Skip to content

Commit 3223749

Browse files
Added strict checks, LANG exports and combined strict/classic logic for reset, stop, start (#3201)
1 parent eb86b24 commit 3223749

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

microk8s-resources/wrappers/microk8s-reset.wrapper

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH"
66
ARCH="$($SNAP/bin/uname -m)"
77
export IN_SNAP_LD_LIBRARY_PATH="$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/$ARCH-linux-gnu:$SNAP/usr/lib/$ARCH-linux-gnu"
88
export PYTHONNOUSERSITE=false
9+
export LC_ALL="${LC_ALL:-C.UTF-8}"
10+
export LANG="${LANG:-C.UTF-8}"
911

1012
LD_LIBRARY_PATH=$IN_SNAP_LD_LIBRARY_PATH ${SNAP}/usr/bin/python3 ${SNAP}/scripts/wrappers/reset.py $@

microk8s-resources/wrappers/microk8s-start.wrapper

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ then
1212
exit 0
1313
fi
1414

15+
exit_if_not_root
1516
exit_if_no_permissions
1617

1718
PARSED=$(getopt --options=lho: --longoptions=help,output:,disable-low-memory-guard --name "$@" -- "$@")
@@ -44,7 +45,8 @@ done
4445

4546
exit_if_low_memory_guard
4647

47-
if ! run_with_sudo snap start ${SNAP_NAME} --enable
48+
49+
if ! run_with_sudo preserve_env snapctl start ${SNAP_NAME} --enable
4850
then
4951
echo 'Failed to start microk8s services. Check snapd logs with "journalctl -u snapd.service"'
5052
exit 1

microk8s-resources/wrappers/microk8s-stop.wrapper

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ then
1313
exit 0
1414
fi
1515

16+
exit_if_not_root
1617
exit_if_no_permissions
1718

1819
FORCE=false
@@ -39,11 +40,26 @@ while true; do
3940
esac
4041
done
4142

42-
if ! run_with_sudo snap stop ${SNAP_NAME} --disable
43+
stopcmd="run_with_sudo snap stop ${SNAP_NAME} --disable"
44+
if is_strict
45+
then
46+
stopcmd="snapctl stop microk8s.daemon-kubelite --disable"
47+
fi
48+
49+
$stopcmd
50+
stop_status=$?
51+
52+
if ! [ $stop_status -eq 0 ]
4353
then
4454
echo 'Failed to stop microk8s services. Check snapd logs with "journalctl -u snapd.service"'
4555
exit 1
4656
else
47-
kill_all_container_shims
57+
if is_strict
58+
then
59+
remove_all_containers
60+
snapctl stop microk8s --disable
61+
else
62+
kill_all_container_shims
63+
fi
4864
run_with_sudo touch ${SNAP_DATA}/var/lock/stopped.lock
4965
fi

0 commit comments

Comments
 (0)