Repository navigation
Conversation
When both attributes are set they must not contradict each other: deploy.restart_policy.condition and max_attempts are compared to the service-level restart value after mapping them to the engine vocabulary, so 'restart: always' and 'condition: any' are accepted as the same policy while 'restart: unless-stopped' with 'condition: on-failure' is rejected instead of silently picking a winner. Attributes left unset on one side are complements and remain allowed. Refs docker/compose#14383 Signed-off-by: arxhr007 <aaron123thomas098@gmail.com>
5 tasks done
Author
|
Closing — #989 (filed within the same second, by @ndeloof) supersedes this: it carries the same contradiction check with identical error messages, plus the loader-side reconciliation that folds the merged outcome into docker/compose#14459 stays relevant in the meantime — as noted in #989's description, it does the field-by-field merge for current compose-go versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Adds a consistency check for
restartanddeploy.restart_policyinloader/validate.go, next to the existingscale/deploy.replicasandcpus/deploy.resources.limits.cpuschecks. When both attributes are set, they must not contradict each other — the values are compared after mapping to the engine vocabulary, sorestart: always+condition: anyis accepted as the same policy.Attributes left unset on one side are treated as complements, not conflicts:
restart: on-failure+max_attempts: 3is allowed (the deploy policy supplies whatrestartdid not set), and arestart_policywith onlydelay/windowstays valid — preserving the complementary cases that motivated the merge-field-by-field fix in docker/compose.Rejected examples:
restart: unless-stopped+condition: on-failure→can't set distinct values on 'restart' and 'deploy.restart_policy.condition'restart: on-failure:3+condition: any→ same error (the mergedalways+ retry count of 3 would also be rejected by the engine at container creation)restart: on-failure:3+condition: on-failure+max_attempts: 5→can't set distinct values on 'restart' and 'deploy.restart_policy.max_attempts'Related
Proposed by @ndeloof on docker/compose#14459 as the compose-go half of the fix for docker/compose#14383 — with the loader rejecting distinct values, the compose-side merge only has to deal with consistent or unset attributes.
Testing done
TestRestartConsistentWithDeployRestartPolicyinloader/tests/restart_test.go: 8 cases covering vocabulary equivalence (any/always,none/no), matching condition + attempts, complementary/unset attributes, and each distinct-value rejectiongo test ./loader/...— full loader suite passesgolangci-lint run— 0 issuesAI disclosure
This contribution was prepared by an AI agent (Devin, Cognition) acting on a human's behalf. The human submitter may not have independently reviewed or tested the change.