-
Notifications
You must be signed in to change notification settings - Fork 99
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
Don't rely on in-reconciler state to determine last-in-cluster. #33
Don't rely on in-reconciler state to determine last-in-cluster. #33
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markusthoemmes: 0 warnings.
In response to this:
Proposed Changes
Trying to determine the last resource in the cluster via state kept in the reconciler is racy and error-prone. Ask the API instead.
Deployments should also be removed via the ownerRef. An explicit deletion shouldn't be necessary.
Release Note
NONE
/assign @houshengbo @jcrossley3 @aliok
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.
Hi @markusthoemmes. Thanks for your PR. I'm waiting for a knative-sandbox 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Makes sense. Thanks! Just a couple questions.
return fmt.Errorf("failed to list all KnativeEventings: %w", err) | ||
} | ||
|
||
if len(kes.Items) == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious whether there's also a race condition here. Specifically, if the API server tells us there are 2 while both are being deleted, is it safe to rely on the other's reconcile loop to delete the cluster-scoped resources? I assume so, but just checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, you are right. I'll make this a little more bulletproof by checking if all items have a DeletionTimestamp set, i.e.: All resources are being deleted.
return fmt.Errorf("failed to list all KnativeServings: %w", err) | ||
} | ||
|
||
if len(kes.Items) == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question above applies, but also makes me wonder if we can factor this "delete the RBAC last" logic into a shared lib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably can, yes. This is part of a larger refactor which I wanted to get through first before consolidating too much.
if allBeingDeleted { | ||
// If the list has only one element, we're currently reconciling the last one and thus | ||
// can go ahead and delete cluster-scoped resources. | ||
manifest, err := r.transform(ctx, instance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along the line 263 before, you use r.transform(instance), but add ctx as another param here. Which one should be the correct one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. they are two different functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both will eventually have a ctx once I land a followup of this that will use genreconciler for KnativeEventing as well.
It boils down to logger usage: We should always use the logger in the context, because it has all the... well... context already set to it.
/ok-to-test |
316bcfd
to
96c722c
Compare
20ab838
to
fc24d1b
Compare
fc24d1b
to
db52b0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: houshengbo, markusthoemmes 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 |
/test pull-knative-sandbox-operator-integration-tests |
hmpf, rebase mistake. |
4e63b35
to
0fcb8de
Compare
/lgtm |
@markusthoemmes: PR needs rebase. 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. |
Signed-off-by: Matthias Wessendorf <[email protected]>
Proposed Changes
Trying to determine the last resource in the cluster via state kept in the reconciler is racy and error-prone. Ask the API instead.
Deployments should also be removed via the ownerRef. An explicit deletion shouldn't be necessary.
Release Note
/assign @houshengbo @jcrossley3 @aliok