Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed pod's cpu & mem resource setters helpers. #608

Conversation

greyerof
Copy link
Contributor

The original implementation was overwriting any req/limit that was previosly set for the other resources. For instance, test cases doing this didn't work properly:

  pod.RedefineWithCPUResources(testPod, "1", "1")
  pod.RedefineWithMemoryResources(testPod, "512Mi", "512Mi")

The call to pod.RedefineWithMemoryResources() was zero-ing the cpu req/limits that was just set before ("1", "1") as it was creating a new empty container.Resources field (corev1.ResourceRequirements{}).

The new implementations don't overwrite other reqs/limits values, they just set/overwrite the corresponding ones (cpu/mem).

The affected test cases were passing until now because a bug in the cert suite code in the function AreCPUResourcesWholeUnits() that was wrongly returning "true" when the cpu reqs/limit were not set. It was fixed here:
redhat-best-practices-for-k8s/certsuite#1631

The original implementation was overwriting any req/limit that was
previosly set for the other resources. For instance, test cases
doing this didn't work properly:

  pod.RedefineWithCPUResources(testPod, "1", "1")
  pod.RedefineWithMemoryResources(testPod, "512Mi", "512Mi")

The call to pod.RedefineWithMemoryResources() was zero-ing the cpu
req/limits that was just set before ("1", "1") as it was creating a new
empty container.Resources field (corev1.ResourceRequirements{}).

The new implementations don't overwrite other reqs/limits values, it
justs sets/overwrite the corresponding ones (cpu/mem).

The affected test cases were passing until now because a bug in the cert
suite code in the function AreCPUResourcesWholeUnits() that was wrongly
returning "true" when the cpu reqs/limit were not set. It was fixed
here:
redhat-best-practices-for-k8s/certsuite#1631
@greyerof
Copy link
Contributor Author

@sebrandon1 this should fix PR #607

@sebrandon1 sebrandon1 merged commit 9b8506e into redhat-best-practices-for-k8s:main Nov 17, 2023
3 checks passed
sebrandon1 added a commit to sebrandon1/cnfcert-tests-verification that referenced this pull request Dec 5, 2023
* origin/main:
  Switch to 1-to-1 result struct mapping (redhat-best-practices-for-k8s#616)
  Bump github.com/onsi/ginkgo/v2 from 2.13.1 to 2.13.2 (redhat-best-practices-for-k8s#615)
  Fix CI badge (redhat-best-practices-for-k8s#614)
  Bump github.com/operator-framework/api from 0.19.0 to 0.20.0 (redhat-best-practices-for-k8s#613)
  Bump github.com/golang/glog from 1.1.2 to 1.2.0 (redhat-best-practices-for-k8s#612)
  Fix pointer (redhat-best-practices-for-k8s#611)
  Add more pod package unit tests (redhat-best-practices-for-k8s#610)
  Update istio to v1.20.0 (redhat-best-practices-for-k8s#609)
  Enable PR checks against test suite (redhat-best-practices-for-k8s#607)
  Fixed pod's cpu & mem resource setters helpers. (redhat-best-practices-for-k8s#608)
  Bump k8s.io/apiextensions-apiserver from 0.28.3 to 0.28.4 (redhat-best-practices-for-k8s#605)
  Adjust SynchronizedAfterSuite (redhat-best-practices-for-k8s#602)
  Revert "Reduce the number of procs for parallel (redhat-best-practices-for-k8s#595)" (redhat-best-practices-for-k8s#601)
  Revert "Increase flaky retries from 2 to 3 (redhat-best-practices-for-k8s#575)" (redhat-best-practices-for-k8s#600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants