#53048·Docker

Flaky test: docker-py SwarmTest::test_init_swarm_with_ca_config (swarm left encrypted/locked between tests)

Author: GordonTheTurtleCreated Jul 10, 2026Updated Sep 17, 2026
Labelsflaky

Description

The docker-py integration test SwarmTest::test_init_swarm_with_ca_config fails intermittently when the swarm daemon is left in an encrypted/locked state by a preceding test, causing the subsequent POST /swarm/init call to return HTTP 503.

First observed

2026-07-09, run 29032400304 (bump_bolt branch, test (amd64, graphdriver) / docker-py job).

Failure output

___________________ SwarmTest.test_init_swarm_with_ca_config ___________________

    raise HTTPError(http_error_msg, response=self)
E   requests.exceptions.HTTPError: 503 Server Error: Service Unavailable
    for url: http+docker://localhost/v1.55/swarm/init
E   docker.errors.APIError: 503 Server Error for http+docker://localhost/v1.55/swarm/init:
    Service Unavailable ("Swarm is encrypted and needs to be unlocked
    before it can be used. Please use \"docker swarm unlock\" to unlock it.")
    tests/integration/api_swarm_test.py:91: in test_init_swarm_with_ca_config

Root cause

A prior test in the docker-py suite (likely one of the swarm lock/unlock tests) leaves the daemon's swarm in an encrypted, locked state. When test_init_swarm_with_ca_config runs next and calls swarm/init, the daemon refuses with 503 because it first needs to be unlocked.

This is a test isolation / teardown problem — the test suite does not reliably unlock or leave the swarm in a clean state before the next test runs.

Related

  • #34051 — TestSwarmLockUnlockCluster (Go integration-cli) shares the same root family: swarm lock state leaking between tests
  • #37306 — flaky tests epic

Reproduction

Run the full docker-py integration suite (make test-docker-py) multiple times; the failure is environment- and ordering-sensitive.

Flagged by automated CI flakiness scan.