Repository navigation
Fix Swarm UpdateConfig property types - #15566
Conversation
- Change Parallelism from string? to int? (Docker spec requires integer) - Rename FailOnError to FailureAction and change from bool? to string? (Docker spec requires "continue", "rollback", or "pause") - Update XML documentation for both properties - Add snapshot test verifying correct YAML serialization Fixes #11691 Co-authored-by: Copilot <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15566Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15566" |
There was a problem hiding this comment.
Pull request overview
Fixes Docker Swarm deploy.update_config YAML serialization in Aspire’s Docker Compose publisher by correcting mismatched CLR property types so generated Compose files conform to the Docker Compose spec.
Changes:
- Change
UpdateConfig.Parallelismfromstring?toint?to serialize as a YAML integer. - Replace
FailOnError(bool?, mapped tofailure_action) withFailureAction(string?) to match Compose’s expected string enum. - Add a snapshot-based unit test verifying
update_configYAML output.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Aspire.Hosting.Docker/Resources/ServiceNodes/Swarm/UpdateConfig.cs | Corrects update_config property types/names to generate valid Swarm Compose YAML. |
| tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs | Adds a verification test covering UpdateConfig serialization. |
| tests/Aspire.Hosting.Docker.Tests/Snapshots/DockerComposeTests.DockerSwarmUpdateConfigSerializedCorrectly.verified.yaml | Adds the expected YAML snapshot including correctly-typed parallelism and failure_action. |
| /// <summary> | ||
| /// Indicates whether the update process should stop and fail upon encountering an error. | ||
| /// Gets or sets the action to take when an update fails. | ||
| /// Valid values are <c>"continue"</c>, <c>"rollback"</c>, and <c>"pause"</c>. | ||
| /// </summary> | ||
| [YamlMember(Alias = "failure_action")] | ||
| public bool? FailOnError { get; set; } | ||
| public string? FailureAction { get; set; } |
There was a problem hiding this comment.
Renaming FailOnError (bool?) to FailureAction (string?) is a breaking change for consumers. Since the old property also produced invalid Compose YAML, consider keeping an [Obsolete] FailOnError shim (with [YamlIgnore]) that maps true/false to valid failure_action values (e.g., pause vs continue) to provide a smoother migration path while still emitting valid YAML.
| @@ -30,10 +28,11 @@ public sealed class UpdateConfig | |||
| public string? Delay { get; set; } | |||
|
|
|||
| /// <summary> | |||
| /// Indicates whether the update process should stop and fail upon encountering an error. | |||
| /// Gets or sets the action to take when an update fails. | |||
| /// Valid values are <c>"continue"</c>, <c>"rollback"</c>, and <c>"pause"</c>. | |||
| /// </summary> | |||
| [YamlMember(Alias = "failure_action")] | |||
| public bool? FailOnError { get; set; } | |||
| public string? FailureAction { get; set; } | |||
There was a problem hiding this comment.
The checked-in API surface file src/Aspire.Hosting.Docker/api/Aspire.Hosting.Docker.cs still declares UpdateConfig.FailOnError as bool? and UpdateConfig.Parallelism as string?. With this change, the API surface should be updated to reflect FailureAction (string?) and Parallelism (int?), otherwise API-validation/approval tooling is likely to fail or the published API docs will be incorrect.
James Newton-King (JamesNK)
left a comment
There was a problem hiding this comment.
Looks good assuming that the breaking changing to UpdateConfig are ok.
|
🎬 CLI E2E Test Recordings — 49 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23522799103 |
|
Yeah its OK because it was completely broken before :) |
) - Change Parallelism from string? to int? (Docker spec requires integer) - Rename FailOnError to FailureAction and change from bool? to string? (Docker spec requires "continue", "rollback", or "pause") - Update XML documentation for both properties - Add snapshot test verifying correct YAML serialization Fixes microsoft#11691 Co-authored-by: Mitch Denny <[email protected]> Co-authored-by: Copilot <[email protected]>
| /// </summary> | ||
| [YamlMember(Alias = "parallelism")] | ||
| public string? Parallelism { get; set; } | ||
| public int? Parallelism { get; set; } |
There was a problem hiding this comment.
Just an FYI - this is technically a breaking change since this is public API.
Not a blocker - just wanted to call it out.
Documentation Check ✅No documentation PR is required for this change. Reason: This PR fixes incorrect property types in the
|
Description
Fix incorrect property types in the Docker Swarm
UpdateConfigclass that cause invalid Docker Compose YAML to be generated.Two bugs:
Parallelismwasstring?but Docker Compose spec requires an integer. This caused the value to be serialized as"2"(quoted string) instead of2(integer), which Docker rejects.FailOnErrorwasbool?mapped tofailure_action, but Docker Compose spec requires a string enum ("continue","rollback", or"pause"). Renamed toFailureActionto better reflect the YAML aliasfailure_actionand its semantics.Also added a snapshot unit test verifying correct YAML serialization of all
UpdateConfigproperties.Fixes #11691
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: