Unverified Commit de206187 by Christian Brauner Committed by GitHub

Merge pull request #2542 from tcharding/signal-fail-2523

tools: Indicate container startup failure
parents 4f9500b1 e3e70db3
...@@ -318,7 +318,7 @@ static int toss_list(struct lxc_list *c_groups_list) ...@@ -318,7 +318,7 @@ static int toss_list(struct lxc_list *c_groups_list)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int count = 0, i = 0, ret = 0; int count = 0, failed = 0, i = 0, ret = 0;
struct lxc_list *cmd_group; struct lxc_list *cmd_group;
struct lxc_container **containers = NULL; struct lxc_container **containers = NULL;
struct lxc_list **c_groups_lists = NULL; struct lxc_list **c_groups_lists = NULL;
...@@ -491,11 +491,15 @@ int main(int argc, char *argv[]) ...@@ -491,11 +491,15 @@ int main(int argc, char *argv[])
} }
/* clean up any lingering detritus */ /* clean up any lingering detritus, if container exists here
* then it must have failed to start.
*/
failed = 0;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (containers[i]) if (containers[i]) {
failed++;
lxc_container_put(containers[i]); lxc_container_put(containers[i]);
}
if (c_groups_lists && c_groups_lists[i]) if (c_groups_lists && c_groups_lists[i])
toss_list(c_groups_lists[i]); toss_list(c_groups_lists[i]);
} }
...@@ -504,5 +508,10 @@ int main(int argc, char *argv[]) ...@@ -504,5 +508,10 @@ int main(int argc, char *argv[])
toss_list(cmd_groups_list); toss_list(cmd_groups_list);
free(containers); free(containers);
if (failed == count)
exit(1); /* Total failure */
else if (failed > 0)
exit(2); /* Partial failure */
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment