-
Notifications
You must be signed in to change notification settings - Fork 695
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 owner references in reconcile resource util function #3574
Conversation
We previously set owner references only on creation as they usually don't change. With the association model in ECK ownership can change though. This commit takes this into account by resetting the owner reference on updates.
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 was wondering why we are not reusing the logic of the ReconcileResource
function:
NeedsUpdate()
detects if owners need to be updatedUpdateReconciled()
updates the owners
I guess this is because we want to do that for all the resources ? But is it not a bit inconsistent with the fact that NeedsUpdate()
may prevent the ownership to be fixed, because it does not detect that owners
needs to be updated ?
cloud-on-k8s/pkg/controller/common/reconciler/secret.go
Lines 25 to 31 in 869870f
NeedsUpdate: func() bool { | |
// update if expected labels and annotations are not there | |
return !maps.IsSubset(expected.Labels, reconciled.Labels) || | |
!maps.IsSubset(expected.Annotations, reconciled.Annotations) || | |
// or if secret data is not strictly equal | |
!reflect.DeepEqual(expected.Data, reconciled.Data) | |
}, |
@@ -160,11 +160,24 @@ func ReconcileResource(params Params) error { | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
expectedMeta, err := meta.Accessor(params.Expected) |
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.
nit: maybe move those lines a bit closer to where expectedMeta
is used
I think that is a fair point. I guess the only problem with that approach is that we would have to remember at each use of the Regarding the question of whether we would miss the owner upgrade if it is not included in the I don't feel super strongly about both points and am happy to reconsider if we think an explicit inclusion of the owner reference in |
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.
My thinking was that thats somewhat inconsistent with the current signature of the function as it takes an owner as an argument which sort of indicates that it will handle the OwnerReference for the caller.
👍 I'm fine with keeping the PR as is
We previously set owner references only on creation as they usually don't change. With the association model in ECK ownership can change though. The referenced resource can change and the controller e.g. the Elasticsearch controller for a Kibana -> Elasticsearch relationship relies on the owner referrence in its watch on secrets.
This PR takes this into account by resetting the owner reference on updates.
Fixes #3470