-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
conditions Utility to let specify the entire condition #11033
Comments
@srirammageswaran8 Would conditions.Set work for your use case? ( cluster-api/util/conditions/setter.go Line 41 in 4f1637e
|
@sbueringer , Thanks for the followup. The |
What is your use case for changing LastTransistionTime in a case where it shouldn't be changed? |
Chatted with @srirammageswaran8 offline, the main use cases we've chatted about, which might or might not be a fit for conditions, is when a transition is known to be happened at a different time and the condition is observing when the state has changed. For example, say "ec2 instance created" the timestamp can be gathered from the APIs |
Thanks @vincepri . Instead of using the observed value of the resource I was trying to get the actual time of the transition of the resource to the conditions. |
Ah now I got it. I think that makes sense based on the godoc of the LastTransitionTime field |
Would be good to hear @fabriziopandini's opinion |
Maybe we can just change the existing Set function to always "accept" the LastTransitionTime when it is set on the condition that is passed in |
If I can give my two cents, changing the LastTransitionTime could be surprising for users, and in fact the definition of this field explicitly call out that using then using the time when the API field changed is acceptable. In fact, by a quick check, api machinery condition utils do not allow changing last transition time too (but it seems they do allow changes of reason, message and observed generation 🤔). Considering that the new Cluster API condition utils I'm working on are going to relies on upstream condition utils and thus do not allow changing last transition time, frankly speaking I don't think we should make it possible to change lasttransition time in existing CAPI condition utils. |
I think then we should fix our godoc. It seems to clearly state that it's preferred that the lastTransitionTime "should be when the underlying condition changed" Although the upstream metav1.Condition has the same godoc comment: // lastTransitionTime is the last time the condition transitioned from one status to another.
// This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. It's very confusing to me if the "should" case is the one that we don't support |
To me the godoc make sense. I read it as:
|
I'm reading
as the lastTranistionTime should be the time when "whatever is underlying this condition" changes (e.g. some change in the infrastructure) And then
(i.e. the time when the condition field changes) is just meant as a fallback if the transition time of the "underlying condition" is not known |
I took some additional time to compare existing conditions utils and future/upstream aligned conditions utils Those are the diffs:
Both seems bug to me, and by just fixing 1 also this issue should be addressed (but I would fix both) |
Sounds good to me. I would also fix both. It's really confusing if the lastTransitionTime changes just because e.g. the message of a condition changes |
/help |
@fabriziopandini: GuidelinesPlease ensure that the issue body includes answers to the following questions:
For more details on the requirements of such an issue, please see here and ensure that they are met. 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-sigs/prow repository. |
cc @srirammageswaran8 @vincepri ^^ (in case you are interested to implement it) |
So the fix for this issue would be updating the Set() method
So fix for this issue is to fix these two in existing condition utility or are you looking for something else as well. |
Both changes should be implemented in https://github.com/fabriziopandini/cluster-api/blob/a8ae016c1800887ecd0683ac2e4720e6f9626d73/util/conditions/setter.go#L41-L78 |
Thank you, Will try to submit a PR with change |
/assign @Karthik-K-N |
What would you like to be added (User Story)?
A new conditions utility to upsert conditions with the given LastTransistionTime and state fields.
Detailed Description
The LastTransistionTime definition Says
Would be better to have a utility in conditions to let it specify the entire condition and upsert the condition when the condition type already exists. The Utility should add / update the condition with the given state fields which include
And the LastTransistionTime specified in the new condition to add.
Anything else you would like to add?
The Utility may be used to track the transition of the state in any cloud provider / any other resources.
Label(s) to be applied
/kind feature
One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels.
The text was updated successfully, but these errors were encountered: