diff --git a/README.md b/README.md index dc65551..050d0c2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/daemon/client/checks/openshift.go b/daemon/client/checks/openshift.go index 191f96f..52f997f 100644 --- a/daemon/client/checks/openshift.go +++ b/daemon/client/checks/openshift.go @@ -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 @@ -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() @@ -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 diff --git a/daemon/client/handlers/minor.go b/daemon/client/handlers/minor.go index 80c686e..e6ad3cb 100644 --- a/daemon/client/handlers/minor.go +++ b/daemon/client/handlers/minor.go @@ -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 @@ -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()) }