Skip to content

Commit 08b99f8

Browse files
committed
refactor(healthcheck): simplify ForceRemoveTransientHealthCheckFiles
Signed-off-by: Hayato Kiwata <dev@haytok.jp>
1 parent adfb7d4 commit 08b99f8

1 file changed

Lines changed: 1 addition & 32 deletions

File tree

pkg/healthcheck/healthcheck_manager_linux.go

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -226,38 +226,7 @@ func ForceRemoveTransientHealthCheckFiles(ctx context.Context, containerID strin
226226

227227
// Stop service with timeout
228228
go func() {
229-
select {
230-
case <-timeoutCtx.Done():
231-
log.G(ctx).Warnf("timeout stopping service %s during force cleanup", service)
232-
return
233-
default:
234-
sChan := make(chan string, 1)
235-
if _, err := conn.StopUnitContext(timeoutCtx, service, "ignore-dependencies", sChan); err == nil {
236-
select {
237-
case msg := <-sChan:
238-
if msg != "done" {
239-
log.G(ctx).Warnf("service stop message during force cleanup: %s", msg)
240-
}
241-
case <-timeoutCtx.Done():
242-
log.G(ctx).Warnf("timeout waiting for service stop confirmation: %s", service)
243-
}
244-
} else {
245-
log.G(ctx).Warnf("failed to stop service %s during force cleanup: %v", service, err)
246-
}
247-
}
248-
}()
249-
250-
// Reset failed units (best effort, non-blocking)
251-
go func() {
252-
select {
253-
case <-timeoutCtx.Done():
254-
log.G(ctx).Warnf("timeout resetting failed unit %s during force cleanup", service)
255-
return
256-
default:
257-
if err := conn.ResetFailedUnitContext(timeoutCtx, service); err != nil {
258-
log.G(ctx).Warnf("failed to reset failed unit %s during force cleanup: %v", service, err)
259-
}
260-
}
229+
stopSystemdUnit(ctx, timeoutCtx, conn, service)
261230
}()
262231

263232
// Wait a short time for operations to complete, but don't block indefinitely

0 commit comments

Comments
 (0)