From 725b37f515e4ad01e1f4491b6d8137ce1416f6d6 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Fri, 28 Jun 2019 16:19:49 -0400 Subject: [PATCH] Init HostState.failed_builds If _update_from_compute_node returns early and the HostState is not filtered out we can hit an AttributeError in the BuildFailureWeigher because the failed_builds attribute is not set. This simply initializes the attribute like the other stats fields. Change-Id: I5f8e4d32c6a1d6b61396b4fa11c5d776f432df0c Closes-Bug: #1834691 (cherry picked from commit d540903463aa9b0cf69cefac7cc60e5b70e40a1c) --- nova/scheduler/host_manager.py | 1 + nova/tests/unit/scheduler/test_host_manager.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py index bb9624a2a3f4..8028b5e939b6 100644 --- a/nova/scheduler/host_manager.py +++ b/nova/scheduler/host_manager.py @@ -126,6 +126,7 @@ class HostState(object): # Additional host information from the compute node stats: self.num_instances = 0 self.num_io_ops = 0 + self.failed_builds = 0 # Other information self.host_ip = None diff --git a/nova/tests/unit/scheduler/test_host_manager.py b/nova/tests/unit/scheduler/test_host_manager.py index a4fc0d840fbc..a42370da8fd5 100644 --- a/nova/tests/unit/scheduler/test_host_manager.py +++ b/nova/tests/unit/scheduler/test_host_manager.py @@ -1455,3 +1455,5 @@ class HostStateTestCase(test.NoDBTestCase): # Because compute record not ready, the update of free ram # will not happen and the value will still be 0 self.assertEqual(0, host.free_ram_mb) + # same with failed_builds + self.assertEqual(0, host.failed_builds)