Skip to content

Commit

Permalink
ignore empty cids without calling the tagger (#1830)
Browse files Browse the repository at this point in the history
  • Loading branch information
xvello committed Jul 2, 2018
1 parent eb4721f commit 291c735
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kubelet/datadog_checks/kubelet/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def is_excluded(self, cid, pod_uid=None):
:param pod_uid: pod UID for static pod detection
:return: bool
"""
if not cid:
return True

if cid in self.cache:
return self.cache[cid]

Expand Down
10 changes: 10 additions & 0 deletions kubelet/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ def test_container_filter(monkeypatch):
assert short_cid in filter.containers
is_excluded.assert_not_called()

# Test cid == None
is_excluded.reset_mock()
assert filter.is_excluded(None) is True
is_excluded.assert_not_called()

# Test cid == ""
is_excluded.reset_mock()
assert filter.is_excluded("") is True
is_excluded.assert_not_called()

# Test non-existing container
is_excluded.reset_mock()
assert filter.is_excluded("invalid") is True
Expand Down

0 comments on commit 291c735

Please sign in to comment.