@@ -28,6 +28,7 @@ import (
2828 commonconditions "github.com/medik8s/common/pkg/conditions"
2929 "github.com/medik8s/common/pkg/etcd"
3030 commonevents "github.com/medik8s/common/pkg/events"
31+ commonlabels "github.com/medik8s/common/pkg/labels"
3132 "github.com/medik8s/common/pkg/lease"
3233 "github.com/medik8s/common/pkg/nodes"
3334 "github.com/pkg/errors"
@@ -353,6 +354,13 @@ func (r *NodeHealthCheckReconciler) Reconcile(ctx context.Context, req ctrl.Requ
353354 continue
354355 }
355356
357+ if r .isNodeRemediationExcluded (& node ) {
358+ msg := fmt .Sprintf ("Skipped remediation because node %s is marked to exclude remediations" , node .GetName ())
359+ log .Info (msg )
360+ commonevents .WarningEvent (r .Recorder , nhc , utils .EventReasonRemediationSkipped , msg )
361+ continue
362+ }
363+
356364 log .Info ("handling unhealthy node" , "node" , node .GetName ())
357365 requeueAfter , err := r .remediate (ctx , & node , nhc , resourceManager )
358366 if err != nil {
@@ -872,6 +880,15 @@ func (r *NodeHealthCheckReconciler) addRemediationTemplateCRWatch(templateCR *un
872880 return nil
873881}
874882
883+ func (r * NodeHealthCheckReconciler ) isNodeRemediationExcluded (node * v1.Node ) bool {
884+ if nodeLabels := node .GetLabels (); nodeLabels == nil {
885+ return false
886+ } else {
887+ _ , isNodeExcluded := nodeLabels [commonlabels .ExcludeFromRemediation ]
888+ return isNodeExcluded
889+ }
890+ }
891+
875892func getTimeoutAt (remediation * remediationv1alpha1.Remediation , configuredTimeout * time.Duration ) time.Time {
876893 return remediation .Started .Add (* configuredTimeout )
877894}
0 commit comments