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

Allow skip loading Python kubelet check based on DD_KUBELET_CORE_CHECK_ENABLED #16856

Merged
Prev Previous commit
Next Next commit
Add unit test to check init is skipped
  • Loading branch information
jennchenn committed Mar 4, 2024
commit 942f9bd7f2fd270054e742c96d1e497084380c58
8 changes: 8 additions & 0 deletions kubelet/tests/test_kubelet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
from six import iteritems

from datadog_checks.base.checks.kubelet_base.base import KubeletCredentials
from datadog_checks.base.errors import SkipInstanceError
from datadog_checks.base.utils.date import parse_rfc3339
from datadog_checks.base.errors import SkipInstanceError
from datadog_checks.dev.http import MockResponse
from datadog_checks.kubelet import KubeletCheck, PodListUtils

Expand Down Expand Up @@ -1561,3 +1563,9 @@ def test_kubelet_unavailable_check_can_init(monkeypatch):
with mock.patch('datadog_checks.kubelet.kubelet.get_connection_info', return_value=kubelet_conn_info):
check = mock_kubelet_check(monkeypatch, [instance], kube_version=None)
assert check is not None

def test_kubelet_does_not_init_if_config_var_set_to_true(monkeypatch):
monkeypatch.setenv("DD_KUBERNETES_KUBELET_CORE_CHECK_ENABLED", "true")
with pytest.raises(SkipInstanceError):
KubeletCheck('kubelet', {}, [{}])
return