Skip to content

Commit ae8d2d2

Browse files
authored
Merge pull request #10591 from Levi080513/huangwei/op-mhc-warning-event
🐛 Skip publishing the `RemediationRestricted` event when there are no unhealthy target
2 parents 80b3ceb + 3e589fc commit ae8d2d2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

internal/controllers/machinehealthcheck/machinehealthcheck_controller.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,15 @@ func (r *Reconciler) reconcile(ctx context.Context, logger logr.Logger, cluster
279279
Message: message,
280280
})
281281

282-
r.recorder.Event(
283-
m,
284-
corev1.EventTypeWarning,
285-
EventRemediationRestricted,
286-
message,
287-
)
282+
// If there are no unhealthy target, skip publishing the `RemediationRestricted` event to avoid misleading.
283+
if len(unhealthy) != 0 {
284+
r.recorder.Event(
285+
m,
286+
corev1.EventTypeWarning,
287+
EventRemediationRestricted,
288+
message,
289+
)
290+
}
288291
errList := []error{}
289292
for _, t := range append(healthy, unhealthy...) {
290293
if err := t.patchHelper.Patch(ctx, t.Machine); err != nil {

0 commit comments

Comments
 (0)