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

Health store integration #1196

Merged
merged 62 commits into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
6f0b291
refactor monitor daemon
hglkrijger May 29, 2018
97aa665
initial commit for hostga health monitor
hglkrijger May 29, 2018
1920e3f
send telemetry when hostplugin heartbeat fails
hglkrijger May 29, 2018
33240bb
adjust monitor delta
hglkrijger May 29, 2018
0a73ce6
fix call
hglkrijger May 29, 2018
3f90f20
use correct endpoint
hglkrijger May 29, 2018
051e9f5
update version
hglkrijger May 29, 2018
427a04f
cleanup
hglkrijger May 29, 2018
3399ef9
add content type header
hglkrijger May 29, 2018
89e67f6
cleanup logging
hglkrijger May 29, 2018
c466c11
update observation name
hglkrijger May 29, 2018
f386a74
minor refactor
hglkrijger May 30, 2018
88c34ae
add signal for /versions
hglkrijger May 30, 2018
9a25a69
debugging
hglkrijger May 30, 2018
165f5c8
fix
hglkrijger May 30, 2018
90b1727
remove debugging
hglkrijger May 30, 2018
55ac6fe
verbose logs
hglkrijger May 30, 2018
28994c0
cleanup, add report for artifacts
hglkrijger May 30, 2018
21d76b1
minor cleanup
hglkrijger May 30, 2018
6eaa000
minor refactor and cleanup
hglkrijger May 30, 2018
1388bb5
switch to using fetch over download_ext_handler_pkg directly
hglkrijger May 31, 2018
2f2abfc
whitespace cleanup
hglkrijger May 31, 2018
d5b7874
switch default
hglkrijger May 31, 2018
1806eb4
exception formatting
hglkrijger May 31, 2018
21493bc
debugging
hglkrijger May 31, 2018
17157be
remove debugging
hglkrijger May 31, 2018
edb824a
remove 400 from resource gone codes
hglkrijger May 31, 2018
a0b53ec
rollup hostplugin fetch reporting
hglkrijger May 31, 2018
f3ee5cb
update exthandler prefix
hglkrijger May 31, 2018
38f53b2
report fetch from GuestAgent
hglkrijger May 31, 2018
60d6345
refactor, report status health
hglkrijger May 31, 2018
86e2ead
remove debugging
hglkrijger May 31, 2018
29aaaa6
update for tests
hglkrijger May 31, 2018
532c6b7
limit the observation field sizes
hglkrijger Jun 1, 2018
a1c5bed
change manifest message to verbose
hglkrijger Jun 1, 2018
653f2b4
remove enable events from the log
hglkrijger Jun 1, 2018
b32b9d0
test layout cleanup
hglkrijger Jun 1, 2018
f5f26ae
update existing host plugin tests to cover health service calls
hglkrijger Jun 1, 2018
0821103
do not log agent enable event
hglkrijger Jun 1, 2018
0370af7
fix failure conditions, status codes, add tests
hglkrijger Jun 1, 2018
7dd815d
merge master
hglkrijger Jun 1, 2018
0cee3f1
merge fix
hglkrijger Jun 1, 2018
aa19959
fix event import
hglkrijger Jun 1, 2018
a401c00
unit test updates
hglkrijger Jun 2, 2018
8e1e30a
unit test fix
hglkrijger Jun 2, 2018
3d952b4
cleanup the monitor thread; heartbeat tests
hglkrijger Jun 4, 2018
f9e16d0
update naming for PR feedback
hglkrijger Jun 4, 2018
493f347
fix import test
hglkrijger Jun 4, 2018
e76f578
mock events for monitor tests
hglkrijger Jun 4, 2018
98dcf0e
adjust handler model
hglkrijger Jun 4, 2018
a608772
monitor thread clean shutdown for unit tests
hglkrijger Jun 4, 2018
3dbaff7
switch to thread join
hglkrijger Jun 4, 2018
9d8640e
correct init sequence
hglkrijger Jun 4, 2018
58586a0
event thread None check
hglkrijger Jun 4, 2018
8a16a86
add healthservice tests
hglkrijger Jun 5, 2018
91a6c37
update health service tests
hglkrijger Jun 5, 2018
ccccd19
test observationsare cleared after failures
hglkrijger Jun 5, 2018
a5673be
test for status codes
hglkrijger Jun 5, 2018
3ee3f27
additional tests for reporting
hglkrijger Jun 5, 2018
14f022f
better json compare
hglkrijger Jun 5, 2018
1a465fa
PR feedback
hglkrijger Jun 5, 2018
47f18c5
additional bounds safety; new test
hglkrijger Jun 5, 2018
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
5 changes: 5 additions & 0 deletions azurelinuxagent/ga/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ def run(self):
self.init_protocols()
self.start()

def stop(self):
self.should_run = False
if self.is_alive():
self.event_thread.join()

def init_protocols(self):
self.protocol = self.protocol_util.get_protocol()
self.health_service = HealthService(self.protocol.endpoint)
Expand Down
11 changes: 6 additions & 5 deletions tests/ga/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ def test_heartbeats(self, patch_hostplugin_heartbeat, patch_send_events, patch_t
self.assertEqual(0, patch_hostplugin_heartbeat.call_count)
self.assertEqual(0, patch_send_events.call_count)
self.assertEqual(0, patch_telemetry_heartbeat.call_count)

monitor_handler.start()
time.sleep(1)
self.assertTrue(monitor_handler.is_alive())

self.assertNotEqual(0, patch_hostplugin_heartbeat.call_count)
self.assertNotEqual(0, patch_send_events.call_count)
self.assertNotEqual(0, patch_telemetry_heartbeat.call_count)

monitor_handler.should_run = False
monitor_handler.stop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change!


def test_heartbeat_timings_updates_after_window(self, *args):
monitor_handler = get_monitor_handler()
Expand Down Expand Up @@ -128,7 +130,7 @@ def test_heartbeat_timings_updates_after_window(self, *args):
self.assertNotEqual(events_collection, monitor_handler.last_event_collection)
self.assertNotEqual(heartbeat_telemetry, monitor_handler.last_telemetry_heartbeat)

monitor_handler.should_run = False
monitor_handler.stop()

def test_heartbeat_timings_no_updates_within_window(self, *args):
monitor_handler = get_monitor_handler()
Expand Down Expand Up @@ -159,7 +161,7 @@ def test_heartbeat_timings_no_updates_within_window(self, *args):
self.assertEqual(events_collection, monitor_handler.last_event_collection)
self.assertEqual(heartbeat_telemetry, monitor_handler.last_telemetry_heartbeat)

monitor_handler.should_run = False
monitor_handler.stop()

@patch("azurelinuxagent.common.protocol.healthservice.HealthService.report_host_plugin_heartbeat")
def test_heartbeat_creates_signal(self, patch_report_heartbeat, *args):
Expand All @@ -168,5 +170,4 @@ def test_heartbeat_creates_signal(self, patch_report_heartbeat, *args):
monitor_handler.last_host_plugin_heartbeat = datetime.datetime.utcnow() - timedelta(hours=1)
monitor_handler.send_host_plugin_heartbeat()
self.assertEqual(1, patch_report_heartbeat.call_count)
monitor_handler.should_run = False

monitor_handler.stop()