diff --git a/zun/api/controllers/v1/capsules.py b/zun/api/controllers/v1/capsules.py index 8f3e5b8e0..2004a1140 100644 --- a/zun/api/controllers/v1/capsules.py +++ b/zun/api/controllers/v1/capsules.py @@ -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 diff --git a/zun/api/controllers/v1/schemas/parameter_types.py b/zun/api/controllers/v1/schemas/parameter_types.py index 524463316..cbe3742da 100644 --- a/zun/api/controllers/v1/schemas/parameter_types.py +++ b/zun/api/controllers/v1/schemas/parameter_types.py @@ -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, },