File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ CONTAINERD_FLAGS+="--address ${TRIMMED_CONTAINERD_SOCK} \
7979 --state ${CONTAINERD_STATE} \
8080 --root ${CONTAINERD_ROOT} "
8181
82- kill_containerd_cmd =
82+ pid =
8383
8484# NOTE: We don't have the sudo command on Windows.
8585sudo=" "
@@ -103,12 +103,6 @@ test_setup() {
103103 pid=$!
104104 set +m
105105
106- if [ $IS_WINDOWS -eq 1 ]; then
107- kill_containerd_cmd=" ${sudo} kill ${pid} "
108- else
109- kill_containerd_cmd=" ${sudo} pkill -g $( ps -o pgid= -p ${pid} ) "
110- fi
111-
112106 # Wait for containerd to be running by using the containerd client ctr to check the version
113107 # of the containerd server. Wait an increasing amount of time after each of five attempts
114108 local -r crictl_path=$( which crictl)
@@ -122,8 +116,14 @@ test_setup() {
122116
123117# test_teardown kills containerd.
124118test_teardown () {
125- if [ -n " ${kill_containerd_cmd} " ]; then
126- ${kill_containerd_cmd}
119+ if [ -n " ${pid} " ]; then
120+ if [ $IS_WINDOWS -eq 1 ]; then
121+ # NOTE(claudiub): The containerd process will have the same PGID as the keepalive process,
122+ # so we can kill both of them by matching the PGID.
123+ ${sudo} ps | awk " {if (\$ 3 == ${pid} ) print \$ 1}" | xargs kill
124+ else
125+ ${sudo} pkill -g $( ps -o pgid= -p ${pid} )
126+ fi
127127 fi
128128}
129129
You can’t perform that action at this time.
0 commit comments