@@ -308,13 +308,15 @@ func restartHNS(ctx context.Context) error {
308
308
tryStopServiceFn (ctx , service ),
309
309
retry .UntilSucceeded (),
310
310
retry .Context (ctx ),
311
+ retry .DelayType (retry .BackOffDelay ),
311
312
)
312
313
// Start the service again
313
314
log .Printf ("Starting HNS service" )
314
315
_ = retry .Do (
315
316
tryStartServiceFn (ctx , service ),
316
317
retry .UntilSucceeded (),
317
318
retry .Context (ctx ),
319
+ retry .DelayType (retry .BackOffDelay ),
318
320
)
319
321
log .Printf ("HNS service started" )
320
322
return nil
@@ -342,6 +344,8 @@ func tryStartServiceFn(ctx context.Context, service managedService) func() error
342
344
}
343
345
}
344
346
// Wait for the service to start
347
+ deadline , cancel := context .WithTimeout (ctx , 90 * time .Second )
348
+ defer cancel ()
345
349
ticker := time .NewTicker (500 * time .Millisecond ) //nolint:gomnd // 500ms
346
350
defer ticker .Stop ()
347
351
for {
@@ -354,8 +358,8 @@ func tryStartServiceFn(ctx context.Context, service managedService) func() error
354
358
break
355
359
}
356
360
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
359
363
case <- ticker .C :
360
364
}
361
365
}
@@ -379,6 +383,8 @@ func tryStopServiceFn(ctx context.Context, service managedService) func() error
379
383
}
380
384
}
381
385
// Wait for the service to stop
386
+ deadline , cancel := context .WithTimeout (ctx , 90 * time .Second )
387
+ defer cancel ()
382
388
ticker := time .NewTicker (500 * time .Millisecond ) //nolint:gomnd // 500ms
383
389
defer ticker .Stop ()
384
390
for {
@@ -391,8 +397,8 @@ func tryStopServiceFn(ctx context.Context, service managedService) func() error
391
397
break
392
398
}
393
399
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
396
402
case <- ticker .C :
397
403
}
398
404
}
0 commit comments