Skip to content

Commit 8a33066

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "api: Set min, maxItems for server_group.policies field"
2 parents f47bde5 + 32c43fc commit 8a33066

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

nova/api/openstack/compute/schemas/server_groups.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14+
1415
import copy
1516

1617
from nova.api.validation import parameter_types
@@ -27,15 +28,18 @@
2728
'name': parameter_types.name,
2829
'policies': {
2930
# This allows only a single item and it must be one of the
30-
# enumerated values. So this is really just a single string
31-
# value, but for legacy reasons is an array. We could
32-
# probably change the type from array to string with a
33-
# microversion at some point but it's very low priority.
31+
# enumerated values. It's changed to a single string value
32+
# in 2.64.
3433
'type': 'array',
35-
'items': [{
36-
'type': 'string',
37-
'enum': ['anti-affinity', 'affinity']}],
34+
'items': [
35+
{
36+
'type': 'string',
37+
'enum': ['anti-affinity', 'affinity'],
38+
},
39+
],
3840
'uniqueItems': True,
41+
'minItems': 1,
42+
'maxItems': 1,
3943
'additionalItems': False,
4044
}
4145
},

nova/tests/functional/regressions/test_bug_1894966.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ def test_create_with_empty_policies(self):
3737
client.OpenStackApiException,
3838
self.api.post_server_groups,
3939
{'name': 'test group', 'policies': []})
40-
# FIXME(stephenfin): This should not be a 500 error
41-
self.assertEqual(500, exc.response.status_code)
40+
self.assertEqual(400, exc.response.status_code)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
fixes:
3+
- |
4+
Resolved an issue whereby providing an empty list for the ``policies``
5+
field in the request body of the ``POST /os-server-groups`` API would
6+
result in a server error. This only affects the 2.1 to 2.63 microversions,
7+
as the 2.64 microversion replaces the ``policies`` list field with a
8+
``policy`` string field. See `bug #1894966`__ for more information.
9+
10+
.. __: https://bugs.launchpad.net/nova/+bug/1894966

0 commit comments

Comments
 (0)