From 9e025987749c5e9c4c235158602af6e66c0a508a Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Fri, 9 Feb 2018 17:16:02 -0500 Subject: [PATCH] Bail out early if cluster state cannot be determined --- .circleci/config.yml | 2 +- elasticsearch_collectd.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 326a058..b63cb1e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: '2' jobs: build: docker: - - image: ubuntu:yakkety + - image: ubuntu:xenial working_directory: ~/code steps: - setup_remote_docker diff --git a/elasticsearch_collectd.py b/elasticsearch_collectd.py index 05f8b02..b223925 100755 --- a/elasticsearch_collectd.py +++ b/elasticsearch_collectd.py @@ -1019,6 +1019,10 @@ def detect_es_master(self): cluster_state = self.fetch_url(self.es_url_scheme + "://" + self.es_host + ":" + str(self.es_port) + "/_cluster/state/master_node") + if cluster_state is None: + self.es_current_master = False + return + if self.es_current_master is False \ and cluster_state['master_node'] == self.node_id: self.es_current_master = True