@@ -308,13 +308,15 @@ func restartHNS(ctx context.Context) error {
308308 tryStopServiceFn (ctx , service ),
309309 retry .UntilSucceeded (),
310310 retry .Context (ctx ),
311+ retry .DelayType (retry .BackOffDelay ),
311312 )
312313 // Start the service again
313314 log .Printf ("Starting HNS service" )
314315 _ = retry .Do (
315316 tryStartServiceFn (ctx , service ),
316317 retry .UntilSucceeded (),
317318 retry .Context (ctx ),
319+ retry .DelayType (retry .BackOffDelay ),
318320 )
319321 log .Printf ("HNS service started" )
320322 return nil
@@ -342,6 +344,8 @@ func tryStartServiceFn(ctx context.Context, service managedService) func() error
342344 }
343345 }
344346 // Wait for the service to start
347+ deadline , cancel := context .WithTimeout (ctx , 90 * time .Second )
348+ defer cancel ()
345349 ticker := time .NewTicker (500 * time .Millisecond ) //nolint:gomnd // 500ms
346350 defer ticker .Stop ()
347351 for {
@@ -354,8 +358,8 @@ func tryStartServiceFn(ctx context.Context, service managedService) func() error
354358 break
355359 }
356360 select {
357- case <- ctx .Done ():
358- return errors . Wrap ( ctx . Err (), "context cancelled" )
361+ case <- deadline .Done ():
362+ return deadline . Err () //nolint:wrapcheck // error has sufficient context
359363 case <- ticker .C :
360364 }
361365 }
@@ -379,6 +383,8 @@ func tryStopServiceFn(ctx context.Context, service managedService) func() error
379383 }
380384 }
381385 // Wait for the service to stop
386+ deadline , cancel := context .WithTimeout (ctx , 90 * time .Second )
387+ defer cancel ()
382388 ticker := time .NewTicker (500 * time .Millisecond ) //nolint:gomnd // 500ms
383389 defer ticker .Stop ()
384390 for {
@@ -391,8 +397,8 @@ func tryStopServiceFn(ctx context.Context, service managedService) func() error
391397 break
392398 }
393399 select {
394- case <- ctx .Done ():
395- return errors . Wrap ( ctx . Err (), "context cancelled" )
400+ case <- deadline .Done ():
401+ return deadline . Err () //nolint:wrapcheck // error has sufficient context
396402 case <- ticker .C :
397403 }
398404 }
0 commit comments