Backward-compatible with old restart_policy

The property 'restart_policy' is changed in spec content [1], but
unfortunately it doesn't change in a backward-compatible way and
breaks the gophercloud CI. This patch fixes it.

[1] https://review.openstack.org/#/c/571398/

Change-Id: Ia623cd54432f83505c93f94680859c492adc4f22
This commit is contained in:
Hongbin Lu 2018-07-05 03:07:26 +00:00
parent aafdd20617
commit 1526cfd22d
2 changed files with 11 additions and 2 deletions

View File

@ -153,8 +153,13 @@ class CapsuleController(base.Controller):
capsule_need_memory = 0
container_volume_requests = []
capsule_restart_policy = spec_content.get('restart_policy',
'always')
if spec_content.get('restart_policy'):
capsule_restart_policy = spec_content.get('restart_policy')
else:
# NOTE(hongbin): this is deprecated but we need to maintain
# backward-compatibility. Will remove this branch in the future.
capsule_restart_policy = template_json.get('restart_policy',
'always')
container_restart_policy = {"MaximumRetryCount": "0",
"Name": capsule_restart_policy}
new_capsule.restart_policy = capsule_restart_policy

View File

@ -494,6 +494,10 @@ capsule_template = {
"kind": capsule_kind,
"capsuleVersion": capsule_version,
"metadata": capsule_metadata,
# NOTE(hongbin): property 'restartPolicy' is deprecated but we keep
# it here for backward-compatibility. Will remove it after the
# deprecation period.
"restartPolicy": capsule_restart_policy,
"spec": capsule_spec,
"availabilityZone": availability_zone,
},