Skip to content

Commit

Permalink
Validate that CI Operator pods have resource limits
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov committed Sep 26, 2018
1 parent 2d55905 commit 47faff6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion hack/validate-prow-job-semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def main():
if not failed:
with open(path) as f:
data = yaml.load(f)
for check in [validate_job_repo, validate_names, validate_sharding, validate_access, validate_pod_name]:
for check in [validate_job_repo, validate_names, validate_sharding, validate_access, validate_pod_name, validate_resources]:
check(path, data)

if failed:
Expand Down Expand Up @@ -211,4 +211,26 @@ def validate_image_pull(path, data):

return out

def validate_resources(path, data):
out = True
for job_type in data:
if job_type == "periodics":
continue

for repo in data[job_type]:
for job in data[job_type][repo]:
if job["agent"] != "kubernetes":
continue

if job["spec"]["containers"][0]["command"][0] != "ci-operator":
continue

resources = {"limits":{"cpu":"500m"},"requests":{"cpu":"10m"}}
if "resources" not in job["spec"]["containers"][0] or job["spec"]["containers"][0]["resources"] != resources:
print("[ERROR] {}: ci-operator job {} should set the pod's CPU resources to {}".format(path, job["name"], resources))
out = False
continue

return out

main()

0 comments on commit 47faff6

Please sign in to comment.