diff --git a/nodepool/driver/static/provider.py b/nodepool/driver/static/provider.py index d618ad247..6bcab3f1d 100644 --- a/nodepool/driver/static/provider.py +++ b/nodepool/driver/static/provider.py @@ -208,7 +208,7 @@ class StaticNodeProvider(Provider): ''' host_keys = self.checkHost(static_node) node_tuple = nodeTuple(static_node) - nodes = self.getRegisteredReadyNodes() + nodes = self.getRegisteredReadyNodes(node_tuple) new_attrs = ( static_node["labels"], static_node["username"], diff --git a/nodepool/tests/unit/test_driver_static.py b/nodepool/tests/unit/test_driver_static.py index 64db1236f..3e59e201e 100644 --- a/nodepool/tests/unit/test_driver_static.py +++ b/nodepool/tests/unit/test_driver_static.py @@ -236,6 +236,30 @@ class TestDriverStatic(tests.DBTestCase): self.assertEqual(nodes[0].connection_type, 'winrm') self.assertEqual(nodes[0].host_keys, []) + def test_static_node_update_startup(self): + ''' + Test that updates a static node on config change at startup. + ''' + configfile = self.setup_config('static-basic.yaml') + pool = self.useNodepool(configfile, watermark_sleep=1) + pool.start() + + self.log.debug("Waiting for initial node") + nodes = self.waitForNodes('fake-label') + + pool.stop() + configfile = self.setup_config('static-multilabel.yaml') + pool = self.useNodepool(configfile, watermark_sleep=1) + pool.start() + + self.log.debug("Waiting for new label") + nodes = self.waitForNodes('fake-label2') + self.assertEqual(len(nodes), 1) + # Check that the node was updated and not re-created + self.assertEqual(nodes[0].id, "0000000000") + self.assertIn('fake-label', nodes[0].type) + self.assertIn('fake-label2', nodes[0].type) + def test_static_multilabel(self): configfile = self.setup_config('static-multilabel.yaml') pool = self.useNodepool(configfile, watermark_sleep=1)