Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

nielstholenaar
Copy link
Contributor

What does this PR do?

This PR resolves an issue with the Elasticsearch integration, that prevented the integration from working when there are no values passed for tls_protocols_allowed or tls_ciphers.

Motivation

When not passing any values for the tls_protocols_allowed or tls_ciphers the following config is being generated:

--- /etc/datadog-agent/conf.d/elastic.d/conf.yaml
+++ /tmp/puppet-file20250314-2365624-ndvht2
@@ -8,3 +8,5 @@
       index_stats: true
       pshard_stats: false
       pending_task_stats: true
+      tls_protocols_allowed:
+      tls_ciphers:

This result in the error below:

2025-03-14 14:26:58 CET | CORE | ERROR | (pkg/collector/worker/check_logger.go:71 in Error) | check:elastic | Error running check: [{"message":"'NoneType' object is not iterable","traceback":"Traceback (most recent call last):\n  File \"/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/checks/base.py\", line 1301, in run\n    self.check(instance)\n  File \"/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/elastic/elastic.py\", line 141, in check\n    stats_data = self._get_data(stats_url)\n                 ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/elastic/elastic.py\", line 336, in _get_data\n    resp = self.http.get(url)\n           ^^^^^^^^^\n  File \"/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/checks/base.py\", line 400, in http\n    self._http = RequestsWrapper(self.instance or {}, self.init_config, self.HTTP_CONFIG_REMAPPER, self.log)\n                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/base/utils/http.py\", line 324, in __init__\n    for protocol in config['tls_protocols_allowed']:\n                    ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^\nTypeError: 'NoneType' object is not iterable\n"}]

Additional Notes

Describe your test plan

@nielstholenaar nielstholenaar requested review from a team as code owners March 14, 2025 14:12
@nielstholenaar
Copy link
Contributor Author

nielstholenaar commented Mar 27, 2025

@fanny-jiang would you mind checking this? The elasticsearch integration is currently broken.

Edit: i see the tests are failing, i will have a look.

@nielstholenaar nielstholenaar force-pushed the fix/elasticsearch-tls branch from 931eaba to 5fbb0bc Compare April 2, 2025 13:11
…assed via _instances

Fix: Added fallback for possible empty params
@nielstholenaar nielstholenaar force-pushed the fix/elasticsearch-tls branch from 5fbb0bc to 300195a Compare April 2, 2025 13:12
@nielstholenaar
Copy link
Contributor Author

nielstholenaar commented Apr 2, 2025

I fixed the issues from the test. I have also added some explicit checking for the tags param. Could you check the MR again?

@fanny-jiang fanny-jiang merged commit 5684083 into DataDog:main Apr 3, 2025
12 checks passed
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.

2 participants