diff --git a/internal/machine/cluster.go b/internal/machine/cluster.go index f6d6c4ce..b6a67224 100644 --- a/internal/machine/cluster.go +++ b/internal/machine/cluster.go @@ -218,6 +218,9 @@ func (cc *clusterController) Run(ctx context.Context) error { err = errGroup.Wait() // It's safe to stop the Corrosion service after the controllers depending on it and API server are stopped. + // Use a new context with a timeout as the current context is already canceled. + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() if corroErr := cc.corroService.Stop(ctx); corroErr != nil { err = errors.Join(err, fmt.Errorf("stop corrosion service: %w", corroErr)) } else { diff --git a/internal/machine/corroservice/systemd.go b/internal/machine/corroservice/systemd.go index 9231cf0c..5efe573d 100644 --- a/internal/machine/corroservice/systemd.go +++ b/internal/machine/corroservice/systemd.go @@ -27,7 +27,7 @@ func (s *SystemdService) Start(ctx context.Context) error { return s.startOrRestart(ctx, "start") } -func (s *SystemdService) Stop(ctx context.Context) error { +func (s *SystemdService) Stop(_ context.Context) error { if _, err := exec.Command("systemctl", "stop", s.Unit).Output(); err != nil { return fmt.Errorf("systemctl stop %s: %w", s.Unit, err) }