@@ -37,6 +37,7 @@ import (
37
37
"github.com/aws/aws-sdk-go/service/sqs"
38
38
"github.com/rs/zerolog"
39
39
"github.com/rs/zerolog/log"
40
+ "k8s.io/apimachinery/pkg/api/errors"
40
41
"k8s.io/apimachinery/pkg/util/wait"
41
42
)
42
43
@@ -267,23 +268,33 @@ func drainOrCordonIfNecessary(interruptionEventStore *interruptioneventstore.Sto
267
268
if nthConfig .CordonOnly || drainEvent .IsRebalanceRecommendation () {
268
269
err := node .Cordon (nodeName )
269
270
if err != nil {
270
- log .Log ().Err (err ).Msg ("There was a problem while trying to cordon the node" )
271
- os .Exit (1 )
272
- }
273
- log .Log ().Str ("node_name" , nodeName ).Msg ("Node successfully cordoned" )
274
- err = node .LogPods (nodeName )
275
- if err != nil {
276
- log .Log ().Err (err ).Msg ("There was a problem while trying to log all pod names on the node" )
271
+ if errors .IsNotFound (err ) {
272
+ log .Warn ().Err (err ).Msgf ("node '%s' not found in the cluster" , nodeName )
273
+ } else {
274
+ log .Log ().Err (err ).Msg ("There was a problem while trying to cordon the node" )
275
+ os .Exit (1 )
276
+ }
277
+ } else {
278
+ log .Log ().Str ("node_name" , nodeName ).Msg ("Node successfully cordoned" )
279
+ err = node .LogPods (nodeName )
280
+ if err != nil {
281
+ log .Log ().Err (err ).Msg ("There was a problem while trying to log all pod names on the node" )
282
+ }
283
+ metrics .NodeActionsInc ("cordon" , nodeName , err )
277
284
}
278
- metrics .NodeActionsInc ("cordon" , nodeName , err )
279
285
} else {
280
286
err := node .CordonAndDrain (nodeName )
281
287
if err != nil {
282
- log .Log ().Err (err ).Msg ("There was a problem while trying to cordon and drain the node" )
283
- os .Exit (1 )
288
+ if errors .IsNotFound (err ) {
289
+ log .Warn ().Err (err ).Msgf ("node '%s' not found in the cluster" , nodeName )
290
+ } else {
291
+ log .Log ().Err (err ).Msg ("There was a problem while trying to cordon and drain the node" )
292
+ os .Exit (1 )
293
+ }
294
+ } else {
295
+ log .Log ().Str ("node_name" , nodeName ).Msg ("Node successfully cordoned and drained" )
296
+ metrics .NodeActionsInc ("cordon-and-drain" , nodeName , err )
284
297
}
285
- log .Log ().Str ("node_name" , nodeName ).Msg ("Node successfully cordoned and drained" )
286
- metrics .NodeActionsInc ("cordon-and-drain" , nodeName , err )
287
298
}
288
299
289
300
interruptionEventStore .MarkAllAsDrained (nodeName )
0 commit comments