fix: reconcile_config_map_values unconditionally removes+reapplies every option - #932
Open
tod-uma wants to merge 1 commit into
Open
Conversation
…ery option `remove_config_map_stanza.yml` unconditionally issued `ini_file state=absent` for every option recorded in the previous `.<conf_file>.splunk-ansible-managed.yml` state file, then `set_config_stanza.yml` immediately re-added every currently-desired option with `ini_file state=present`. In steady state (group_vars unchanged between runs) this deletes and recreates the identical option on every single converge -- `ini_file` correctly reports `changed: true` for both the removal (the option existed) and the re-add (it was just removed), even though the net file content never moves. This is a distinct bug from the splunk_upgrade list/string comparison fixed in rc3 -- confirmed by re-testing rc3 against indexer06 twice: the splunkd restart pair is gone (changed 4 -> 2, deterministic across both runs), and the only remaining changed tasks are these two reconcile steps. Fix: only remove an option if it is no longer present in the current desired stanza (conf_stanzas, already in scope from set_config_file.yml's include vars) -- i.e. only prune options actually dropped from group_vars. An option that's still desired, even with a changed value, is left for set_config_stanza.yml's existing idempotent `ini_file state=present` to update in place, which already no-ops correctly when the value hasn't changed. Verified the new condition against three cases offline (steady state, one key dropped, whole stanza dropped) before touching a host.
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.
Summary
remove_config_map_stanza.ymlunconditionally issuedini_file state=absentfor every option recorded in the previous.<conf_file>.splunk-ansible-managed.ymlstate file, thenset_config_stanza.ymlimmediately re-added every currently-desired option withini_file state=present. In steady state (group_vars unchanged between runs) this deletes and recreates the identical option on every single converge —ini_filecorrectly reportschanged: truefor both the removal (the option existed) and the re-add (it was just removed), even though the net file content never moves.This is a distinct bug from #931 (the
splunk_upgradelist/string comparison) — confirmed independently by re-testing #931's fix alone against two hosts, twice each: the splunkd restart pair was gone and the runs were deterministic, but a steadychanged=2remained, always attributable to these same two reconcile tasks.Fix
Only remove an option if it is no longer present in the current desired stanza (
conf_stanzas, already in scope viaset_config_file.yml's include vars) — i.e. only prune options actually dropped from group_vars. An option that's still desired, even with a changed value, is left forset_config_stanza.yml's existing idempotentini_file state=presentto update in place, which already no-ops correctly when the value hasn't changed.Test plan
whencondition offline against three cases before touching a host: steady state (no removal), one key dropped from group_vars (only that key pruned), whole stanza dropped (all its keys pruned)ansible-lintclean of new issues (pre-existingrisky-file-permissionsfinding on this file predates this change, confirmed viagit stash)changed=0onuser-prefs.conf's ConfigMap-owned reconcile, down from 2 changed tasks every run