diff options
author | Zuul <zuul@review.opendev.org> | 2020-10-06 02:28:45 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-10-06 02:28:45 +0000 |
commit | b97703609ea4ce6351b4a578b7ab6c5317206203 (patch) | |
tree | c01a1640f6484b34ce36f88219f7a75e0b4cbb4d | |
parent | 62c42ff5841db258aa81b014fdb0054020ef9c85 (diff) | |
parent | 781210bd598c3e0ee9bd6a7db5d25688b5fc0131 (diff) | |
download | nova-b97703609ea4ce6351b4a578b7ab6c5317206203.tar.gz |
Merge "api: Set min, maxItems for server_group.policies field" into stable/ussuri
-rw-r--r-- | nova/api/openstack/compute/schemas/server_groups.py | 18 | ||||
-rw-r--r-- | nova/tests/functional/regressions/test_bug_1894966.py | 3 | ||||
-rw-r--r-- | releasenotes/notes/bug-1894966-d25c12b1320cb910.yaml | 10 |
3 files changed, 22 insertions, 9 deletions
diff --git a/nova/api/openstack/compute/schemas/server_groups.py b/nova/api/openstack/compute/schemas/server_groups.py index c5724bd687..102c6df869 100644 --- a/nova/api/openstack/compute/schemas/server_groups.py +++ b/nova/api/openstack/compute/schemas/server_groups.py @@ -11,6 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. + import copy from nova.api.validation import parameter_types @@ -27,15 +28,18 @@ create = { 'name': parameter_types.name, 'policies': { # This allows only a single item and it must be one of the - # enumerated values. So this is really just a single string - # value, but for legacy reasons is an array. We could - # probably change the type from array to string with a - # microversion at some point but it's very low priority. + # enumerated values. It's changed to a single string value + # in 2.64. 'type': 'array', - 'items': [{ - 'type': 'string', - 'enum': ['anti-affinity', 'affinity']}], + 'items': [ + { + 'type': 'string', + 'enum': ['anti-affinity', 'affinity'], + }, + ], 'uniqueItems': True, + 'minItems': 1, + 'maxItems': 1, 'additionalItems': False, } }, diff --git a/nova/tests/functional/regressions/test_bug_1894966.py b/nova/tests/functional/regressions/test_bug_1894966.py index 74cd7c07c4..3e85bfe557 100644 --- a/nova/tests/functional/regressions/test_bug_1894966.py +++ b/nova/tests/functional/regressions/test_bug_1894966.py @@ -37,5 +37,4 @@ class TestCreateServerGroupWithEmptyPolicies( client.OpenStackApiException, self.api.post_server_groups, {'name': 'test group', 'policies': []}) - # FIXME(stephenfin): This should not be a 500 error - self.assertEqual(500, exc.response.status_code) + self.assertEqual(400, exc.response.status_code) diff --git a/releasenotes/notes/bug-1894966-d25c12b1320cb910.yaml b/releasenotes/notes/bug-1894966-d25c12b1320cb910.yaml new file mode 100644 index 0000000000..f87cc7806d --- /dev/null +++ b/releasenotes/notes/bug-1894966-d25c12b1320cb910.yaml @@ -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 |