Skip to content

Serialize Swarm UpdateConfig.MaxFailureRatio as a YAML number - #21512

Merged
Mitch Denny (mitchdenny) merged 1 commit into
mainfrom
davidfowl/fix-swarm-max-failure-ratio
Nov 3, 2026
Merged

Mitch Denny (mitchdenny) merged 1 commit into
mainfrom
davidfowl/fix-swarm-max-failure-ratio

Conversation

@davidfowl

Copy link
Copy Markdown
Collaborator

Description

Aspire.Hosting.Docker.Resources.ServiceNodes.Swarm.UpdateConfig.MaxFailureRatio was typed as string?. The Compose serializer (ForceQuotedStringsEventEmitter) double-quotes every string scalar, so the published file contained max_failure_ratio: "0.3". Docker Swarm requires a number and rejects the file. The existing snapshot test DockerSwarmUpdateConfigSerializedCorrectly had locked in the quoted (invalid) output.

Fix: change MaxFailureRatio to double? so it's emitted as a plain YAML number. This follows the sibling Parallelism string?→int? fix in #15566 and the type suggested in the issue. The test and snapshot now use 0.3 and expect max_failure_ratio: 0.3.

Compatibility note: this is a source/binary-breaking type change on a public property. The previous type could only ever produce Swarm-invalid output, so it's justified, as #15566 was. Local dotnet pack package validation passes (the 13.6.2 baseline only ships net8.0, which is ignored). No api/*.cs edits, per repo guidance. The property isn't part of the ATS/polyglot export.

Reproduction and evidence (local, Docker 29.1.3)

Check Before (main 13b2068) After
docker stack config -c docker-compose.yaml on the publisher output from DockerSwarmUpdateConfigSerializedCorrectly ❌ services.my-service.deploy.update_config.max_failure_ratio must be a number ✅ exit 0
docker stack deploy to a single-node swarm (E2E) ❌ same validation error, nothing deployed ✅ service created; docker service inspect → "MaxFailureRatio":0.3
DockerSwarmUpdateConfigSerializedCorrectly with the new snapshot ❌ fails: received max_failure_ratio: "0.3", expected 0.3 ✅ passes
Aspire.Hosting.Docker.Tests (full project) n/a ✅ 143 passed, 1 skipped, 0 failed

For the deploy step only, the network driver was swapped from bridge to overlay, because Swarm services can't attach to bridge networks; that's unrelated to this fix. update_config was left untouched. Inspected spec after deploy:

{"Parallelism":2,"Delay":10000000000,"FailureAction":"rollback","Monitor":5000000000,"MaxFailureRatio":0.3,"Order":"start-first"}

Fixes #19000

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No (changes the type of an existing property; see compatibility note)
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

MaxFailureRatio was typed as string?, so the Docker Compose publisher
emitted a double-quoted scalar (max_failure_ratio: "0.3") that Docker
Swarm rejects with 'max_failure_ratio must be a number'. Change it to
double?, matching the earlier Parallelism fix (#15566).

Fixes #19000

Co-authored-by: Copilot <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21512

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21512"

@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

5 / 100 PR test projects · 3 PR jobs, from 3 changed files.

Selected PR test projects (5 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests

Selected PR jobs (3)

extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

🔧 src/Aspire.Hosting.Docker/Resources/ServiceNodes/Swarm/UpdateConfig.cs (changed source)
→ 1 directly: Aspire.Hosting.Docker.Tests
→ 3 via the project graph: Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests (2 hops)

📦 affected project Aspire.Hosting.Docker
→ 1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Docker.Tests

🧪 tests/Aspire.Hosting.Docker.Tests/Snapshots/DockerComposeTests.DockerSwarmUpdateConfigSerializedCorrectly.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.Docker.Tests

Job reasons

Job Triggered by
extension-e2e • src/Aspire.Hosting.Docker/Resources/ServiceNodes/Swarm/UpdateConfig.cs
• affected project Aspire.Hosting.Docker
polyglot affected project Aspire.Hosting.Docker
typescript-api-compat affected project Aspire.Hosting.Docker

Selection computed for commit 916f4d9.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the change to serialize Docker Swarm’s maximum failure ratio as a YAML number.

No open issues 🎉

What changed in this PR

Fixes #19000 by making Docker Swarm’s UpdateConfig.MaxFailureRatio serialize as a YAML number rather than a quoted string that Docker rejects.

Changes:

  • Changes MaxFailureRatio from string? to double? and clarifies its documentation. This intentionally breaks source and binary compatibility.
  • Updates the existing serialization test and snapshot to use and expect numeric 0.3.
File Description
tests/​Aspire.Hosting.Docker.Tests/​Snapshots/​DockerComposeTests.DockerSwarmUpdateConfigSerializedCorrectly.verified.yaml Expects an unquoted numeric failure ratio.
tests/​Aspire.Hosting.Docker.Tests/​DockerComposeTests.cs Assigns a numeric value in the serialization test.
src/​Aspire.Hosting.Docker/​Resources/​ServiceNodes/​Swarm/​UpdateConfig.cs Changes the property to double? and documents the numeric requirement.

Review effort: Balanced

Copy link
Copy Markdown
Collaborator Author

CI note for head 916f4d9: attempt 1 of run 41155112085 had 3 failures, all in VS Code extension E2E and unrelated to this Docker Compose YAML change. I've rerun the failed jobs once.

  • VS Code extension E2E (Linux, tree-actions): Timed out after 180000ms waiting for resource 'e2e-terminal' state Running.
  • VS Code extension E2E (Windows, resource-debug-tools-negative): Timed out after 10000ms waiting for E2E control revision …
  • VS Code extension E2E (Windows, winui-debug): runner lost ("The hosted runner lost communication with the server").

🤖 Posted by AspireAgent (AI Agent)

@davidfowl

Copy link
Copy Markdown
Collaborator Author

Are there any other yaml values like this in either docker or k8s?

Copy link
Copy Markdown
Collaborator Author

Are there any other yaml values like this in either docker or k8s?

I checked both, and I don't see any others. Details:

Docker Compose / Swarm (src/Aspire.Hosting.Docker/Resources): I went through every string? property with a [YamlMember]. The only spec-numeric field typed as a string was UpdateConfig.MaxFailureRatio. Other numeric fields are already numeric: Parallelism, Replicas, RestartPolicy.MaxAttempts, secret Mode (int?) and config Mode (UnixFileMode? with a converter). The remaining string-typed values that look numeric are allowed as strings by the spec. I confirmed this by running the quoted forms through docker compose config -q and docker stack config (Docker 29.1.3); both exit 0:

shm_size: "64m"
stop_grace_period: "10s"
deploy.resources.limits/reservations: cpus: "0.5", memory: "512M"
deploy.restart_policy: delay: "5s", window: "30s"
secrets[]/configs[]: uid: "1000", gid: "1000"

Kubernetes (src/Aspire.Hosting.Kubernetes/Resources): the string-typed properties are all string or quantity types in the Kubernetes API, such as sizeLimit, averageValue, divisor, metadata.uid, env/sysctl/header value and Gateway TLS mode. Numeric fields are typed numerically: replicas, defaultMode/mode (int?), and port/targetPort/containerPort (Int32OrStringV1). IntOrStringConverter emits the numeric case as a plain scalar, and the existing snapshots show containerPort: 18888 and targetPort: 18888 unquoted.

So this PR stays scoped to MaxFailureRatio.

🤖 Posted by AspireAgent (AI Agent)

@mitchdenny
Mitch Denny (mitchdenny) merged commit ea08148 into main Nov 3, 2026
423 of 428 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 3, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

docs_optional → bug_fix_restores_documented_behavior. No signals triggered. The PR changes UpdateConfig.MaxFailureRatio from string? to double? so Swarm compose output emits a valid number. The aspire.dev docs tree has no mention of MaxFailureRatio or max_failure_ratio, so there is no documented content to update.

Eric Erhardt (eerhardt) added a commit to microsoft/aspire.dev that referenced this pull request Nov 12, 2026
## Summary

<!-- Describe what this pull request changes and why. -->

Document the three Aspire 17.0 breaking changes for Docker Swarm
`MaxFailureRatio`, the Azure Cosmos DB `configureClientOptions`
callback, and `ResourceUrlAnnotation.DisplayOrder`. Update the Cosmos DB
client options example and the custom resource URL example to reflect
the new APIs.

## Third-party links and affiliations

<!--
List any third-party links added or changed by this pull request and
disclose any
material affiliation with the linked organizations, such as employment,
sponsorship, or ownership. Write "None" if this pull request doesn't add
or
change third-party links.
-->

Added cross-repository references to
[microsoft/aspire#21512](microsoft/aspire#21512),
[microsoft/aspire#19349](microsoft/aspire#19349),
and
[microsoft/aspire#20637](microsoft/aspire#20637).
Material affiliation was not provided.

## Validation

<!-- List the checks you ran or explain why validation isn't needed. -->

- `git diff --check` — passed.
- `bun run dev -- --host 127.0.0.1` from `src/frontend` — rendered the
What's new, Cosmos DB connection, and custom resource URL pages. The
local `/api/live/` endpoint returned 404, so live updates were disabled
in the preview.

---------

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Aspire.Hosting.Docker] UpdateConfig.MaxFailureRatio serializes as a quoted string and produces invalid Compose YAML

3 participants