Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require container to be down in dcc.Down #26

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

sin3point14
Copy link
Contributor

The check can be racy, let the caller do whatever checks it wants to do. daemon.go already has a check where it decides if dcc.Down is needed or not. Now we also add a check to RestartServiceWithHaltHeight before it calls Down, with an appropriate error message.

Closes #25

Not sure how I can add tests for this :(, suggestions welcome!

The check can be racy, let the caller do whatever checks it wants to do.
daemon.go already has a check when it decides if dcc.Down is needed or not
Now we also add a check to RestartServiceWithHaltHeight before it calls Down,
with an appropriate error message.
@sin3point14
Copy link
Contributor Author

sin3point14 commented Dec 11, 2024

This is one way to do this, another way is to let the check be there dcc.Down and treat ErrContainerNotRunning as a warning in wherever it is called. However then that check too is racy, container can be running at

isImageContainerRunning, err := dcc.IsServiceRunning(ctx, serviceName, timeout)
but exits by the time execution reaches
err = cmd.ExecuteWithDeadlineAndLog(ctx, deadline, []string{}, "docker", "compose", "-f", dcc.composeFile, "down", "--remove-orphans", "-t", strconv.Itoa(timeoutSeconds))
.

I just went with this way as it felt like the natural solution, but if the other method is better, I can surely change to that.

Copy link
Contributor

@mkaczanowski mkaczanowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mkaczanowski mkaczanowski merged commit bd8128b into main Dec 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perform upgrade even if dcc.Down fails as no container is running
2 participants