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

Introduce --abort-on-container-failure #11680

Merged
merged 1 commit into from Apr 8, 2024
Merged

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Apr 3, 2024

What I did

Introduce --abort-on-container-failure as a custom flavor for cascade stop, which only stops on container failure (exit != 0). This allows to run "tasks" defined by services (sorry for the conceptual mismatch) and complete successfully if all succeeded, but fail if any failed, and kill the others (aka "fail fast")

Related issue
closes #10225

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@ndeloof ndeloof requested review from a team, glours, milas and jhrotko and removed request for a team April 3, 2024 07:57
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 78.94737% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 54.48%. Comparing base (ff20b64) to head (3816eea).

Files Patch % Lines
cmd/compose/up.go 68.75% 3 Missing and 2 partials ⚠️
pkg/compose/printer.go 82.35% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11680      +/-   ##
==========================================
- Coverage   54.57%   54.48%   -0.10%     
==========================================
  Files         145      145              
  Lines       12605    12624      +19     
==========================================
- Hits         6879     6878       -1     
- Misses       5037     5053      +16     
- Partials      689      693       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

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

Some questions about the command flags compatibility before approving

@@ -131,6 +143,7 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service, ex
flags.BoolVar(&create.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
flags.BoolVar(&up.noStart, "no-start", false, "Don't start the services after creating them")
flags.BoolVar(&up.cascadeStop, "abort-on-container-exit", false, "Stops all containers if any container was stopped. Incompatible with -d")
flags.BoolVar(&up.cascadeFail, "abort-on-container-failure", false, "Stops all containers if any container exited with failure. Incompatible with -d")
Copy link
Contributor

Choose a reason for hiding this comment

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

Incompatible with -d or cascadeStop or both?
If not compatible with -d, I think you forgot to add the associated check in validateFlags function

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

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

LGTM

@ndeloof ndeloof merged commit 29692b5 into docker:main Apr 8, 2024
32 checks passed
@ndeloof ndeloof deleted the cascade-fail branch April 8, 2024 13:41
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.

Fail the docker-compose command if any one of the conatiner failed
2 participants