File tree Expand file tree Collapse file tree 10 files changed +49
-29
lines changed Expand file tree Collapse file tree 10 files changed +49
-29
lines changed Original file line number Diff line number Diff line change 46
46
set -x
47
47
sudo apt-get install python3-setuptools
48
48
sudo pip3 install --upgrade pip
49
- sudo pip3 install -U pytest sh
49
+ sudo pip3 install -U pytest sh psutil
50
50
sudo apt-get -y install open-iscsi
51
51
sudo systemctl enable iscsid
52
52
- name : Fetch snap
71
71
set -x
72
72
sudo apt-get install python3-setuptools
73
73
sudo pip3 install --upgrade pip
74
- sudo pip3 install -U pytest sh
74
+ sudo pip3 install -U pytest sh psutil
75
75
sudo apt-get -y install open-iscsi
76
76
sudo systemctl enable iscsid
77
77
- name : Fetch snap
@@ -139,7 +139,7 @@ jobs:
139
139
set -x
140
140
sudo apt-get install python3-setuptools
141
141
sudo pip3 install --upgrade pip
142
- sudo pip3 install -U pytest sh
142
+ sudo pip3 install -U pytest sh psutil
143
143
sudo apt-get -y install open-iscsi
144
144
sudo systemctl enable iscsid
145
145
- name : Fetch snap
Original file line number Diff line number Diff line change @@ -988,7 +988,7 @@ remove_all_containers() {
988
988
989
989
for container in $( " ${SNAP} /microk8s-ctr.wrapper" containers ls | $SNAP /bin/sed -n ' 1!p' | $SNAP /usr/bin/gawk ' {print $1}' )
990
990
do
991
- " ${SNAP} /microk8s-ctr.wrapper" container delete --force $container & > /dev/null || true
991
+ " ${SNAP} /microk8s-ctr.wrapper" container delete $container & > /dev/null || true
992
992
done
993
993
}
994
994
Original file line number Diff line number Diff line change 2
2
3
3
. " ${SNAP} /actions/common/utils.sh"
4
4
5
- if is_strict
6
- then
7
- remove_all_containers
8
- else
9
- kill_all_container_shims
10
- fi
5
+ remove_all_containers
6
+ kill_all_container_shims
Original file line number Diff line number Diff line change 65
65
echo " cert change detected. Reconfiguring the kube-apiserver"
66
66
rm -rf .srl
67
67
snapctl stop microk8s.daemon-kubelite
68
- if is_strict
69
- then
70
- remove_all_containers
71
- snapctl restart microk8s.daemon-containerd
72
- else
73
- snapctl stop microk8s.daemon-containerd
74
- kill_all_container_shims
75
- snapctl start microk8s.daemon-containerd
76
- fi
68
+ remove_all_containers
69
+ kill_all_container_shims
70
+ snapctl restart microk8s.daemon-containerd
77
71
snapctl start microk8s.daemon-kubelite
78
72
start_all_containers
79
73
restart_attempt=$[$restart_attempt +1]
Original file line number Diff line number Diff line change @@ -40,26 +40,22 @@ while true; do
40
40
esac
41
41
done
42
42
43
- stopcmd =" run_with_sudo snap stop ${SNAP_NAME} --disable "
43
+ prefix_cmd =" run_with_sudo snap"
44
44
if is_strict
45
45
then
46
- stopcmd =" snapctl stop microk8s.daemon-kubelite --disable "
46
+ prefix_cmd =" snapctl"
47
47
fi
48
48
49
- $stopcmd
49
+ $prefix_cmd stop microk8s.daemon-kubelite --disable
50
50
stop_status=$?
51
51
52
52
if ! [ $stop_status -eq 0 ]
53
53
then
54
54
echo ' Failed to stop microk8s services. Check snapd logs with "journalctl -u snapd.service"'
55
55
exit 1
56
56
else
57
- if is_strict
58
- then
59
- remove_all_containers
60
- snapctl stop microk8s --disable
61
- else
62
- kill_all_container_shims
63
- fi
57
+ remove_all_containers
58
+ kill_all_container_shims
59
+ $prefix_cmd stop microk8s --disable
64
60
run_with_sudo touch ${SNAP_DATA} /var/lock/stopped.lock
65
61
fi
Original file line number Diff line number Diff line change @@ -7,6 +7,15 @@ use_snap_env
7
7
8
8
snapctl stop ${SNAP_NAME} .daemon-kubelite 2>&1 || true
9
9
10
+ # Temporarily start containerd so we can stop and kill all the microk8s containers.
11
+ snapctl start ${SNAP_NAME} .daemon-containerd 2>&1 || true
12
+ # wait for containerd to start.
13
+ sleep 5
14
+
15
+ # Remove any lingering containers and shims.
16
+ remove_all_containers
17
+ kill_all_container_shims
18
+
10
19
# Try to symlink /var/lib/kubelet so that most kubelet device plugins work out of the box.
11
20
if test -L /var/lib/kubelet; then
12
21
unlink /var/lib/kubelet || true
Original file line number Diff line number Diff line change 7
7
sh
8
8
jsonschema == 4.0.0
9
9
pdbpp
10
+ psutil
10
11
netifaces
11
12
requests
Original file line number Diff line number Diff line change 3
3
import requests
4
4
import os .path
5
5
6
+ import utils
7
+
6
8
7
9
class TestSimple (object ):
8
10
def test_microk8s_nodes_ready (self ):
@@ -132,3 +134,17 @@ def test_microk8s_services_running(self):
132
134
133
135
# Verify that all node services are running
134
136
assert running_node_services == set (node_services ), "Not all node services are running"
137
+
138
+ def test_microk8s_stop_start (self ):
139
+ coredns_procs = utils ._get_process ("coredns" )
140
+ assert len (coredns_procs ) > 0 , "Expected to find a coredns process running."
141
+
142
+ utils .run_until_success ("/snap/bin/microk8s.stop" , timeout_insec = 180 )
143
+
144
+ new_coredns_procs = utils ._get_process ("coredns" )
145
+ assert len (new_coredns_procs ) == 0 , "coredns found still running after microk8s stop."
146
+
147
+ utils .run_until_success ("/snap/bin/microk8s.start" , timeout_insec = 180 )
148
+
149
+ new_coredns_procs = utils ._get_process ("coredns" )
150
+ assert len (new_coredns_procs ) > 0 , "Expected to find a new coredns process running."
Original file line number Diff line number Diff line change 20
20
is_container ,
21
21
is_ipv6_configured ,
22
22
kubectl ,
23
+ _get_process ,
23
24
)
24
25
25
26
upgrade_from = os .environ .get ("UPGRADE_MICROK8S_FROM" , "beta" )
@@ -162,3 +163,5 @@ def test_upgrade(self):
162
163
if not is_container ():
163
164
# On lxc umount docker overlay is not permitted.
164
165
check_call ("sudo snap remove microk8s" .split ())
166
+ coredns_procs = _get_process ("coredns" )
167
+ assert len (coredns_procs ) == 0 , "Expected to have 0 coredns processes running."
Original file line number Diff line number Diff line change 3
3
import time
4
4
import yaml
5
5
import platform
6
+ import psutil
6
7
from subprocess import check_output , CalledProcessError , check_call
7
8
8
9
@@ -270,3 +271,7 @@ def is_ipv6_configured():
270
271
return b"inet6" in output
271
272
except CalledProcessError :
272
273
return False
274
+
275
+
276
+ def _get_process (name ):
277
+ return [p for p in psutil .process_iter () if name == p .name ()]
You can’t perform that action at this time.
0 commit comments