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

CreateOrUpdate falsely claiming its updating resources #847

Closed
mcristina422 opened this issue Mar 9, 2020 · 8 comments
Closed

CreateOrUpdate falsely claiming its updating resources #847

mcristina422 opened this issue Mar 9, 2020 · 8 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Milestone

Comments

@mcristina422
Copy link
Contributor

While using CreateOrUpdate with resources that get defaulted it can return OperationResultUpdated despite there being no updates. I'm not concerned that the call to Update is happening, the same values get defaulted. But I think returning OperationResultUpdated is wrong since nothing was actually updated. I think that OperationResultUpdated should only be returned when the ResourceVersion is not equal to the original.
https://github.com/kubernetes-sigs/controller-runtime/compare/master...mcristina422:cmpResourseVersion?expand=1#diff-4c146d38c03cf55e321de9ad53af4452R220-R238

I originally came across this issue setting ports on Service similar to #464 (comment)

I recreated the issue in a Deployment with my proposed fix in https://github.com/kubernetes-sigs/controller-runtime/compare/master...mcristina422:cmpResourseVersion?expand=1

@DirectXMan12 do you think my proposal makes sense

@DirectXMan12
Copy link
Contributor

I think that makes sense, off the top of my head. I'm assuming the previous semantics were "did I submit an update", not "did an update actually occur" though. Anyone else have thoughts?

cc @alexeldeib who touched that code last.

/kind feature
/priority awaiting-more-evidence

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. labels Mar 14, 2020
@mcristina422
Copy link
Contributor Author

The reason I prefer it not to be just "did I submit an update" is that I use the result to determine if the Owned resource I am updating has been modified. If so, end the reconciliation early and let the update of the Owned object trigger a rereconcile and progress further into the reconcile logic. If this is not intended behavior thats understandable

@alexeldeib
Copy link
Contributor

alexeldeib commented Mar 14, 2020

Seems reasonable. Currently if an object was found remotely (i.e., it's an update) but there is no difference, we no-op locally and return OperationResultNone, nil:

if equality.Semantic.DeepEqual(existing, obj) {
return OperationResultNone, nil
}

I think this change makes our behavior consistent so that OperationResultNone + no error means "the object you submitted and the object in the API server were the same". Right now we have an edge case where we tell the user that the blackbox create or update succeeded, but they have to go diff the objects themselves to figure out what happened. I personally think the important semantic is that something changed -- depending on using CreateOrUpdate to submit no-ops to the API server seems like something I'd discourage anyway.

@alexeldeib
Copy link
Contributor

@mcristina422 can you clarify your use case slightly? You have a controller on e.g. the parent objects and when the parent tries to CreateOrUpdate a child object, you want to use the OperationResultUpdated to let the child re-trigger the parent to reconcile?

Without depending on OperationResult here, you should be able to do this by having the parent CreateOrUpdate the child, and then check for a status field on the child object.

@vincepri vincepri added this to the Next milestone Mar 26, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 24, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 24, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Projects
None yet
Development

No branches or pull requests

6 participants