Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.

Commit

Permalink
delete: Delete container only if state is STOPPED
Browse files Browse the repository at this point in the history
This patch verify if a container is not stopped when
the delete command is used. The detele command
will fail, this is acording to oci spec:

https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc5/runtime.md#delete

Fixes: #1018

Signed-off-by: Jose Carlos Venegas Munoz <[email protected]>
  • Loading branch information
jcvenegas committed Jun 28, 2017
1 parent cfcc9cd commit a51537c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/oci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,17 +1075,25 @@ cc_oci_stop (struct cc_oci_config *config,
return false;
}

/* if the process has finished the container is stopped */
if (kill (state->pid, 0) != 0) {
config->state.status = OCI_STATUS_STOPPED;
}

if (config->state.status != OCI_STATUS_STOPPED ) {
g_critical("cannot delete container, it is not stopped");
return false;
}

/* is VM running? */
if (kill (config->vm->pid, 0) == 0) {
/* delete a pod_containers not destroy a VM(pod)*/
if (cc_pod_is_pod_container(config)) {
g_debug("Cannot delete container %s (pid %u) - "
"it is a pod container", state->id, state->pid);
} else if (cc_pod_is_pod_sandbox (config) ||
config->state.status != OCI_STATUS_STOPPED) {
if (! cc_proxy_hyper_destroy_pod(config)) {
g_critical ("failed to destroy pod");
return false;
}
"it is a pod container", state->id, state->pid);
} else if (! cc_proxy_hyper_destroy_pod(config)) {
g_critical ("failed to destroy pod");
return false;
}
} else {
/* This isn't a fatal condition since:
Expand Down

0 comments on commit a51537c

Please sign in to comment.