From ae2359f321ab14eed2ed4154e4e0b93d26ed2813 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Mon, 11 Mar 2013 14:02:30 -0700 Subject: [PATCH] Force resource updates to update updated_at When there's no changes in resources, compute_node_update (and other DB update calls) won't modify 'updated_at'. 'updated_at' is what is used to invalidate the cache in the scheduler's host_manager. Because of a race with the compute manager, the scheduler could be out of sync with the compute_nodes table but have a newer time on its cache. By always updating 'updated_at' on resource updates, the periodic task will be sure to invalidate any bad cache the scheduler has. Fixes bug 1153778 Change-Id: I19b51a5b84f472cd0f4de6460a4edb540cc62da2 --- nova/tests/test_db_api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 769ddaea..b779affa 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -1511,6 +1511,12 @@ class CapacityTestCase(test.TestCase): self.assertEqual(2, int(stats['num_proj_12345'])) self.assertEqual(1, int(stats['num_tribbles'])) + def test_compute_node_update_always_updates_updated_at(self): + item = self._create_helper('host1') + item_updated = db.compute_node_update(self.ctxt, + item['id'], {}) + self.assertNotEqual(item['updated_at'], item_updated['updated_at']) + def test_compute_node_stat_prune(self): item = self._create_helper('host1') for stat in item['stats']: