From 69227c66c25d49beab3210bdf08f53cbde78d87f Mon Sep 17 00:00:00 2001 From: Arne Wiebalck Date: Tue, 11 Jan 2022 12:37:41 +0100 Subject: [PATCH] Set resource_url when getting all nodes Since the default value resource_url is None, make sure the parameter is set to 'nodes' when getting all nodes. Change-Id: I6cc52eb56c7888a433d24aa79154143d6f35cf83 --- ironic/api/controllers/v1/node.py | 2 ++ ironic/tests/unit/api/controllers/v1/test_node.py | 8 ++++++++ .../fix_pagination_resource_url-42fb4023fde9da2b.yaml | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 releasenotes/notes/fix_pagination_resource_url-42fb4023fde9da2b.yaml diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py index f3d017b6dc..4831361cf2 100644 --- a/ironic/api/controllers/v1/node.py +++ b/ironic/api/controllers/v1/node.py @@ -2288,6 +2288,7 @@ class NodesController(rest.RestController): fields = api_utils.get_request_return_fields(fields, detail, _DEFAULT_RETURN_FIELDS) + resource_url = 'nodes' extra_args = {'description_contains': description_contains} return self._get_nodes_collection(chassis_uuid, instance_uuid, associated, maintenance, retired, @@ -2295,6 +2296,7 @@ class NodesController(rest.RestController): limit, sort_key, sort_dir, driver=driver, resource_class=resource_class, + resource_url=resource_url, fields=fields, fault=fault, conductor_group=conductor_group, detail=detail, diff --git a/ironic/tests/unit/api/controllers/v1/test_node.py b/ironic/tests/unit/api/controllers/v1/test_node.py index 61eebc6dad..b642f3ee39 100644 --- a/ironic/tests/unit/api/controllers/v1/test_node.py +++ b/ironic/tests/unit/api/controllers/v1/test_node.py @@ -1347,6 +1347,7 @@ class TestListNodes(test_api_base.BaseApiTest): next_marker = data['nodes'][-1]['uuid'] self.assertIn(next_marker, data['next']) + self.assertIn('nodes', data['next']) def test_collection_links_default_limit(self): cfg.CONF.set_override('max_limit', 3, 'api') @@ -1360,6 +1361,7 @@ class TestListNodes(test_api_base.BaseApiTest): next_marker = data['nodes'][-1]['uuid'] self.assertIn(next_marker, data['next']) + self.assertIn('nodes', data['next']) def test_collection_links_custom_fields(self): fields = 'driver_info,uuid' @@ -1379,6 +1381,7 @@ class TestListNodes(test_api_base.BaseApiTest): next_marker = data['nodes'][-1]['uuid'] self.assertIn(next_marker, data['next']) self.assertIn('fields', data['next']) + self.assertIn('nodes', data['next']) def test_get_collection_pagination_no_uuid(self): fields = 'name' @@ -1396,6 +1399,7 @@ class TestListNodes(test_api_base.BaseApiTest): self.assertEqual(limit, len(data['nodes'])) self.assertIn('marker=%s' % nodes[limit - 1].uuid, data['next']) + self.assertIn('nodes', data['next']) def test_collection_links_instance_uuid_param(self): cfg.CONF.set_override('max_limit', 1, 'api') @@ -1613,6 +1617,7 @@ class TestListNodes(test_api_base.BaseApiTest): headers={api_base.Version.string: str(api_v1.max_version())}) self.assertEqual(1, len(data['connectors'])) self.assertIn('next', data) + self.assertIn('volume/connectors', data['next']) def test_volume_connectors_subresource_noid(self): node = obj_utils.create_test_node(self.context) @@ -1652,6 +1657,7 @@ class TestListNodes(test_api_base.BaseApiTest): headers={api_base.Version.string: str(api_v1.max_version())}) self.assertEqual(1, len(data['targets'])) self.assertIn('next', data) + self.assertIn('volume/target', data['next']) def test_volume_targets_subresource_noid(self): node = obj_utils.create_test_node(self.context) @@ -1856,6 +1862,7 @@ class TestListNodes(test_api_base.BaseApiTest): data = self.get_json('/nodes/?limit=3&associated=True') self.assertThat(data['nodes'], matchers.HasLength(3)) self.assertIn('associated=True', data['next']) + self.assertIn('nodes', data['next']) def test_detail_with_association_filter(self): associated_nodes = (self @@ -1870,6 +1877,7 @@ class TestListNodes(test_api_base.BaseApiTest): self.assertThat(data['nodes'], matchers.HasLength(3)) self.assertIn('driver', data['nodes'][0]) self.assertIn('associated=True', data['next']) + self.assertIn('nodes', data['next']) def test_detail_with_instance_uuid(self): node = obj_utils.create_test_node( diff --git a/releasenotes/notes/fix_pagination_resource_url-42fb4023fde9da2b.yaml b/releasenotes/notes/fix_pagination_resource_url-42fb4023fde9da2b.yaml new file mode 100644 index 0000000000..eb255a1056 --- /dev/null +++ b/releasenotes/notes/fix_pagination_resource_url-42fb4023fde9da2b.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes an issue where clients would get a 404 due to the node pagination + breaking at max_limit due to an uninitialised resource_url.