Skip to content

Commit 9c474d4

Browse files
author
Peter Giacomo Lombardo
authored
If the host agent goes offline, timeout and reset. (#255)
1 parent 1f2a650 commit 9c474d4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

instana/agent/host.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
"""
55
from __future__ import absolute_import
66

7-
import json
87
import os
8+
import json
9+
import urllib3
10+
import requests
911
from datetime import datetime
1012

1113
from ..log import logger
@@ -230,6 +232,10 @@ def report_data_payload(self, payload):
230232
# The host agent returned something indicating that is has a request for us that we
231233
# need to process.
232234
self.handle_agent_tasks(json.loads(response.content)[0])
235+
except requests.exceptions.ConnectionError:
236+
pass
237+
except urllib3.exceptions.MaxRetryError:
238+
pass
233239
except Exception as exc:
234240
logger.debug("report_data_payload: Instana host agent connection error (%s)", type(exc), exc_info=True)
235241
return response

instana/collector/host.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def prepare_and_report_data(self):
4242
self.agent.machine.fsm.ready()
4343
else:
4444
return
45+
46+
if self.agent.machine.fsm.current == "good2go" and self.agent.is_timed_out():
47+
logger.info("The Instana host agent has gone offline or is no longer reachable for > 1 min. Will retry periodically.")
48+
self.agent.reset()
4549
except Exception:
4650
logger.debug('Harmless state machine thread disagreement. Will self-correct on next timer cycle.')
4751

0 commit comments

Comments
 (0)