Skip to content

Commit 2eaab69

Browse files
committed
Handle dead pod but remaining container case on k8s
1 parent 1dcd528 commit 2eaab69

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

utils/service_discovery/sd_docker_backend.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ def _get_checks_to_refresh(self, state, c_id):
113113
Use the DATADOG_ID label or the image."""
114114
inspect = state.inspect_container(c_id)
115115

116-
# if the container was removed we can't tell which check is concerned
117-
# so we have to reload everything
118-
# TODO: with the cache it's not needed anymore
119-
# but the cache never purges dead containers, this should be improved
120-
if not inspect:
116+
# If the container was removed we can't tell which check is concerned
117+
# so we have to reload everything.
118+
# Same thing if it's stopped and we're on Kubernetes in auto_conf mode
119+
# because the pod was deleted and its template could have been in the annotations.
120+
if not inspect or \
121+
(not inspect.get('State', {}).get('Running')
122+
and Platform.is_k8s() and not self.agentConfig.get('sd_config_backend')):
121123
self.reload_check_configs = True
122124
return
123125

@@ -343,7 +345,6 @@ def _get_config_templates(self, identifier, **platform_kwargs):
343345
templates = []
344346
if config_backend is None:
345347
auto_conf = True
346-
log.warning('No supported configuration backend was provided, using auto-config only.')
347348
else:
348349
auto_conf = False
349350

0 commit comments

Comments
 (0)