Keep invalid container states from dropping host heartbeats

This commit is contained in:
2026-10-05 16:15:15 -04:00
parent 87c5cf4b4b
commit ad63b3957d
6 changed files with 36 additions and 18 deletions
+4 -2
View File
@@ -583,7 +583,7 @@ class AgentTests(unittest.TestCase):
self.assertNotIn("instanceResourcesError", inventory)
def test_heartbeat_states_share_inspection_and_include_stopped_and_unhealthy_containers(self):
for status, running, health in (("exited", False, "healthy"), ("running", True, "unhealthy"), ("running", True, "healthy")):
for status, running, health in (("exited", False, "healthy"), ("running", True, "unhealthy"), ("running", True, "healthy"), ("restarting", True, "healthy"), ("paused", True, "healthy")):
info = self.resource_container()
info["State"].update({"Status": status, "Running": running, "Health": {"Status": health}})
observations = []
@@ -593,7 +593,9 @@ class AgentTests(unittest.TestCase):
self.assertEqual(observations[0]["instanceId"], INSTANCE)
self.assertEqual(observations[0]["generation"], 1)
self.assertEqual(observations[0]["state"], health if running and health != "healthy" else status)
self.assertEqual(observations[0]["healthy"], running and health == "healthy")
self.assertEqual(observations[0]["healthy"], status == "running" and running and health == "healthy")
self.docker.containers[self.agent.container_name(INSTANCE, 1)] = info
self.assertEqual(self.agent.inspect(INSTANCE, 1)["healthy"], observations[0]["healthy"])
self.assertIn("observedAt", observations[0])
self.assertEqual(sum(args.args[:2] == ("container", "inspect") for args in docker.call_args_list), 1)
info["Mounts"][0]["Source"] = "/foreign/app"