-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
⚠ Update fake client deletionTimestamp behavior #2316
⚠ Update fake client deletionTimestamp behavior #2316
Conversation
|
Welcome @lleshchi! |
Hi @lleshchi. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
8522ea3
to
eeea5bb
Compare
eeea5bb
to
c28b017
Compare
c28b017
to
b7d4a85
Compare
This is looking solid to me. One minor query inline. Also, I'm not digging deep into the test cases -- leaving that for the experts :) |
@lleshchi Could it be that you forgot to push the new version? :) |
@sbueringer Was waiting on a clarification from @vincepri regarding one of the review comments. Otherwise, pushing changes now :) |
b7d4a85
to
c9d9599
Compare
Which one? :) |
Apologies, I reach out in slack about this. Should have posted here as well |
The current fake client methods diverge from the behavior of real k8s. This results in scenarios where an object can be created or modified to have a deletionTimestamp and no finalizers, with a delay in garbage collection, causing inaccurate or ambiguous behavior in test cases that use the fake client. Bring fake client behavior closer in line with real k8s behavior by modifying the following: - Update() and Patch() will reject changes that set a previously-unset deletionTimestamp - Create() will ignore a deletionTimestamp on an object - Build() will error if initialized with an object that has a deletionTimestamp but no finalizers; but will accept a deletionTimestamp if it has finalizers. Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
c9d9599
to
7a66d58
Compare
Thank you! /lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lleshchi, sbueringer The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Rewrite unittests to accommodate changes in controller-runtime v0.15.0 and create a hive specific scheme. One such major change involves the behavior of the fake client deletionTimestamp. The fake client will panic if initialized with an object that has a DeletionTimestamp and no finalizer, and will silently ignore a DeletionTimestamp on an object in a Create request, matching the behavior of the kube-apiserver. Tests have been rewritten to work with this new behavior. kubernetes-sigs/controller-runtime#2316 This update also includes a requirement to register a fake client WithStatusSubresource in order to successfully update the Status subresource of an object. Due to this change, the helper function NewFakeClientBuilder() is added to pkg/test/fake to allow for easier setup of a fake client with the necessary sub-resources. kubernetes-sigs/controller-runtime#2259 Lastly, a new singleton scheme has been introduced to the codebase. The hive specific scheme is registered once, with all necessary packages, and used throughout the codebase, removing the need to specify unique schemes for each use case, and decreasing the overall amount of imports. Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Rewrite unittests to accommodate changes in controller-runtime v0.15.0 and create a hive specific scheme. One such major change involves the behavior of the fake client deletionTimestamp. The fake client will panic if initialized with an object that has a DeletionTimestamp and no finalizer, and will silently ignore a DeletionTimestamp on an object in a Create request, matching the behavior of the kube-apiserver. Tests have been rewritten to work with this new behavior. kubernetes-sigs/controller-runtime#2316 This update also includes a requirement to register a fake client WithStatusSubresource in order to successfully update the Status subresource of an object. Due to this change, the helper function NewFakeClientBuilder() is added to pkg/test/fake to allow for easier setup of a fake client with the necessary sub-resources. kubernetes-sigs/controller-runtime#2259 Lastly, a new singleton scheme has been introduced to the codebase. The hive specific scheme is registered once, with all necessary packages, and used throughout the codebase, removing the need to specify unique schemes for each use case, and decreasing the overall amount of imports. Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Rewrite unittests to accommodate changes in controller-runtime v0.15.0 and create a hive specific scheme. One such major change involves the behavior of the fake client deletionTimestamp. The fake client will panic if initialized with an object that has a DeletionTimestamp and no finalizer, and will silently ignore a DeletionTimestamp on an object in a Create request, matching the behavior of the kube-apiserver. Tests have been rewritten to work with this new behavior. kubernetes-sigs/controller-runtime#2316 This update also includes a requirement to register a fake client WithStatusSubresource in order to successfully update the Status subresource of an object. Due to this change, the helper function NewFakeClientBuilder() is added to pkg/test/fake to allow for easier setup of a fake client with the necessary sub-resources. kubernetes-sigs/controller-runtime#2259 Lastly, a new singleton scheme has been introduced to the codebase. The hive specific scheme is registered once, with all necessary packages, and used throughout the codebase, removing the need to specify unique schemes for each use case, and decreasing the overall amount of imports. Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Rewrite unittests to accommodate changes in controller-runtime v0.15.0 and create a hive specific scheme. One such major change involves the behavior of the fake client deletionTimestamp. The fake client will panic if initialized with an object that has a DeletionTimestamp and no finalizer, and will silently ignore a DeletionTimestamp on an object in a Create request, matching the behavior of the kube-apiserver. Tests have been rewritten to work with this new behavior. kubernetes-sigs/controller-runtime#2316 This update also includes a requirement to register a fake client WithStatusSubresource in order to successfully update the Status subresource of an object. Due to this change, the helper function NewFakeClientBuilder() is added to pkg/test/fake to allow for easier setup of a fake client with the necessary sub-resources. kubernetes-sigs/controller-runtime#2259 Lastly, a new singleton scheme has been introduced to the codebase. The hive specific scheme is registered once, with all necessary packages, and used throughout the codebase, removing the need to specify unique schemes for each use case, and decreasing the overall amount of imports. Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Rewrite unittests to accommodate changes in controller-runtime v0.15.0 and create a hive specific scheme. One such major change involves the behavior of the fake client deletionTimestamp. The fake client will panic if initialized with an object that has a DeletionTimestamp and no finalizer, and will silently ignore a DeletionTimestamp on an object in a Create request, matching the behavior of the kube-apiserver. Tests have been rewritten to work with this new behavior. kubernetes-sigs/controller-runtime#2316 This update also includes a requirement to register a fake client WithStatusSubresource in order to successfully update the Status subresource of an object. Due to this change, the helper function NewFakeClientBuilder() is added to pkg/test/fake to allow for easier setup of a fake client with the necessary sub-resources. kubernetes-sigs/controller-runtime#2259 Lastly, a new singleton scheme has been introduced to the codebase. The hive specific scheme is registered once, with all necessary packages, and used throughout the codebase, removing the need to specify unique schemes for each use case, and decreasing the overall amount of imports. Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Rewrite unittests to accommodate changes in controller-runtime v0.15.0 and create a hive specific scheme. One such major change involves the behavior of the fake client deletionTimestamp. The fake client will panic if initialized with an object that has a DeletionTimestamp and no finalizer, and will silently ignore a DeletionTimestamp on an object in a Create request, matching the behavior of the kube-apiserver. Tests have been rewritten to work with this new behavior. kubernetes-sigs/controller-runtime#2316 This update also includes a requirement to register a fake client WithStatusSubresource in order to successfully update the Status subresource of an object. Due to this change, the helper function NewFakeClientBuilder() is added to pkg/test/fake to allow for easier setup of a fake client with the necessary sub-resources. kubernetes-sigs/controller-runtime#2259 Lastly, a new singleton scheme has been introduced to the codebase. The hive specific scheme is registered once, with all necessary packages, and used throughout the codebase, removing the need to specify unique schemes for each use case, and decreasing the overall amount of imports. Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Fake client won't create objects after kubernetes-sigs/controller-runtime#2316 if they have DeletionTimeStamp without finalizers Signed-off-by: Waleed Malik <ahmedwaleedmalik@gmail.com>
* Update k8s APIs to v1.28 Signed-off-by: Waleed Malik <ahmedwaleedmalik@gmail.com> * Satisfy fake clients requirement of finalizers with DeletionTimeStamp Fake client won't create objects after kubernetes-sigs/controller-runtime#2316 if they have DeletionTimeStamp without finalizers Signed-off-by: Waleed Malik <ahmedwaleedmalik@gmail.com> * Revert change in all_e2e_test.go Signed-off-by: Waleed Malik <ahmedwaleedmalik@gmail.com> * Refactored code Signed-off-by: Waleed Malik <ahmedwaleedmalik@gmail.com> --------- Signed-off-by: Waleed Malik <ahmedwaleedmalik@gmail.com>
…ernetes libs to v0.30.0 (#3707) * go version, dep version * refactor for controller-runtime udpate * update tests, fix if statement the controller-runtime strips DeletionTimestamp from manifests on Create(). kubernetes-sigs/controller-runtime#2316 * refactor tests * remove placeholder comments * remove reconciler from WithOptions * remove DefaultNamespace cache option * remote `&& !hasGroupFinalizer` This was causing e2e tests to fail when an ingress did not have the group finalizer. The unit tests ing-1_been_deleted, and ing-6_been_deleted will need reworked due to changes in the controller-runtime that cause them to fail. * update unit tests for ctrl client/fake >0.15 controller-runtime >=0.15 does not support creating (or adding the field via Update()) objects with a DeletionTimestamp. To work around this we add an annotation `unit-test/delete` to mark the ingresses that we want to test deletion. We check for this annotation and then call Delete(). This will set the DeletionTimestamp to the current date and time so we use IgnoreOtherFields to skip then comparing want to got. relevant controller-runtime discussion/pr: - kubernetes-sigs/controller-runtime#2184 (comment) - kubernetes-sigs/controller-runtime#2316 * remove unused contexts * add DefaultNamespaces cache config * set opt.Cache.DefaultNamespaces conditionally If WatchNamespace is set to corev1.NamespaceAll we should not set DefaultNamespaces. This code assumes that only one namespace is specified for WatchNamespace. That decision was based on the help text for the flag `watch-namespace`. Related controller-runtime issue: kubernetes-sigs/controller-runtime#2628 * make crds * set go to v1.22.3
…ernetes libs to v0.30.0 (kubernetes-sigs#3707) * go version, dep version * refactor for controller-runtime udpate * update tests, fix if statement the controller-runtime strips DeletionTimestamp from manifests on Create(). kubernetes-sigs/controller-runtime#2316 * refactor tests * remove placeholder comments * remove reconciler from WithOptions * remove DefaultNamespace cache option * remote `&& !hasGroupFinalizer` This was causing e2e tests to fail when an ingress did not have the group finalizer. The unit tests ing-1_been_deleted, and ing-6_been_deleted will need reworked due to changes in the controller-runtime that cause them to fail. * update unit tests for ctrl client/fake >0.15 controller-runtime >=0.15 does not support creating (or adding the field via Update()) objects with a DeletionTimestamp. To work around this we add an annotation `unit-test/delete` to mark the ingresses that we want to test deletion. We check for this annotation and then call Delete(). This will set the DeletionTimestamp to the current date and time so we use IgnoreOtherFields to skip then comparing want to got. relevant controller-runtime discussion/pr: - kubernetes-sigs/controller-runtime#2184 (comment) - kubernetes-sigs/controller-runtime#2316 * remove unused contexts * add DefaultNamespaces cache config * set opt.Cache.DefaultNamespaces conditionally If WatchNamespace is set to corev1.NamespaceAll we should not set DefaultNamespaces. This code assumes that only one namespace is specified for WatchNamespace. That decision was based on the help text for the flag `watch-namespace`. Related controller-runtime issue: kubernetes-sigs/controller-runtime#2628 * make crds * set go to v1.22.3
* update the traffic test for ingress (#3725) * update the traffic test for ingress * make crds * prevent controller runtime complaining about SetupLogger() was never called (#3724) * Update go to v1.22, controller-runtime dependency to v0.18.2, and kubernetes libs to v0.30.0 (#3707) * go version, dep version * refactor for controller-runtime udpate * update tests, fix if statement the controller-runtime strips DeletionTimestamp from manifests on Create(). kubernetes-sigs/controller-runtime#2316 * refactor tests * remove placeholder comments * remove reconciler from WithOptions * remove DefaultNamespace cache option * remote `&& !hasGroupFinalizer` This was causing e2e tests to fail when an ingress did not have the group finalizer. The unit tests ing-1_been_deleted, and ing-6_been_deleted will need reworked due to changes in the controller-runtime that cause them to fail. * update unit tests for ctrl client/fake >0.15 controller-runtime >=0.15 does not support creating (or adding the field via Update()) objects with a DeletionTimestamp. To work around this we add an annotation `unit-test/delete` to mark the ingresses that we want to test deletion. We check for this annotation and then call Delete(). This will set the DeletionTimestamp to the current date and time so we use IgnoreOtherFields to skip then comparing want to got. relevant controller-runtime discussion/pr: - kubernetes-sigs/controller-runtime#2184 (comment) - kubernetes-sigs/controller-runtime#2316 * remove unused contexts * add DefaultNamespaces cache config * set opt.Cache.DefaultNamespaces conditionally If WatchNamespace is set to corev1.NamespaceAll we should not set DefaultNamespaces. This code assumes that only one namespace is specified for WatchNamespace. That decision was based on the help text for the flag `watch-namespace`. Related controller-runtime issue: kubernetes-sigs/controller-runtime#2628 * make crds * set go to v1.22.3 * restrict resolve resolveViaVPCENIs to fargate only (#3709) * Added helm envFrom value parameter for cluster-name (#3683) * Added helm envFrom value parameter for cluster-name * Update README.md file * Add envFrom configuration to values.yaml * Remove empty line in values.yaml * feat: disable default helm labels (#3574) * feat: disable helm labels * fix: doc * Update README.md (#3638) Remove extra / in crds --------- Co-authored-by: Luke Arntz <luke@blue42.net> Co-authored-by: Omer Aplatony <61663422+omerap12@users.noreply.github.com> Co-authored-by: Rémi BUISSON <remi-buisson@orange.fr> Co-authored-by: Mike Wilson <hyperbolic2346@users.noreply.github.com>
Closes #2184
The current fake client methods diverge from the behavior of real k8s. This results in scenarios where an object can be created or modified to have a deletionTimestamp and no finalizers, with a delay in garbage collection, causing inaccurate or ambiguous behavior in test cases that use the fake client.
Bring fake client behavior closer in line with real k8s behavior by modifying the following: