Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions platform/os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,15 @@ func restartHNS(ctx context.Context) error {
tryStopServiceFn(ctx, service),
retry.UntilSucceeded(),
retry.Context(ctx),
retry.DelayType(retry.BackOffDelay),
)
// Start the service again
log.Printf("Starting HNS service")
_ = retry.Do(
tryStartServiceFn(ctx, service),
retry.UntilSucceeded(),
retry.Context(ctx),
retry.DelayType(retry.BackOffDelay),
)
log.Printf("HNS service started")
return nil
Expand Down Expand Up @@ -342,6 +344,8 @@ func tryStartServiceFn(ctx context.Context, service managedService) func() error
}
}
// Wait for the service to start
deadline, cancel := context.WithTimeout(ctx, 90*time.Second)
defer cancel()
ticker := time.NewTicker(500 * time.Millisecond) //nolint:gomnd // 500ms
defer ticker.Stop()
for {
Expand All @@ -354,8 +358,8 @@ func tryStartServiceFn(ctx context.Context, service managedService) func() error
break
}
select {
case <-ctx.Done():
return errors.Wrap(ctx.Err(), "context cancelled")
case <-deadline.Done():
return deadline.Err() //nolint:wrapcheck // error has sufficient context
case <-ticker.C:
}
}
Expand All @@ -379,6 +383,8 @@ func tryStopServiceFn(ctx context.Context, service managedService) func() error
}
}
// Wait for the service to stop
deadline, cancel := context.WithTimeout(ctx, 90*time.Second)
defer cancel()
ticker := time.NewTicker(500 * time.Millisecond) //nolint:gomnd // 500ms
defer ticker.Stop()
for {
Expand All @@ -391,8 +397,8 @@ func tryStopServiceFn(ctx context.Context, service managedService) func() error
break
}
select {
case <-ctx.Done():
return errors.Wrap(ctx.Err(), "context cancelled")
case <-deadline.Done():
return deadline.Err() //nolint:wrapcheck // error has sufficient context
case <-ticker.C:
}
}
Expand Down
Loading