Suppress conflicts between retry options and auto_remove option

This patch fixes conflicts between retry options and auto_remove option.
To suppress this conflicts, when retry option selected this patch clears
auto_remove option and set readonly attribute for the checkbox.

Also, to check them easily from user, move auto_remove option from
Miscellaneous tab to Spec tab, i.e. under retry options.

Change-Id: I34a409141adf1ad822e5999240ccbb8ae8e2acf5
Closes-Bug: #1763250
This commit is contained in:
Shu Muto 2018-04-11 16:30:52 +09:00
parent 3f7935d3ac
commit 1d47c368fe
7 changed files with 66 additions and 56 deletions

View File

@ -0,0 +1,6 @@
fixes:
- >
[`bug/1763250 <https://bugs.launchpad.net/zun-ui/+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.

View File

@ -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);

View File

@ -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) : "";
}

View File

@ -5,6 +5,4 @@
<dd translate>The environment variables in comma separated KEY=VALUE pairs</dd>
<dt translate>Enable Interactive Mode</dt>
<dd translate>Allocate pseudo-TTY and keep STDIN open even if not attached. This also enables Web console in console tab on details view.</dd>
<dt translate>Auto remove</dt>
<dd translate>Automatically remove the container when it exits</dd>
</dl>

View File

@ -3,8 +3,8 @@
<dd translate>The number of virtual cpus.</dd>
<dt translate>Memory</dt>
<dd translate>The container memory size in MiB.</dd>
<dt translate>Restart Policy</dt>
<dd translate>Restart policy to apply when a container exits.</dd>
<dt translate>Runtime</dt>
<dd translate>The runtime to use for this container. Default: "runc"</dd>
<dt translate>Exit Policy</dt>
<dd translate>Policy to apply when a container exits.</dd>
</dl>

View File

@ -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

View File

@ -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']]">
</hz-resource-property-list>
</div>
</div>
@ -33,7 +33,7 @@
cls="dl-horizontal"
item="ctrl.container"
property-groups="[['host', 'workdir', 'environment', 'interactive',
'auto_remove', 'labels','links']]">
'labels', 'links']]">
</hz-resource-property-list>
</div>
</div>