Merge "api: Set min, maxItems for server_group.policies field" into stable/train

This commit is contained in:
Zuul 2020-10-15 00:05:41 +00:00 committed by Gerrit Code Review
commit c718cf445d
3 changed files with 22 additions and 9 deletions

View File

@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import copy import copy
from nova.api.validation import parameter_types from nova.api.validation import parameter_types
@ -27,15 +28,18 @@ create = {
'name': parameter_types.name, 'name': parameter_types.name,
'policies': { 'policies': {
# This allows only a single item and it must be one of the # This allows only a single item and it must be one of the
# enumerated values. So this is really just a single string # enumerated values. It's changed to a single string value
# value, but for legacy reasons is an array. We could # in 2.64.
# probably change the type from array to string with a
# microversion at some point but it's very low priority.
'type': 'array', 'type': 'array',
'items': [{ 'items': [
'type': 'string', {
'enum': ['anti-affinity', 'affinity']}], 'type': 'string',
'enum': ['anti-affinity', 'affinity'],
},
],
'uniqueItems': True, 'uniqueItems': True,
'minItems': 1,
'maxItems': 1,
'additionalItems': False, 'additionalItems': False,
} }
}, },

View File

@ -37,5 +37,4 @@ class TestCreateServerGroupWithEmptyPolicies(
client.OpenStackApiException, client.OpenStackApiException,
self.api.post_server_groups, self.api.post_server_groups,
{'name': 'test group', 'policies': []}) {'name': 'test group', 'policies': []})
# FIXME(stephenfin): This should not be a 500 error self.assertEqual(400, exc.response.status_code)
self.assertEqual(500, exc.response.status_code)

View File

@ -0,0 +1,10 @@
---
fixes:
- |
Resolved an issue whereby providing an empty list for the ``policies``
field in the request body of the ``POST /os-server-groups`` API would
result in a server error. This only affects the 2.1 to 2.63 microversions,
as the 2.64 microversion replaces the ``policies`` list field with a
``policy`` string field. See `bug #1894966`__ for more information.
.. __: https://bugs.launchpad.net/nova/+bug/1894966