fixup! refactor(container): restart handling

This commit is contained in:
Rob Watson 2025-04-13 05:20:47 +02:00
parent 888aadbdc0
commit 7242534a10

View File

@ -332,7 +332,7 @@ func (a *Client) runContainerLoop(
containerID string, containerID string,
imageName string, imageName string,
networkCountConfig NetworkCountConfig, networkCountConfig NetworkCountConfig,
shouldRestart ShouldRestartFunc, shouldRestartFunc ShouldRestartFunc,
stateC chan<- domain.Container, stateC chan<- domain.Container,
errC chan<- error, errC chan<- error,
) { ) {
@ -366,8 +366,8 @@ func (a *Client) runContainerLoop(
respC, errC := a.apiClient.ContainerWait(ctx, containerID, container.WaitConditionNextExit) respC, errC := a.apiClient.ContainerWait(ctx, containerID, container.WaitConditionNextExit)
select { select {
case resp := <-respC: case resp := <-respC:
if shouldRestart != nil { if shouldRestartFunc != nil {
shouldRestart, err := shouldRestart(resp.StatusCode, restartCount, time.Since(startedWaitingAt)) shouldRestart, err := shouldRestartFunc(resp.StatusCode, restartCount, time.Since(startedWaitingAt))
if shouldRestart && err != nil { if shouldRestart && err != nil {
panic(fmt.Errorf("shouldRestart must return nil error if restarting, but returned: %w", err)) panic(fmt.Errorf("shouldRestart must return nil error if restarting, but returned: %w", err))
} }