diff --git a/releasenotes/notes/bug-1763250-5035b39df953d25d.yaml b/releasenotes/notes/bug-1763250-5035b39df953d25d.yaml new file mode 100644 index 0000000..68dd255 --- /dev/null +++ b/releasenotes/notes/bug-1763250-5035b39df953d25d.yaml @@ -0,0 +1,6 @@ +fixes: + - > + [`bug/1763250 `_] + Fixed issue the conflict between retry and auto_remove options. + To avoid this conflict, auto_remove option will be cleared when + retry option is set. diff --git a/zun_ui/static/dashboard/container/containers/actions/create.service.js b/zun_ui/static/dashboard/container/containers/actions/create.service.js index c6ed947..11de7c9 100644 --- a/zun_ui/static/dashboard/container/containers/actions/create.service.js +++ b/zun_ui/static/dashboard/container/containers/actions/create.service.js @@ -70,13 +70,15 @@ } function submit(context) { + delete context.model.exit_policy; if (context.model.restart_policy === "on-failure") { if (!context.model.restart_policy_max_retry) { - context.model.restart_policy_max_retry = 0; + delete context.model.restart_policy_max_retry; + } else { + context.model.restart_policy = + context.model.restart_policy + ":" + + context.model.restart_policy_max_retry; } - context.model.restart_policy = - context.model.restart_policy + ":" + - context.model.restart_policy_max_retry; } delete context.model.restart_policy_max_retry; context.model.mounts = setMounts(context.model.mounts); diff --git a/zun_ui/static/dashboard/container/containers/actions/update.service.js b/zun_ui/static/dashboard/container/containers/actions/update.service.js index f7bf4d1..6ddf41c 100644 --- a/zun_ui/static/dashboard/container/containers/actions/update.service.js +++ b/zun_ui/static/dashboard/container/containers/actions/update.service.js @@ -83,6 +83,8 @@ ? response.data.command : ""; config.model.hostname = response.data.hostname ? response.data.hostname : ""; + config.model.auto_remove = response.data.auto_remove + ? response.data.auto_remove : false; config.model.cpu = response.data.cpu ? response.data.cpu : ""; config.model.memory = response.data.memory @@ -91,6 +93,11 @@ ? response.data.restart_policy.Name : ""; config.model.restart_policy_max_retry = response.data.restart_policy.MaximumRetryCount ? parseInt(response.data.restart_policy.MaximumRetryCount, 10) : null; + if (config.model.auto_remove) { + config.model.exit_policy = "remove"; + } else { + config.model.exit_policy = config.model.restart_policy; + } config.model.runtime = response.data.runtime ? response.data.runtime : ""; config.model.allocatedNetworks = getAllocatedNetworks(response.data.addresses); @@ -100,8 +107,6 @@ ? hashToString(response.data.environment) : ""; config.model.interactive = response.data.interactive ? response.data.interactive : false; - config.model.auto_remove = response.data.auto_remove - ? response.data.auto_remove : false; config.model.labels = response.data.labels ? hashToString(response.data.labels) : ""; } diff --git a/zun_ui/static/dashboard/container/containers/actions/workflow/misc.help.html b/zun_ui/static/dashboard/container/containers/actions/workflow/misc.help.html index 0a92239..6ea6be7 100644 --- a/zun_ui/static/dashboard/container/containers/actions/workflow/misc.help.html +++ b/zun_ui/static/dashboard/container/containers/actions/workflow/misc.help.html @@ -5,6 +5,4 @@
The environment variables in comma separated KEY=VALUE pairs
Enable Interactive Mode
Allocate pseudo-TTY and keep STDIN open even if not attached. This also enables Web console in console tab on details view.
-
Auto remove
-
Automatically remove the container when it exits
diff --git a/zun_ui/static/dashboard/container/containers/actions/workflow/spec.help.html b/zun_ui/static/dashboard/container/containers/actions/workflow/spec.help.html index 06fdf71..33c1ace 100644 --- a/zun_ui/static/dashboard/container/containers/actions/workflow/spec.help.html +++ b/zun_ui/static/dashboard/container/containers/actions/workflow/spec.help.html @@ -3,8 +3,8 @@
The number of virtual cpus.
Memory
The container memory size in MiB.
-
Restart Policy
-
Restart policy to apply when a container exits.
Runtime
The runtime to use for this container. Default: "runc"
+
Exit Policy
+
Policy to apply when a container exits.
diff --git a/zun_ui/static/dashboard/container/containers/actions/workflow/workflow.service.js b/zun_ui/static/dashboard/container/containers/actions/workflow/workflow.service.js index 26c68cc..1b9cfc0 100644 --- a/zun_ui/static/dashboard/container/containers/actions/workflow/workflow.service.js +++ b/zun_ui/static/dashboard/container/containers/actions/workflow/workflow.service.js @@ -45,12 +45,13 @@ {value: "always", name: gettext("Always")}, {value: "never", name: gettext("Never")} ]; - var restartPolicies = [ + var exitPolicies = [ {value: "", name: gettext("Select policy.")}, {value: "no", name: gettext("No")}, - {value: "on-failure", name: gettext("On failure")}, - {value: "always", name: gettext("Always")}, - {value: "unless-stopped", name: gettext("Unless Stopped")} + {value: "on-failure", name: gettext("Restart on failure")}, + {value: "always", name: gettext("Always restart")}, + {value: "unless-stopped", name: gettext("Restart if stopped")}, + {value: "remove", name: gettext("Remove container")} ]; // schema @@ -87,6 +88,10 @@ title: gettext("Hostname"), type: "string" }, + runtime: { + title: gettext("Runtime"), + type: "string" + }, cpu: { title: gettext("CPU"), type: "number", @@ -97,12 +102,8 @@ type: "number", minimum: 4 }, - destination: { - title: gettext("Destination"), - type: "string" - }, - restart_policy: { - title: gettext("Restart Policy"), + exit_policy: { + title: gettext("Exit Policy"), type: "string" }, restart_policy_max_retry: { @@ -110,10 +111,6 @@ type: "number", minimum: 0 }, - runtime: { - title: gettext("Runtime"), - type: "string" - }, // misc workdir: { title: gettext("Working Directory"), @@ -127,10 +124,6 @@ title: gettext("Enable interactive mode"), type: "boolean" }, - auto_remove: { - title: gettext("Auto remove"), - type: "boolean" - }, // labels labels: { title: gettext("Labels"), @@ -214,7 +207,7 @@ items: [ { type: "section", - htmlClass: "col-xs-12", + htmlClass: "col-xs-6", items: [ { key: "hostname", @@ -223,6 +216,17 @@ } ] }, + { + type: "section", + htmlClass: "col-xs-6", + items: [ + { + key: "runtime", + placeholder: gettext("The runtime to create container with."), + readonly: action === "update" + } + ] + }, { type: "section", htmlClass: "col-xs-6", @@ -250,16 +254,25 @@ htmlClass: "col-xs-6", items: [ { - key: "restart_policy", + key: "exit_policy", type: "select", readonly: action === "update", - titleMap: restartPolicies, + titleMap: exitPolicies, onChange: function() { - var readonly = model.restart_policy !== "on-failure"; - if (readonly) { + var notOnFailure = model.exit_policy !== "on-failure"; + if (notOnFailure) { model.restart_policy_max_retry = ""; } - form[0].tabs[1].items[4].items[0].readonly = readonly; + form[0].tabs[1].items[5].items[0].readonly = notOnFailure; + // set auto_remove whether exit_policy is "remove". + // if exit_policy is set as "remove", clear restart_policy. + // otherwise, set restart_policy as same value as exit_policy. + model.auto_remove = (model.exit_policy === "remove"); + if (model.auto_remove) { + model.restart_policy = ""; + } else { + model.restart_policy = model.exit_policy; + } } } ] @@ -270,21 +283,10 @@ items: [ { key: "restart_policy_max_retry", - placeholder: gettext("Retry times for 'On failure' policy."), + placeholder: gettext("Retry times for 'Restart on failure' policy."), readonly: true } ] - }, - { - type: "section", - htmlClass: "col-xs-6", - items: [ - { - key: "runtime", - placeholder: gettext("The runtime to create container with."), - readonly: action === "update", - } - ] } ] }, @@ -390,10 +392,6 @@ { key: "interactive", readonly: action === "update" - }, - { - key: "auto_remove", - readonly: action === "update" } ] } @@ -455,11 +453,13 @@ run: true, // spec hostname: "", + runtime: "", cpu: "", memory: "", + exit_policy: "", restart_policy: "", restart_policy_max_retry: "", - runtime: "", + auto_remove: false, // mounts mounts: [], // networks @@ -472,7 +472,6 @@ workdir: "", environment: "", interactive: true, - auto_remove: false, // labels labels: "", // hints diff --git a/zun_ui/static/dashboard/container/containers/details/overview.html b/zun_ui/static/dashboard/container/containers/details/overview.html index 39ccc70..38753de 100644 --- a/zun_ui/static/dashboard/container/containers/details/overview.html +++ b/zun_ui/static/dashboard/container/containers/details/overview.html @@ -18,9 +18,9 @@ resource-type-name="OS::Zun::Container" cls="dl-horizontal" item="ctrl.container" - property-groups="[['image', 'image_driver', 'image_pull_policy', - 'cpu', 'memory', 'restart_policy', 'runtime', - 'hostname', 'addresses', 'ports', 'security_groups']]"> + property-groups="[['image', 'image_driver', 'image_pull_policy', 'hostname', 'runtime', + 'cpu', 'memory', 'restart_policy', 'auto_remove', + 'addresses', 'ports', 'security_groups']]"> @@ -33,7 +33,7 @@ cls="dl-horizontal" item="ctrl.container" property-groups="[['host', 'workdir', 'environment', 'interactive', - 'auto_remove', 'labels','links']]"> + 'labels', 'links']]">