Fix docker_network.present recreating networks on Docker 29+ (#68518)#69366
Open
dwoz wants to merge 1 commit into
Open
Fix docker_network.present recreating networks on Docker 29+ (#68518)#69366dwoz wants to merge 1 commit into
dwoz wants to merge 1 commit into
Conversation
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
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 does this PR do?
Stops
docker_network.presentfrom 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.presentstate run reportedNetwork would be recreated with new configand produced a no-op IPAM diff. Docker 29 added an empty-stringIPRangefield to every IPAMConfigentry returned bydocker inspect; Salt'sdocker.compare_networksdid 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 offsorted(x) == ["Gateway", "Subnet"]and likewise stopped matching once Docker emitted the new field.New Behavior
docker.compare_networksstrips empty-string/None placeholder values from each IPAMConfigentry before sorting and comparing pools.docker_network.present::is_default_poolapplies the same normalisation. A real configuration change is still reported.Note
salt/states/docker_network.pyandsalt/modules/dockermod.pywere removed from upstream Salt starting in 3008.x and migrated to thesaltext-dockerextension. This PR targets the oldest still-supported branch carrying the bug (3006.x); merge-forward propagates the fix to3007.x. A separate PR will be needed againstsaltstack/saltext-dockerto cover 3008.x+/master.Merge requirements satisfied?
changelog/68518.fixed.md)test_compare_networks_ipam_config_empty_iprange)Commits signed with GPG?
Yes