@@ -125,7 +125,7 @@ func main() {
125125 wait .PollImmediateUntil (2 * time .Second , func () (done bool , err error ) {
126126 err = handleRebootUncordon (nthConfig .NodeName , interruptionEventStore , * node )
127127 if err != nil {
128- log .Log (). Err (err ).Msgf ("Unable to complete the uncordon after reboot workflow on startup, retrying" )
128+ log .Err (err ).Msgf ("Unable to complete the uncordon after reboot workflow on startup, retrying" )
129129 }
130130 return false , nil
131131 }, stopCh )
@@ -152,7 +152,7 @@ func main() {
152152 if nthConfig .EnableSQSTerminationDraining {
153153 creds , err := nthConfig .AWSSession .Config .Credentials .Get ()
154154 if err != nil {
155- log .Warn (). Err (err ).Msg ("Unable to get AWS credentials" )
155+ log .Err (err ).Msg ("Unable to get AWS credentials" )
156156 }
157157 log .Debug ().Msgf ("AWS Credentials retrieved from provider: %s" , creds .ProviderName )
158158
@@ -171,13 +171,13 @@ func main() {
171171
172172 for _ , fn := range monitoringFns {
173173 go func (monitor monitor.Monitor ) {
174- log .Log ().Str ("event_type" , monitor .Kind ()).Msg ("Started monitoring for events" )
174+ log .Info ().Str ("event_type" , monitor .Kind ()).Msg ("Started monitoring for events" )
175175 var previousErr error
176176 var duplicateErrCount int
177177 for range time .Tick (time .Second * 2 ) {
178178 err := monitor .Monitor ()
179179 if err != nil {
180- log .Log ().Str ("event_type" , monitor .Kind ()).Err (err ).Msg ("There was a problem monitoring for events" )
180+ log .Warn ().Str ("event_type" , monitor .Kind ()).Err (err ).Msg ("There was a problem monitoring for events" )
181181 metrics .ErrorEventsInc (monitor .Kind ())
182182 if previousErr != nil && err .Error () == previousErr .Error () {
183183 duplicateErrCount ++
@@ -186,7 +186,7 @@ func main() {
186186 previousErr = err
187187 }
188188 if duplicateErrCount >= duplicateErrThreshold {
189- log .Log ().Msg ("Stopping NTH - Duplicate Error Threshold hit." )
189+ log .Warn ().Msg ("Stopping NTH - Duplicate Error Threshold hit." )
190190 panic (fmt .Sprintf ("%v" , err ))
191191 }
192192 }
@@ -195,11 +195,11 @@ func main() {
195195 }
196196
197197 go watchForInterruptionEvents (interruptionChan , interruptionEventStore )
198- log .Log ().Msg ("Started watching for interruption events" )
199- log .Log ().Msg ("Kubernetes AWS Node Termination Handler has started successfully!" )
198+ log .Info ().Msg ("Started watching for interruption events" )
199+ log .Info ().Msg ("Kubernetes AWS Node Termination Handler has started successfully!" )
200200
201201 go watchForCancellationEvents (cancelChan , interruptionEventStore , node , metrics )
202- log .Log ().Msg ("Started watching for event cancellations" )
202+ log .Info ().Msg ("Started watching for event cancellations" )
203203
204204 var wg sync.WaitGroup
205205
@@ -222,7 +222,7 @@ func main() {
222222 }
223223 }
224224 }
225- log .Log ().Msg ("AWS Node Termination Handler is shutting down" )
225+ log .Info ().Msg ("AWS Node Termination Handler is shutting down" )
226226 wg .Wait ()
227227 log .Debug ().Msg ("all event processors finished" )
228228}
@@ -260,17 +260,17 @@ func watchForCancellationEvents(cancelChan <-chan monitor.InterruptionEvent, int
260260 nodeName := interruptionEvent .NodeName
261261 interruptionEventStore .CancelInterruptionEvent (interruptionEvent .EventID )
262262 if interruptionEventStore .ShouldUncordonNode (nodeName ) {
263- log .Log ().Msg ("Uncordoning the node due to a cancellation event" )
263+ log .Info ().Msg ("Uncordoning the node due to a cancellation event" )
264264 err := node .Uncordon (nodeName )
265265 if err != nil {
266- log .Log (). Err (err ).Msg ("Uncordoning the node failed" )
266+ log .Err (err ).Msg ("Uncordoning the node failed" )
267267 }
268268 metrics .NodeActionsInc ("uncordon" , nodeName , err )
269269
270270 node .RemoveNTHLabels (nodeName )
271271 node .RemoveNTHTaints (nodeName )
272272 } else {
273- log .Log ().Msg ("Another interruption event is active, not uncordoning the node" )
273+ log .Info ().Msg ("Another interruption event is active, not uncordoning the node" )
274274 }
275275 }
276276}
@@ -280,13 +280,13 @@ func drainOrCordonIfNecessary(interruptionEventStore *interruptioneventstore.Sto
280280 nodeName := drainEvent .NodeName
281281 nodeLabels , err := node .GetNodeLabels (nodeName )
282282 if err != nil {
283- log .Warn (). Err (err ).Msgf ("Unable to fetch node labels for node '%s' " , nodeName )
283+ log .Err (err ).Msgf ("Unable to fetch node labels for node '%s' " , nodeName )
284284 }
285285 drainEvent .NodeLabels = nodeLabels
286286 if drainEvent .PreDrainTask != nil {
287287 err := drainEvent .PreDrainTask (* drainEvent , node )
288288 if err != nil {
289- log .Log (). Err (err ).Msg ("There was a problem executing the pre-drain task" )
289+ log .Err (err ).Msg ("There was a problem executing the pre-drain task" )
290290 }
291291 metrics .NodeActionsInc ("pre-drain" , nodeName , err )
292292 }
@@ -295,35 +295,35 @@ func drainOrCordonIfNecessary(interruptionEventStore *interruptioneventstore.Sto
295295 err := node .Cordon (nodeName )
296296 if err != nil {
297297 if errors .IsNotFound (err ) {
298- log .Warn (). Err (err ).Msgf ("node '%s' not found in the cluster" , nodeName )
298+ log .Err (err ).Msgf ("node '%s' not found in the cluster" , nodeName )
299299 } else {
300- log .Log (). Err (err ).Msg ("There was a problem while trying to cordon the node" )
300+ log .Err (err ).Msg ("There was a problem while trying to cordon the node" )
301301 os .Exit (1 )
302302 }
303303 } else {
304- log .Log ().Str ("node_name" , nodeName ).Msg ("Node successfully cordoned" )
304+ log .Info ().Str ("node_name" , nodeName ).Msg ("Node successfully cordoned" )
305305 podNameList , err := node .FetchPodNameList (nodeName )
306306 if err != nil {
307- log .Log (). Err (err ).Msgf ("Unable to fetch running pods for node '%s' " , nodeName )
307+ log .Err (err ).Msgf ("Unable to fetch running pods for node '%s' " , nodeName )
308308 }
309309 drainEvent .Pods = podNameList
310310 err = node .LogPods (podNameList , nodeName )
311311 if err != nil {
312- log .Log (). Err (err ).Msg ("There was a problem while trying to log all pod names on the node" )
312+ log .Err (err ).Msg ("There was a problem while trying to log all pod names on the node" )
313313 }
314314 metrics .NodeActionsInc ("cordon" , nodeName , err )
315315 }
316316 } else {
317317 err := node .CordonAndDrain (nodeName )
318318 if err != nil {
319319 if errors .IsNotFound (err ) {
320- log .Warn (). Err (err ).Msgf ("node '%s' not found in the cluster" , nodeName )
320+ log .Err (err ).Msgf ("node '%s' not found in the cluster" , nodeName )
321321 } else {
322- log .Log (). Err (err ).Msg ("There was a problem while trying to cordon and drain the node" )
322+ log .Err (err ).Msg ("There was a problem while trying to cordon and drain the node" )
323323 os .Exit (1 )
324324 }
325325 } else {
326- log .Log ().Str ("node_name" , nodeName ).Msg ("Node successfully cordoned and drained" )
326+ log .Info ().Str ("node_name" , nodeName ).Msg ("Node successfully cordoned and drained" )
327327 metrics .NodeActionsInc ("cordon-and-drain" , nodeName , err )
328328 }
329329 }
0 commit comments