fix(elasticsearch): make cluster-settings robust to per-block check_mode - #183
Merged
Merged
Conversation
Follow-up to #182. Re-including the role with check_mode: true on an outer block (as elasticsearch_no-security did to cover the guards #154 added) crashed on line 30 of elasticsearch-cluster-settings.yml with: 'dict object' has no attribute 'json' Root cause: ansible_check_mode is the PLAY-level check-mode flag; setting check_mode: true on a block does not flip it, but the uri module still honours the inherited override and returns without an HTTP body. The block-level 'when: not ansible_check_mode' guard then lets execution through anyway, and the next task dereferences _elasticsearch_current_cluster_settings.json which is missing. Two guards: - check_mode: false on the GET so a per-block override still runs the request (this is a pure read, safe to always execute) - default({}) around .persistent so the compare survives any other reason the response is missing Also re-adds the check-mode play to elasticsearch_no-security so the #154 guards actually stay covered.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR updates Elasticsearch cluster-settings reads for check mode and missing response data. It also adds Molecule coverage for re-including the Elasticsearch role in check mode. ChangesElasticsearch check-mode handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Follow-up to #182. Re-including the ES role with
check_mode: trueon an outer block (which is whatelasticsearch_no-securitydid to cover the guards #154 added) crashed on line 30 ofelasticsearch-cluster-settings.yml:Root cause:
ansible_check_modeis the play-level check-mode flag; settingcheck_mode: trueon a block does not flip it, but theurimodule still honours the inherited override and returns without an HTTP body. The block-levelwhen: not ansible_check_modeguard then lets execution through anyway, and the next task dereferences_elasticsearch_current_cluster_settings.jsonwhich is not there.Two guards, belt and suspenders:
check_mode: falseon the GET so a per-block override still runs the request. It's a pure read against/_cluster/settings, safe to always execute.default({})around.persistentso the compare survives any other reason the response is missing.Also re-adds the check-mode play to
elasticsearch_no-security/converge.ymlso the twonot ansible_check_modeguards #154 added toStart ElasticsearchandHandle cluster setup without securityactually stay covered. That was the piece dropped from #182 because it kept tripping on this bug.Summary by CodeRabbit
Bug Fixes
Tests