Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit a3e6f38

Browse files
authored
Merge pull request #251 from gao-feng/pod
do not cleanup resources of pod when all of the containers are exited
2 parents 981e53f + e4b9466 commit a3e6f38

File tree

9 files changed

+1
-449
lines changed

9 files changed

+1
-449
lines changed

src/container.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -778,13 +778,3 @@ void hyper_cleanup_container(struct hyper_container *c, struct hyper_pod *pod)
778778
hyper_cleanup_container_portmapping(c, pod);
779779
hyper_free_container(c);
780780
}
781-
782-
void hyper_cleanup_containers(struct hyper_pod *pod)
783-
{
784-
struct hyper_container *c, *n;
785-
786-
list_for_each_entry_safe(c, n, &pod->containers, list)
787-
hyper_cleanup_container(c, pod);
788-
789-
pod->remains = 0;
790-
}

src/container.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ struct hyper_pod;
5959
int hyper_setup_container(struct hyper_container *container, struct hyper_pod *pod);
6060
struct hyper_container *hyper_find_container(struct hyper_pod *pod, const char *id);
6161
void hyper_cleanup_container(struct hyper_container *container, struct hyper_pod *pod);
62-
void hyper_cleanup_containers(struct hyper_pod *pod);
6362
void hyper_free_container(struct hyper_container *c);
6463

6564
static inline int hyper_has_container(struct hyper_pod *pod, const char *id) {

src/exec.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -715,16 +715,11 @@ static int hyper_release_exec(struct hyper_exec *exec)
715715
fprintf(stdout, "%s container init exited %s, remains %d\n",
716716
__func__, exec->pod->req_destroy?"manually":"automatically", exec->pod->remains);
717717

718-
// TODO send finish of this container and full cleanup
719-
if (--exec->pod->remains > 0)
720-
return 0;
721-
722-
if (exec->pod->req_destroy) {
718+
if (--exec->pod->remains == 0 && exec->pod->req_destroy) {
723719
/* shutdown vm manually, hyper doesn't care the pod finished codes */
724720
hyper_pod_destroyed(0);
725721
}
726722

727-
hyper_cleanup_pod(exec->pod);
728723
return 0;
729724
}
730725

src/hyper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ static inline int hyper_create(char *hyper_path)
8282
}
8383

8484
int hyper_open_serial(char *tty);
85-
void hyper_cleanup_pod(struct hyper_pod *pod);
8685
int hyper_enter_sandbox(struct hyper_pod *pod, int pidpipe);
8786
void hyper_pod_destroyed(int failed);
8887
int hyper_ctl_append_msg(struct hyper_event *he, uint32_t type, uint8_t *data, uint32_t len);

src/init.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -887,47 +887,6 @@ static void hyper_cmd_online_cpu_mem()
887887
}
888888
}
889889

890-
static void hyper_cleanup_hostname(struct hyper_pod *pod)
891-
{
892-
free(pod->hostname);
893-
pod->hostname = NULL;
894-
}
895-
896-
static void hyper_cleanup_shared(struct hyper_pod *pod)
897-
{
898-
if (pod->share_tag == NULL) {
899-
fprintf(stdout, "no shared directory\n");
900-
return;
901-
}
902-
903-
free(pod->share_tag);
904-
pod->share_tag = NULL;
905-
if (umount(SHARED_DIR) < 0 &&
906-
umount2(SHARED_DIR, MNT_DETACH)) {
907-
perror("fail to umount shared dir");
908-
return;
909-
}
910-
911-
if (rmdir(SHARED_DIR) < 0)
912-
perror("fail to delete " SHARED_DIR);
913-
914-
sync();
915-
}
916-
917-
void hyper_cleanup_pod(struct hyper_pod *pod)
918-
{
919-
if (pod->init_pid) {
920-
hyper_kill_process(pod->init_pid);
921-
pod->init_pid = 0;
922-
}
923-
hyper_cleanup_containers(pod);
924-
hyper_cleanup_network(pod);
925-
hyper_cleanup_shared(pod);
926-
hyper_cleanup_dns(pod);
927-
hyper_cleanup_portmapping(pod);
928-
hyper_cleanup_hostname(pod);
929-
}
930-
931890
static int hyper_setup_ctl_channel(char *name)
932891
{
933892
uint8_t buf[8];

0 commit comments

Comments
 (0)