Skip to content

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

Merged
ndeloof merged 1 commit intodocker:mainfrom
ndeloof:cascade-fail
Apr 8, 2024
Merged

Introduce --abort-on-container-failure#11680
ndeloof merged 1 commit intodocker:mainfrom
ndeloof:cascade-fail

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, jhrotko and milas and removed request for a team April 3, 2024 07:57
@codecov
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

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

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