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

[kubernets] Kubelet check failing shouldn't stop metrics collection #2038

Merged
merged 1 commit into from
Nov 3, 2015
Merged
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
15 changes: 9 additions & 6 deletions checks.d/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def _perform_kubelet_checks(self, url):

except Exception, e:
self.log.warning('kubelet check failed: %s' % str(e))
self.service_check(service_check_base, AgentCheck.CRITICAL, 'Kubelet check failed: %s' % str(e))
raise
self.service_check(service_check_base, AgentCheck.CRITICAL,
message='Kubelet check failed: %s' % str(e))

def _perform_master_checks(self, url):
try:
Expand All @@ -104,12 +104,15 @@ def _perform_master_checks(self, url):
nodename = nodeinfo['name']
service_check_name = "{0}.master.{1}.check".format(NAMESPACE, nodename)
cond = nodeinfo['status'][-1]['type']
minion_name = nodeinfo['metadata']['name']
tags = ["minion_name:{0}".format(minion_name)]
if cond != 'Ready':
self.service_check(service_check_name, AgentCheck.CRITICAL, cond)
self.service_check(service_check_name, AgentCheck.CRITICAL,
tags=tags, message=cond)
else:
self.service_check(service_check_name, AgentCheck.OK)
self.service_check(service_check_name, AgentCheck.OK, tags=tags)
except Exception, e:
self.service_check(service_check_name, AgentCheck.CRITICAL, cond)
self.service_check(service_check_name, AgentCheck.CRITICAL, message=str(e))
self.log.warning('master checks url=%s exception=%s' % (url, str(e)))
raise

Expand Down Expand Up @@ -138,7 +141,7 @@ def check(self, instance):
if instance.get('enable_master_checks', False):
master_port = instance.get('master_port', DEFAULT_MASTER_PORT)
master_host = instance.get('master_host', 'localhost')
master_url = '%s://%s:%d/nodes' % (method, host, master_port)
master_url = '%s://%s:%d/api/v1/nodes' % (method, host, master_port)
self._perform_master_checks(master_url)

# kubelet health checks
Expand Down
2 changes: 1 addition & 1 deletion checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def service_check(self, check_name, status, tags=None, timestamp=None,
:param hostname: (optional) str, host that generated the service
check. Defaults to the host_name of the agent
:param check_run_id: (optional) int, id used for logging and tracing
purposes. Don't need to be unique. If not
purposes. Doesn't need to be unique. If not
specified, one will be generated.
"""
if hostname is None:
Expand Down
4 changes: 0 additions & 4 deletions conf.d/kubernetes.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ instances:
#
use_histogram: True
#
# Getting the master checks
# master_host: localhost
# master_port: 8080
#
# Kubelet checks
# enable_kubelet_checks: true
# kubelet_port: 10255
Expand Down
3 changes: 1 addition & 2 deletions tests/checks/mock/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def test_fail(self):
}

# Can't use run_check_twice due to specific metrics
with self.assertRaises(Exception):
self.run_check(config, mocks=mocks, force_reload=True)
self.run_check(config, mocks=mocks, force_reload=True)
self.assertServiceCheck("kubernetes.kubelet.check", status=AgentCheck.CRITICAL)
self.coverage_report()

Expand Down