-
Notifications
You must be signed in to change notification settings - Fork 1k
add events for ResourceInterpreter #5541
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: master
Are you sure you want to change the base?
Conversation
Signed-off-by: whitewindmills <[email protected]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/cc @RainbowMango |
|
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5541 +/- ##
==========================================
+ Coverage 33.86% 34.13% +0.26%
==========================================
Files 643 643
Lines 44500 44512 +12
==========================================
+ Hits 15072 15196 +124
+ Misses 28280 28159 -121
- Partials 1148 1157 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
| eventRecorder.Event(resource, corev1.EventTypeWarning, events.EventReasonAggregateStatusFailed, err.Error()) | ||
| return err | ||
| } | ||
| eventRecorder.Event(resource, corev1.EventTypeNormal, events.EventReasonAggregateStatusSucceed, "Aggregated status to object successfully.") |
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 do you need to adjust the position of these two events?
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 tend to add events after each resource interpretation function to reflect whether the resource interpretation is successful.
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.
kind of justification, but I have some concerns:
the event events.EventReasonAggregateStatusSucceed is used more than this place, and thus it will have so different meaning, whether differentiation or unification is needed?
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.
+1
but I don't have a suitable name to distinguish, do you have one?
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’m looking for references in other interpreters and found that functions like GetDependencies have an event GetDependenciesFailed, ReflectStatus has ReflectStatusFailed, and InterpretHealth has InterpretHealthFailed. These align with the meaning introduced in your PR, so naming this event AggregateStatusFailed in the position of your updated lines seems reasonable.
However, in workstatus.go, there are two place also using this event name which seem to represent successfully collected and updated status of RB. To differentiate, perhaps SyncBindingStatusFailed would be more appropriate? (ps: I'm also poor at naming.)
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.
So you want the AggregateStatusSucceed and AggregateStatusFailed dedicated to indicating resource interpreter status? That means that updating failure after interpreter.AggregateStatus, should not report event.
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.
yes, such update error can be fixed by reconciliation.
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.
ping @RainbowMango
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.
But at the time emitting the success event, the aggregate operation might still not happen, in addition, there might be more than one events due to the retry loop.
I'm afraid it is not acceptable.
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.
other functions of the current resource interpretation framework are also designed in this way, so another purpose of this PR is to be consistent with them.
-
ReflectStatus:
karmada/pkg/controllers/status/work_status_controller.go
Lines 359 to 366 in 836b878
statusRaw, err := c.ResourceInterpreter.ReflectStatus(clusterObj) if err != nil { klog.Errorf("Failed to reflect status for object(%s/%s/%s) with resourceInterpreter, err: %v", clusterObj.GetKind(), clusterObj.GetNamespace(), clusterObj.GetName(), err) c.EventRecorder.Eventf(work, corev1.EventTypeWarning, events.EventReasonReflectStatusFailed, "Reflect status for object(%s/%s/%s) failed, err: %s.", clusterObj.GetKind(), clusterObj.GetNamespace(), clusterObj.GetName(), err.Error()) return err } c.EventRecorder.Eventf(work, corev1.EventTypeNormal, events.EventReasonReflectStatusSucceed, "Reflect status for object(%s/%s/%s) succeed.", clusterObj.GetKind(), clusterObj.GetNamespace(), clusterObj.GetName()) -
InterpretHealth:
karmada/pkg/controllers/status/work_status_controller.go
Lines 371 to 380 in 836b878
healthy, err := c.ResourceInterpreter.InterpretHealth(clusterObj) if err != nil { resourceHealth = workv1alpha1.ResourceUnknown c.EventRecorder.Eventf(work, corev1.EventTypeWarning, events.EventReasonInterpretHealthFailed, "Interpret health of object(%s/%s/%s) failed, err: %s.", clusterObj.GetKind(), clusterObj.GetNamespace(), clusterObj.GetName(), err.Error()) } else if healthy { resourceHealth = workv1alpha1.ResourceHealthy c.EventRecorder.Eventf(work, corev1.EventTypeNormal, events.EventReasonInterpretHealthSucceed, "Interpret health of object(%s/%s/%s) as healthy.", clusterObj.GetKind(), clusterObj.GetNamespace(), clusterObj.GetName()) } else { resourceHealth = workv1alpha1.ResourceUnhealthy c.EventRecorder.Eventf(work, corev1.EventTypeNormal, events.EventReasonInterpretHealthSucceed, "Interpret health of object(%s/%s/%s) as unhealthy.", clusterObj.GetKind(), clusterObj.GetNamespace(), clusterObj.GetName()) -
GetDependencies:
karmada/pkg/dependenciesdistributor/dependencies_distributor.go
Lines 271 to 277 in 836b878
dependencies, err := d.ResourceInterpreter.GetDependencies(workload) if err != nil { klog.Errorf("Failed to customize dependencies for %s(%s), %v", workload.GroupVersionKind(), workload.GetName(), err) d.EventRecorder.Eventf(workload, corev1.EventTypeWarning, events.EventReasonGetDependenciesFailed, err.Error()) return reconcile.Result{}, err } d.EventRecorder.Eventf(workload, corev1.EventTypeNormal, events.EventReasonGetDependenciesSucceed, "Get dependencies(%+v) succeed.", dependencies)
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: