Skip to content

Fix docker_network.present recreating networks on Docker 29+ (#68518)#69366

Open
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68518
Open

Fix docker_network.present recreating networks on Docker 29+ (#68518)#69366
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68518

Conversation

@dwoz

@dwoz dwoz commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Stops docker_network.present from reporting a spurious change (and recreating the network) on every state run against Docker 29+.

What issues does this PR fix or reference?

Fixes #68518

Previous Behavior

After upgrading from Docker 28 to Docker 29, every docker_network.present state run reported Network would be recreated with new config and produced a no-op IPAM diff. Docker 29 added an empty-string IPRange field to every IPAM Config entry returned by docker inspect; Salt's docker.compare_networks did a strict dict-equality check, so the engine's {Subnet, IPRange:"", Gateway} never matched the Salt-built desired {Subnet, Gateway}. The state's default-pool short-circuit (is_default_pool) keyed off sorted(x) == ["Gateway", "Subnet"] and likewise stopped matching once Docker emitted the new field.

New Behavior

docker.compare_networks strips empty-string/None placeholder values from each IPAM Config entry before sorting and comparing pools. docker_network.present::is_default_pool applies the same normalisation. A real configuration change is still reported.

Note

salt/states/docker_network.py and salt/modules/dockermod.py were removed from upstream Salt starting in 3008.x and migrated to the saltext-docker extension. This PR targets the oldest still-supported branch carrying the bug (3006.x); merge-forward propagates the fix to 3007.x. A separate PR will be needed against saltstack/saltext-docker to cover 3008.x+/master.

Merge requirements satisfied?

  • Docs (no documented behavior change; existing comments updated inline)
  • Changelog (changelog/68518.fixed.md)
  • Tests written/updated (test_compare_networks_ipam_config_empty_iprange)

Commits signed with GPG?

Yes

Docker 29 added an empty-string ``IPRange`` field to every IPAM
``Config`` entry returned by ``docker inspect``. Salt's network
comparison was strict on dict keys, so the existing network (with the
new placeholder field) no longer matched the Salt-built desired config
(which omits the field) and ``docker_network.present`` would report
``Network would be recreated with new config`` on every state run.

Drop empty/None placeholder values from IPAM ``Config`` entries before
comparing them in ``docker.compare_networks``, and apply the same
normalisation to the default-pool short-circuit in
``docker_network.present`` so a network created without an explicit
IPAM configuration is still recognised as default.

Fixes saltstack#68518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant