-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
controllerutil: Add DeleteIfExists
and TryUpdate
/ TryUpdateStatus
#357
Comments
Going to address these one at a time, because some of them seem to imply that we have documentation issues:
Caveat: this shouldn't really matter, except for performance reasons -- if you delete, and it doesn't exist, you should get an error and requeue until the cache updates, or you backoff (and then you'll get a requeue when the cache actually updates). That being said, a Then, /good-first-issue
This seems like a documentation issue on our part, since returning an error from the reconciler will cause an automatic requeue, with backoff if need. Retrying inside a reconciler is generally an anti-pattern -- it leads to non-obvious head-of-line blocking and weird logic errors. Your controllers should be idempotent, so requeuing shouldn't cause issues. What's your usecase here that's not solved by requeuing?
Same as above. |
@DirectXMan12: Please ensure the request meets the requirements listed here. If this request no longer meets these requirements, the label can be removed In response to this:
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. |
When developing controllers, other methods that are frequently required and are missing in the controllerutil package are:
DeleteIfExists
: Delete a resource if it exists, otherwise do nothingTryUpdate
: Update a resource, if aConflict
is returned, retry (withwait.Backoff
?)TryUpdateStatus
: Same asTryUpdate
but for theStatus
subresource.This would require making a more general
OperationResult
type that incorporates all possibleOperationResult
(likeOperationResultDeleted
,OperationResultUpdated
etc.) and having 'subclasses' per operation, i.e.CreateOrUpdateResultCreated = CreateOrUpdateResult(OperationResultCreated)
. As such, this would be a partially breaking change.Since I already make use of these methods, I already implemented them and just quickly tried to incorporate them in the controller-runtime. For reference, please look here.
The text was updated successfully, but these errors were encountered: