From 2aeaee92f1c50d1e3066a7b5efd38c4d0e0401f8 Mon Sep 17 00:00:00 2001 From: Simon Westphahl Date: Thu, 9 Nov 2023 11:38:57 +0100 Subject: [PATCH] Ignore unrelated error labels in request handler Nodepool was declining node requests when other unrelated instance types of a provider were unavailable: Declining node request due to ['node type(s) [ubuntu-invalid] not available'] To fix this we will the check error labels against the requested labels before including them in the list of invalid node types. Change-Id: I7bbb3b813ca82baf80821a9e84cc10385ea95a01 --- nodepool/driver/__init__.py | 3 ++- nodepool/tests/fixtures/aws/aws-invalid.yaml | 7 ++++++- nodepool/tests/unit/test_driver_aws.py | 13 ++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/nodepool/driver/__init__.py b/nodepool/driver/__init__.py index 34c55205a..5565158ad 100644 --- a/nodepool/driver/__init__.py +++ b/nodepool/driver/__init__.py @@ -429,7 +429,8 @@ class NodeRequestHandler(NodeRequestHandlerNotifications, if ntype not in valid: invalid.add(ntype) for ntype in self.manager.errorLabels(): - invalid.add(ntype) + if ntype in self.request.node_types: + invalid.add(ntype) return invalid def _waitForNodeSet(self): diff --git a/nodepool/tests/fixtures/aws/aws-invalid.yaml b/nodepool/tests/fixtures/aws/aws-invalid.yaml index dd09b1809..7de0d6eca 100644 --- a/nodepool/tests/fixtures/aws/aws-invalid.yaml +++ b/nodepool/tests/fixtures/aws/aws-invalid.yaml @@ -13,6 +13,7 @@ tenant-resource-limits: max-cores: 1024 labels: + - name: ubuntu-invalid - name: ubuntu providers: @@ -32,7 +33,11 @@ providers: key1: value1 key2: value2 labels: - - name: ubuntu + - name: ubuntu-invalid cloud-image: ubuntu instance-type: t3.nope key-name: zuul + - name: ubuntu + cloud-image: ubuntu + instance-type: t3.medium + key-name: zuul diff --git a/nodepool/tests/unit/test_driver_aws.py b/nodepool/tests/unit/test_driver_aws.py index d92579949..2937befdc 100644 --- a/nodepool/tests/unit/test_driver_aws.py +++ b/nodepool/tests/unit/test_driver_aws.py @@ -756,10 +756,21 @@ class TestDriverAws(tests.DBTestCase): self.assertTrue(response['EbsOptimized']['Value']) def test_aws_invalid_instance_type(self): - req = self.requestNode('aws/aws-invalid.yaml', 'ubuntu') + req = self.requestNode('aws/aws-invalid.yaml', 'ubuntu-invalid') self.assertEqual(req.state, zk.FAILED) self.assertEqual(req.nodes, []) + # Make sure other instance types are not affected + req = zk.NodeRequest() + req.state = zk.REQUESTED + req.tenant_name = 'tenant-1' + req.node_types.append('ubuntu') + self.zk.storeNodeRequest(req) + + req = self.waitForNodeRequest(req) + self.assertEqual(req.state, zk.FULFILLED) + self.assertEqual(len(req.nodes), 1) + def test_aws_diskimage_snapshot(self): self.fake_aws.fail_import_count = 1 configfile = self.setup_config('aws/diskimage.yaml')