Skip to content

Commit 581832b

Browse files
ktsakalozosberkayoz
authored andcommitted
Strict patch
1 parent cdba6a7 commit 581832b

File tree

68 files changed

+951
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+951
-245
lines changed

.github/workflows/build-snap.yml

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
name: Build MicroK8s snap on PR and push to master
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
branches:
9-
- master
4+
- push
5+
- pull_request
6+
7+
### While we work on the strict feature we want the tests to run even if we do put PRs against the master.
8+
### When this work get merged into master the following should be commented in.
9+
# push:
10+
# branches:
11+
# - master
12+
# pull_request:
13+
# branches:
14+
# - master
1015

1116
jobs:
1217
build:
@@ -43,24 +48,80 @@ jobs:
4348
- name: Running upgrade path test
4449
run: |
4550
set -x
46-
sudo -E UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=`pwd`/`ls microk8s*.snap` pytest -s ./tests/test-upgrade-path.py
47-
sudo snap remove microk8s --purge
48-
- name: Running addons tests
51+
# Remove the snapd refresh as soon as v2.52 lands
52+
sudo snap refresh snapd --channel=latest/edge
53+
- name: Check branches
54+
run: |
55+
set -x
56+
(cd tests; pytest -s verify-branches.py)
57+
- name: Running addons tests in strict mode
4958
run: |
5059
set -x
51-
sudo snap install *.snap --classic --dangerous
60+
sudo snap install microk8s.snap --dangerous
61+
sudo ./tests/connect-all-interfaces.sh
5262
./tests/smoke-test.sh
5363
export UNDER_TIME_PRESSURE="True"
64+
export SKIP_OPENEBS="True"
5465
export SKIP_PROMETHEUS="False"
5566
(cd tests; pytest -s verify-branches.py)
5667
sudo -E bash -c "cd /var/snap/microk8s/common/addons/core/tests; pytest -s -ra test-addons.py"
5768
sudo microk8s enable community
5869
sudo -E bash -c "cd /var/snap/microk8s/common/addons/community/tests; pytest -s -ra test-addons.py"
70+
grep -Po "Report tarball is at \K.+" |
71+
sudo xargs -I {} mv {} inspection-report-strict-${{ strategy.job-index }}.tar.gz
5972
sudo snap remove microk8s --purge
60-
- name: Running upgrade tests
73+
sudo rm -rf $HOME/.kube
74+
sudo rm -rf $HOME/.config/helm
75+
sudo dmesg | grep 'apparmor="DENIED"' > ./denials-${{ strategy.job-index }}.log
76+
- name: Upload strict inspect tarball
77+
uses: actions/upload-artifact@v2
78+
with:
79+
name: inspection-report-strict-actions
80+
path: ./inspection-report-strict-${{ strategy.job-index }}.tar.gz
81+
- name: Upload AppArmor denials
82+
uses: actions/upload-artifact@v2
83+
with:
84+
name: apparmor-denials
85+
path: ./denials-${{ strategy.job-index }}.log
86+
- name: Running addons tests in devmode
6187
run: |
6288
set -x
63-
sudo snap install *.snap --classic --dangerous
89+
################ Until devmode of docker-support is fixed we skip this part of the tests #######
90+
exit 0
91+
sudo snap install microk8s.snap --devmode --dangerous
92+
sudo ./tests/connect-all-interfaces.sh
93+
./tests/smoke-test.sh
6494
export UNDER_TIME_PRESSURE="True"
65-
sudo -E bash -c "cd /var/snap/microk8s/common/addons/core/ ; UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=`pwd`/`ls microk8s*.snap` pytest -s ./tests/test-upgrade.py"
95+
export SKIP_OPENEBS="False"
96+
export SKIP_PROMETHEUS="False"
97+
(cd tests; sudo -E pytest -s -ra test-addons.py)
98+
sudo microk8s inspect |
99+
grep -Po "Report tarball is at \K.+" |
100+
sudo xargs -I {} mv {} inspection-report-devmode-${{ strategy.job-index }}.tar.gz
66101
sudo snap remove microk8s --purge
102+
- name: Upload devmode inspect tarball
103+
uses: actions/upload-artifact@v2
104+
with:
105+
name: inspection-report-devmode-actions
106+
path: ./inspection-report-devmode-${{ strategy.job-index }}.tar.gz
107+
- name: Generate AppArmor on failure
108+
run: sudo dmesg | grep 'apparmor="DENIED"' > ./denials-${{ strategy.job-index }}.log
109+
if: failure()
110+
- name: Upload AppArmor denials failure
111+
uses: actions/upload-artifact@v2
112+
with:
113+
name: apparmor-denials
114+
path: ./denials-${{ strategy.job-index }}.log
115+
if: failure()
116+
- name: Generate inspect tarball
117+
run: >
118+
sudo microk8s inspect |
119+
grep -Po "Report tarball is at \K.+" |
120+
sudo xargs -I {} mv {} inspection-report-fail-${{ strategy.job-index }}.tar.gz
121+
if: failure()
122+
- name: Upload inspect tarball
123+
uses: actions/upload-artifact@v2
124+
with:
125+
name: inspection-report-actions
126+
path: ./inspection-report-fail-${{ strategy.job-index }}.tar.gz
127+
if: failure()

docs/build.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,16 @@ lxc file pull test-build/root/microk8s/microk8s_v1.9.6_amd64.snap .
8383
After copying it, you can install it with:
8484

8585
```shell
86-
snap install microk8s_*_amd64.snap --classic --dangerous
86+
sudo snap install microk8s_latest_amd64.snap --dangerous
8787
```
8888

89+
Finally, you need to connect the interfaces. To this end you can use the `connect-all-interfaces.sh` under the `tests` directory:
90+
91+
```shell
92+
sudo tests/connect-all-interfaces.sh
93+
```
94+
95+
8996
## Assembling the Calico CNI manifest
9097

9198
The calico CNI manifest can be found under `upgrade-scripts/000-switch-to-calico/resources/calico.yaml`.

microk8s-resources/default-args/kubelet

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
--client-ca-file=${SNAP_DATA}/certs/ca.crt
44
--anonymous-auth=false
55
--root-dir=${SNAP_COMMON}/var/lib/kubelet
6+
--log-dir=${SNAP_COMMON}/var/log
67
--fail-swap-on=false
78
--feature-gates=DevicePlugins=true
89
--eviction-hard="memory.available<100Mi,nodefs.available<1Gi,imagefs.available<1Gi"

microk8s-resources/wrappers/apiservice-kicker

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ do
5959
# every 5 seconds
6060
sleep 5
6161
if [ -e "${SNAP_DATA}/var/lock/ha-cluster" ] &&
62-
getent group microk8s >/dev/null 2>&1
62+
getent group snap_microk8s >/dev/null 2>&1
6363
then
6464
chmod -R ug+rwX ${SNAP_DATA}/var/kubernetes/backend || true
65-
chgrp microk8s -R ${SNAP_DATA}/var/kubernetes/backend || true
65+
chgrp snap_microk8s -R ${SNAP_DATA}/var/kubernetes/backend || true
6666
fi
6767

6868
if ! [ -e "${SNAP_DATA}/var/lock/no-cert-reissue" ] &&
@@ -80,9 +80,8 @@ do
8080
echo "CSR change detected. Reconfiguring the kube-apiserver"
8181
rm -rf .srl
8282
snapctl stop microk8s.daemon-kubelite
83-
snapctl stop microk8s.daemon-containerd
84-
kill_all_container_shims
85-
snapctl start microk8s.daemon-containerd
83+
remove_all_containers
84+
snapctl restart microk8s.daemon-containerd
8685
snapctl start microk8s.daemon-kubelite
8786
start_all_containers
8887
restart_attempt=$[$restart_attempt+1]

microk8s-resources/wrappers/microk8s-dbctl.wrapper

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export PYTHONNOUSERSITE=false
99

1010
source $SNAP/actions/common/utils.sh
1111

12+
exit_if_not_root
13+
1214
exit_if_no_permissions
1315

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

microk8s-resources/wrappers/microk8s-disable.wrapper

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ 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}"
11+
12+
# avoid AppArmor denial in strict mode when running under sudo without -H
13+
cd "$SNAP"
914

1015
source $SNAP/actions/common/utils.sh
1116

17+
exit_if_not_root
18+
1219
exit_if_no_permissions
1320

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

microk8s-resources/wrappers/microk8s-enable.wrapper

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ 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}"
11+
12+
# avoid AppArmor denial in strict mode when running under sudo without -H
13+
cd "$SNAP"
914

1015
source $SNAP/actions/common/utils.sh
1116

17+
exit_if_not_root
18+
1219
exit_if_no_permissions
1320

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

microk8s-resources/wrappers/microk8s-join.wrapper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ fi
2222

2323
exit_if_no_permissions
2424

25-
sudo -E LD_LIBRARY_PATH=$IN_SNAP_LD_LIBRARY_PATH ${SNAP}/usr/bin/python3 ${SNAP}/scripts/cluster/join.py $@
25+
LD_LIBRARY_PATH=$IN_SNAP_LD_LIBRARY_PATH ${SNAP}/usr/bin/python3 ${SNAP}/scripts/cluster/join.py $@

microk8s-resources/wrappers/microk8s-kubectl.wrapper

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fi
3030
declare -a args="($(cat $SNAP_DATA/args/kubectl))"
3131
if [ -n "${args[@]-}" ]
3232
then
33-
"${SNAP}/kubectl" "${args[@]}" "$@"
33+
EDITOR="${SNAP}/bin/nano" "${SNAP}/kubectl" "${args[@]}" "$@"
3434
else
35-
"${SNAP}/kubectl" "$@"
35+
EDITOR="${SNAP}/bin/nano" "${SNAP}/kubectl" "$@"
3636
fi

microk8s-resources/wrappers/microk8s-leave.wrapper

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export PYTHONNOUSERSITE=false
1111
source $SNAP/actions/common/utils.sh
1212

1313
exit_if_stopped
14+
exit_if_not_root
1415
exit_if_no_permissions
1516

1617
if ! [ -e ${SNAP_DATA}/var/lock/clustered.lock ] &&
@@ -20,4 +21,4 @@ then
2021
exit 1
2122
fi
2223

23-
run_with_sudo preserve_env ${SNAP}/usr/bin/python3 ${SNAP}/scripts/cluster/leave.py $@
24+
run_with_sudo ${SNAP}/usr/bin/python3 ${SNAP}/scripts/cluster/leave.py $@

0 commit comments

Comments
 (0)