Skip to content

Commit

Permalink
Separate number of projects without limits and quota
Browse files Browse the repository at this point in the history
  • Loading branch information
u219911 committed May 9, 2019
1 parent c741272 commit a146998
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ HAWCULAR\_SVC\_IP|MASTER|Ip of the hawcular service|10.10.10.1
ETCD\_IPS|MASTER|Ips of the etcd hosts with protocol & port|https://192.168.125.241:2379,https://192.168.125.244:2379
REGISTRY\_SVC\_IP|MASTER|Ip of the registry service|10.10.10.1
ROUTER\_IPS|MASTER|Ips of the routers services|10.10.10.1,10.10.10.2
PROJECTS\_WITHOUT\_LIMITS|MASTER|Number of system projects that have no limits & quotas|4
PROJECTS\_WITHOUT\_LIMITS|MASTER|Number of system projects that have no limits |4
PROJECTS\_WITHOUT\_QUOTA|MASTER|Number of system projects that have no quotas |4
IS\_GLUSTER\_SERVER|STORAGE|Boolean value of the node is a gluster server|true/false
MOUNTPOINTS\_TO\_CHECK|A list of mount points where free size should be checked|/gluster/registry/,/gluster/xxx
CHECK\_CERTIFICATE\_URLS|A list of urls to check for validity of certificate|https://master-ip:8443
Expand Down
10 changes: 5 additions & 5 deletions daemon/client/checks/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func checkEtcdHealthWithCertPath(msg *string, certPath string, etcdIps string) b
return true
}

func CheckLimitsAndQuotas(allowedWithout int) error {
func CheckLimitsAndQuota(allowedWithoutLimits int, allowedWithoutQuota int) error {
log.Println("Checking limits & quotas")

// Count projects
Expand All @@ -438,7 +438,7 @@ func CheckLimitsAndQuotas(allowedWithout int) error {
return errors.New(msg)
}

// Count quotas
// Count quota
quotaCount, err := exec.Command("bash", "-c", "oc get quota --all-namespaces | wc -l").Output()
if err != nil {
msg := "Could not parse quota count" + err.Error()
Expand All @@ -453,11 +453,11 @@ func CheckLimitsAndQuotas(allowedWithout int) error {

log.Println("Parsed values (projects,limits,quotas)", pCount, lCount, qCount)

if pCount-allowedWithout != lCount {
if pCount-allowedWithoutLimits <= lCount {
return errors.New("There are some projects without limits")
}
if pCount-allowedWithout != qCount {
return errors.New("There are some projects without quotas")
if pCount-allowedWithoutQuota <= qCount {
return errors.New("There are some projects without quota")
}

return nil
Expand Down
17 changes: 11 additions & 6 deletions daemon/client/handlers/minor.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ func HandleMinorChecks(daemonType string, w http.ResponseWriter, r *http.Request
if daemonType == "MASTER" {
externalSystem := os.Getenv("EXTERNAL_SYSTEM_URL")
hawcularIp := os.Getenv("HAWCULAR_SVC_IP")
allowedWithout := os.Getenv("PROJECTS_WITHOUT_LIMITS")
allowedWithoutLimits := os.Getenv("PROJECTS_WITHOUT_LIMITS")
allowedWithoutQuota := os.Getenv("PROJECTS_WITHOUT_QUOTA")
certUrls := os.Getenv("CHECK_CERTIFICATE_URLS")

if len(externalSystem) == 0 || len(allowedWithout) == 0 || len(certUrls) == 0 {
log.Fatal("env variables 'EXTERNAL_SYSTEM_URL', 'PROJECTS_WITHOUT_LIMITS', 'CHECK_CERTIFICATE_URLS' must be specified on type 'MASTER'")
if len(externalSystem) == 0 || len(allowedWithoutLimits) == 0 || len(allowedWithoutQuota) == 0 || len(certUrls) == 0 {
log.Fatal("env variables 'EXTERNAL_SYSTEM_URL', 'PROJECTS_WITHOUT_LIMITS', 'PROJECTS_WITHOUT_QUOTA', 'CHECK_CERTIFICATE_URLS' must be specified on type 'MASTER'")
}

allowedWithoutInt, err := strconv.Atoi(allowedWithout)
allowedWithoutLimitsInt, err := strconv.Atoi(allowedWithoutLimits)
if err != nil {
log.Fatal("allowedWithout seems not to be an integer", allowedWithout)
log.Fatal("allowedWithoutLimits seems not to be an integer", allowedWithoutLimits)
}
allowedWithoutQuotaInt, err := strconv.Atoi(allowedWithoutQuota)
if err != nil {
log.Fatal("allowedWithoutLimits seems not to be an integer", allowedWithoutQuota)
}

// boolean false means exclude buildnodes
Expand All @@ -76,7 +81,7 @@ func HandleMinorChecks(daemonType string, w http.ResponseWriter, r *http.Request
errors = append(errors, err.Error())
}

if err := checks.CheckLimitsAndQuotas(allowedWithoutInt); err != nil {
if err := checks.CheckLimitsAndQuota(allowedWithoutLimitsInt, allowedWithoutQuotaInt); err != nil {
errors = append(errors, err.Error())
}

Expand Down

0 comments on commit a146998

Please sign in to comment.