-
Notifications
You must be signed in to change notification settings - Fork 850
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
Add event recorder to show chaos status. #245
Conversation
Codecov Report
@@ Coverage Diff @@
## master #245 +/- ##
==========================================
+ Coverage 52.9% 60.67% +7.77%
==========================================
Files 34 36 +2
Lines 1603 2014 +411
==========================================
+ Hits 848 1222 +374
- Misses 668 698 +30
- Partials 87 94 +7
Continue to review full report at Codecov.
|
HI. Currently I only add event recorder for the controller-manager. Its events are still missing. I wonder whether we should gather all of events around the chaos resource or spread the events to the owned resources. I prefer the previous one. |
Another problem is that shall we keep track of normal execution of a chaos action? Should the event report the chaos progress? |
I think we should
I think the scheduler chaos can not show the progress, we did not know when to end
|
In my option, I think we can record the event when the chaos starts and ends. |
About this question, If we gather all of the events around the chaos resource, the number of events will be very large and confusing. In my option, I think we can spread the events to the owned resources. |
Make sense ! How about we gather events about chaos actions for begining and ending around the chaos resource? For the events from resources operated by chaos actions, we should let it untouched and K8s will generate events for them. Users can check them if they want. |
We can record an event when to apply chaos action and record the other one when to cancel the action |
As ChaosMesh users needs to know the every timestamp for performing and recovering the chaos action, I suggest that to add event in the certain chaos action controller like following logic: // Apply implements the reconciler.InnerReconciler.Apply
func (r *Reconciler) Apply(ctx context.Context, req ctrl.Request, obj reconciler.InnerObject) error {
// Perform chaos action logic ...
r.Recorder.Event(chaos, v1.EventTypeNormal, utils.EventChaosPerformed, "podfaulre chaos perfromed,affect 3 pods")
}
// Recover implements the reconciler.InnerReconciler.Recover
func (r *Reconciler) Recover(ctx context.Context, req ctrl.Request, obj reconciler.InnerObject) error {
// Recovery chaos action logic
r.Recorder.Event(chaos, v1.EventTypeNormal, utils.EventChaosRecovered, "podfaulre chaos recovered, recover 3 pods")
} In this way, the event would be sent for the |
Yes. It’s a good place for handling chaos starting and recovering event. However, I think we could still record failing events in the entry reconciler. |
@AngleNet Remaining failure event in the entry reconciler is ok to me. |
@AngleNet thank you very much, we will take a look as soon as possible |
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.
The rest lgtm.
if err != nil { | ||
if !chaos.IsDeleted() { | ||
r.Event(chaos, v1.EventTypeWarning, utils.EventChaosInjectFailed, err.Error()) | ||
} else { | ||
r.Event(chaos, v1.EventTypeWarning, utils.EventChaosRecoverFailed, err.Error()) | ||
} | ||
} | ||
return result, nil |
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.
The logic seems weird here. If the reconciliation failed, I suggest send event with reconciliation failed event type and add the error message into event message. It is not necessary to judge which kind of chaos action (inject or recover)
@@ -88,6 +94,7 @@ func (r *Reconciler) Apply(ctx context.Context, req ctrl.Request, chaos reconcil | |||
return err | |||
} | |||
|
|||
r.Event(networkchaos, v1.EventTypeNormal, utils.EventChaosToInject, "") |
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.
ditto
controllers/timechaos/types.go
Outdated
@@ -131,6 +127,7 @@ func (r *Reconciler) Recover(ctx context.Context, req ctrl.Request, chaos reconc | |||
return err | |||
} | |||
|
|||
r.Event(timechaos, v1.EventTypeNormal, utils.EventChaosToRecover, "") |
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.
ditto.
if err != nil { | ||
if !chaos.IsDeleted() { | ||
r.Event(chaos, v1.EventTypeWarning, utils.EventChaosInjectFailed, err.Error()) | ||
} else { | ||
r.Event(chaos, v1.EventTypeWarning, utils.EventChaosRecoverFailed, err.Error()) | ||
} |
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.
ditto.
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.
LGTM
@Yisaer Please take a final look 😝 |
Add event recorder to show chaos status
What problem does this PR solve?
#162 Add event recorder to show chaos status after we have applied a resource.
What is changed and how does it work?
Check List
Tests
Code changes
Side effects
Related changes
Does this PR introduce a user-facing change?: