Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[datadog_monitor] Fix crash for jmx integrations with init_config attributes set #869

Merged
merged 2 commits into from Feb 17, 2023

Conversation

KSerrania
Copy link
Contributor

What does this PR do?

Fixes a crash when the init_config attribute for a jmx integration (such asignite, jboss_wildfly) is set.

Previously, the init_config attribute would be merged in-place (through the merge! method) with another hash: { 'is_jmx': true, 'collect_default_metrics': true }. This would cause a crash if init_config is defined in attributes, because chef attributes cannot be modified that way:

================================================================================
Error executing action `add` on resource 'datadog_monitor[jboss_wildfly]'
================================================================================

Chef::Exceptions::ImmutableAttributeModification
------------------------------------------------
Node attributes are read-only when you do not specify which precedence level to set. To set an attribute use code like `node.default["key"] = "value"'

Cookbook Trace: (most recent call first)
----------------------------------------
/tmp/kitchen/cache/cookbooks/datadog/resources/monitor.rb:67:in `block (2 levels) in class_from_file'
/tmp/kitchen/cache/cookbooks/datadog/resources/monitor.rb:43:in `block in class_from_file'

This PR fixes this by not merging the attributes in-place. It also adds a kitchen test which exhibits the previous faulty behavior.

@KSerrania KSerrania requested a review from a team as a code owner November 23, 2022 09:57
@KSerrania KSerrania merged commit 07a3c59 into main Feb 17, 2023
@KSerrania KSerrania deleted the kserrania/fix-init-config-jmx-integrations branch February 17, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants