Allow case-insensitivity when setting conductor_group via API
Since we use the new conductor group to calculate which conductor an update_node message should go to, we need to lowercase the new conductor_group value at the API level, rather than just before saving the node object. Change-Id: I5530f8e1c2fdff9008e008cfa0c63edaa04e81d9 Story: 2004947 Task: 29362
This commit is contained in:
parent
d9ed28b596
commit
c803488af2
@ -1738,6 +1738,11 @@ class NodesController(rest.RestController):
|
||||
continue
|
||||
if patch_val == wtypes.Unset:
|
||||
patch_val = None
|
||||
# conductor_group is case-insensitive, and we use it to calculate
|
||||
# the conductor to send an update too. lowercase it here instead
|
||||
# of just before saving so we calculate correctly.
|
||||
if field == 'conductor_group':
|
||||
patch_val = patch_val.lower()
|
||||
if rpc_node[field] != patch_val:
|
||||
rpc_node[field] = patch_val
|
||||
|
||||
|
@ -2267,6 +2267,19 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
self.assertEqual(http_client.NOT_ACCEPTABLE, response.status_code)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
@mock.patch('pecan.request')
|
||||
def test__update_changed_fields_lowers_conductor_group(self,
|
||||
mock_pecan_req):
|
||||
mock_pecan_req.version.minor = versions.MINOR_MAX_VERSION
|
||||
controller = api_node.NodesController()
|
||||
|
||||
node_dict = self.node.as_dict()
|
||||
node_dict['conductor_group'] = 'NEW-GROUP'
|
||||
node_obj = api_node.Node(**node_dict)
|
||||
|
||||
controller._update_changed_fields(node_obj, self.node)
|
||||
self.assertEqual('new-group', self.node.conductor_group)
|
||||
|
||||
@mock.patch("pecan.request")
|
||||
def test__update_changed_fields_remove_chassis_uuid(self, mock_pecan_req):
|
||||
mock_pecan_req.version.minor = versions.MINOR_MAX_VERSION
|
||||
|
6
releasenotes/notes/bug-2004947-e5f27e11b8f9c96d.yaml
Normal file
6
releasenotes/notes/bug-2004947-e5f27e11b8f9c96d.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes an issue where setting the ``conductor_group`` for a node was not
|
||||
entirely case-sensitive, in that this could fail if case-sensitivity did
|
||||
not match between the conductor configuration and the API request.
|
Loading…
Reference in New Issue
Block a user