Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions yarn/changelog.d/22676.changed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Catch the backend-agnostic HTTP error types when querying the YARN ResourceManager API so the check stays correct after the httpx migration.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a fixed changelog entry for this bug fix

This entry describes restoring correct behavior after the httpx migration, but .changed entries are reserved for breaking/significant changes and bump the integration's major version per the repo instructions. Shipping this as changed can publish an unnecessary major YARN release; please use a .fixed entry for this patch-level compatibility fix.

Useful? React with 👍 / 👎.

20 changes: 18 additions & 2 deletions yarn/datadog_checks/yarn/yarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

from datadog_checks.base import AgentCheck, is_affirmative
from datadog_checks.base.errors import ConfigurationError
from datadog_checks.base.utils.http_exceptions import (
HTTPConnectionError,
HTTPInvalidURLError,
HTTPSSLError,
HTTPStatusError,
HTTPTimeoutError,
)

# Default settings
DEFAULT_RM_URI = 'http://localhost:8088'
Expand Down Expand Up @@ -472,7 +479,7 @@ def _rest_request_to_json(self, url, object_path, tags, *args, **kwargs):
response.raise_for_status()
response_json = response.json()

except Timeout as e:
except (Timeout, HTTPTimeoutError) as e:
self.service_check(
SERVICE_CHECK_NAME,
AgentCheck.CRITICAL,
Expand All @@ -481,7 +488,16 @@ def _rest_request_to_json(self, url, object_path, tags, *args, **kwargs):
)
raise

except (HTTPError, InvalidURL, ConnectionError, SSLError) as e:
except (
HTTPError,
InvalidURL,
ConnectionError,
SSLError,
HTTPStatusError,
HTTPInvalidURLError,
HTTPConnectionError,
HTTPSSLError,
Comment on lines +496 to +499

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Catch HTTPRequestError for httpx request failures

When the check runs with the httpx2 backend and httpx raises a protocol/generic request failure, the wrapper maps it to datadog_checks.base.utils.http_exceptions.HTTPRequestError (for example LocalProtocolError in the base httpx2 tests). This tuple only adds the narrower status/invalid-url/connection/SSL classes, while the HTTPError name here is still requests.exceptions.HTTPError, so those backend-agnostic request errors bypass the yarn.can_connect CRITICAL service check and escape without the expected failure reporting.

Useful? React with 👍 / 👎.

) as e:
self.service_check(
SERVICE_CHECK_NAME,
AgentCheck.CRITICAL,
Expand Down
6 changes: 3 additions & 3 deletions yarn/tests/test_yarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ def test_auth(aggregator, mocked_auth_request):


def test_ssl_verification(aggregator, mock_http):
from requests.exceptions import SSLError
from datadog_checks.base.utils.http_exceptions import HTTPSSLError

from .conftest import requests_get_mock

mock_http.get.side_effect = SSLError("certificate verification failed")
mock_http.get.side_effect = HTTPSSLError("certificate verification failed")
instance = YARN_SSL_VERIFY_TRUE_CONFIG['instances'][0]

# Instantiate YarnCheck
Expand All @@ -280,7 +280,7 @@ def test_ssl_verification(aggregator, mock_http):
# Run the check on a config with a badly configured SSL certificate
try:
yarn.check(instance)
except SSLError:
except HTTPSSLError:
aggregator.assert_service_check(
SERVICE_CHECK_NAME,
status=YarnCheck.CRITICAL,
Expand Down
Loading