-
Notifications
You must be signed in to change notification settings - Fork 21
OCPBUGS-63029: controllers: cleanup status conditions update #2426
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
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: shajmakh 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 |
|
@shajmakh: This pull request references Jira Issue OCPBUGS-63029, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. 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 openshift-eng/jira-lifecycle-plugin repository. |
|
/jira refresh |
|
@shajmakh: This pull request references Jira Issue OCPBUGS-63029, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: 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 openshift-eng/jira-lifecycle-plugin repository. |
|
relies on #2324 |
|
/retest |
Tal-or
left a comment
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.
Code wise LGTM but I need to have another cycle to understand the logic more clearly
ffromani
left a comment
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.
Unifying the status/conditions management is a good idea. I actually dislike the InPlace approach and I'd like to see THAT gone, not the other way around
is I understand you correctly, you want the code to explicitly return an updated condition set for more safe and guaranteed conditions updates, is that right? |
Unless there are obvious and major performance constraints, which we don't have evidence is the case, I strongly prefer to have functions which construct a full set of new conditions, likely based on the existing ones, rather than mutate the current set. IOW, the |
804df43 to
88e7afc
Compare
|
/retest |
88e7afc to
0058ce8
Compare
|
@shajmakh: This pull request references Jira Issue OCPBUGS-63029, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: 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 openshift-eng/jira-lifecycle-plugin repository. |
The old version of the function was updating the condition inplace without considering whether the it's a base condition or not. The difference in base and non-base condition is that the status of one base condition affect all others, thus the rest would need an update too. The new version enhances this and splits the conditions into base and non-base ones and update all conditions accordingly using u/s SetStatusCondition, which also cares to avoid noisy updates. ref: https://github.com/kubernetes/apimachinery/blob/master/pkg/api/meta/conditions.go note that this peice is part of a larger enhancement that will soon be used in the NRO-controller to update the conditions there. Signed-off-by: Shereen Haj <[email protected]>
Since we are relying on `"k8s.io/apimachinery/pkg/api/meta"` function to update the conditions, use also the u/s function to find the condition. Signed-off-by: Shereen Haj <[email protected]>
So far we had only base conditions for the NRO object, but we want to have a more flexible interface to interact with while supporting non-base conditions, just like we have for NRS controller. In this commit: 1. preserve the consistency of updating status conditions for numaresources CRs (operator and scheduler). 2. minimize Status.Update calls on degraded condition updates. 3. keep using `conditioninfo` to maintain related commit modifications as much as possible, refactor later (switch to metav1 conditions). 4. update conditions and return them instead of mutation. Signed-off-by: Shereen Haj <[email protected]>
|
/retest |
ffromani
left a comment
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.
thanks for this work. I'm generally in favor but I need another pass to understand deeply the changes and their implications
pkg/status/status.go
Outdated
| // update - so if they are updated since the current conditions. | ||
| func ComputeConditions(currentConditions []metav1.Condition, cond metav1.Condition, now time.Time) ([]metav1.Condition, bool) { | ||
| conditions := NewConditions(cond, now) | ||
| conditions := NewBaseConditionsWith(cond, now) |
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.
why With? Let's clarify further (WithTime?) or drop it
| newBase := NewBaseConditionsWith(condition, ts) | ||
| updated := false | ||
| for idx := range newBase { | ||
| changed := metahelper.SetStatusCondition(&conds, newBase[idx]) | ||
| updated = updated || changed | ||
| } | ||
| return true | ||
| return updated |
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.
do we have testcase(s) which highlight the issues in the old code?
| // UpdateConditionsInPlace mutates the given conditions, setting the value of the one pointed out to `condition` to the given values. | ||
| // Differently from `ComputeConditions`, it doesn't allocate new data. Returns true if successfully mutated conditions, false otherwise | ||
| func UpdateConditionsInPlace(conds []metav1.Condition, condition metav1.Condition, ts time.Time) bool { | ||
| cond := FindCondition(conds, condition.Type) |
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.
good idea. We can remove all the instance of this now-redundant function, can't we?
| // UpdateConditions returns the given conditions updated with the given condition. | ||
| // Returns true if the condition was updated, false otherwise. |
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.
thing is, Update is usually in place. Non in-place operation is Make Compute Create, whatever, but is not Update. We need to fix the naming here, because most certainly we don't want to mutate in-place (Update) if we can help it.
So far we had only base conditions for the NRO object, but we want to
have a more flexible interface to interact with while supporting
non-base conditions, just like we have for NRS controller.
In this commit:
numaresources CRs (operator and scheduler).
conditioninfoto maintain related commit modificationsas much as possible, refactor later (switch to metav1 conditions)