Skip to content

Commit c792a24

Browse files
ktsakalozosberkayoz
authored andcommitted
Strict patch
1 parent 3223749 commit c792a24

File tree

61 files changed

+920
-240
lines changed

Some content is hidden

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

61 files changed

+920
-240
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-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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ then
2323
exit 1
2424
fi
2525

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

microk8s-resources/wrappers/microk8s-start.wrapper

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ then
5252
exit 1
5353
else
5454
start_all_containers
55-
if run_with_sudo test -e ${SNAP_DATA}/var/lock/stopped.lock
55+
if test -e ${SNAP_DATA}/var/lock/stopped.lock
5656
then
5757
# Mark the api server as starting
58-
run_with_sudo rm ${SNAP_DATA}/var/lock/stopped.lock &> /dev/null
58+
rm ${SNAP_DATA}/var/lock/stopped.lock &> /dev/null
5959
fi
6060
fi
6161

microk8s-resources/wrappers/microk8s.wrapper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if [ -f "${SNAP}/microk8s-${APP}.wrapper" ]; then
2929
"${SNAP}/microk8s-${APP}.wrapper" "$@"
3030
readonly EXIT="$?"
3131
elif [ "${APP}" == "inspect" ]; then
32-
sudo SNAP_DATA=${SNAP_DATA} ${SNAP}/inspect.sh "$@"
32+
SNAP_DATA=${SNAP_DATA} ${SNAP}/inspect.sh "$@"
3333
readonly EXIT="$?"
3434
elif [ "${APP}" == "help" ] || [ "${APP}" == "--help" ] || [ "$APP" == "-h" ]; then
3535
help

microk8s-resources/wrappers/run-flanneld-with-args

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,4 @@ fi
4444

4545
# This is really the only way I could find to get the args passed in correctly.
4646
declare -a args="($(cat $SNAP_DATA/args/flanneld))"
47-
export CORE_LD_LIBRARY_PATH="$SNAP/../../core18/current/lib/$ARCH-linux-gnu"
48-
export LD_LIBRARY_PATH="$CORE_LD_LIBRARY_PATH:$LD_LIBRARY_PATH"
4947
exec "$SNAP_DATA/opt/cni/bin/flanneld" "${args[@]}"

microk8s-resources/wrappers/run-kubelite-with-args

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,23 @@ then
7979
fi
8080

8181
#UFW configuration
82-
if ufw version &> /dev/null
83-
then
84-
ufw=$(ufw status)
85-
if echo $ufw | grep -q "Status: active" &&
86-
! [ -e ${SNAP_DATA}/var/lock/skip.ufw ]
87-
then
88-
# These succeed regardless of whether the rule exists already or not
89-
echo "Found enabled UFW: adding rules to allow in/out traffic on 'cali+' and 'vxlan.calico' devices"
90-
if ! ufw allow in on vxlan.calico ||
91-
! ufw allow out on vxlan.calico ||
92-
! ufw allow in on cali+ ||
93-
! ufw allow out on cali+
94-
then
95-
echo "Failed to update UFW rules. You may want to set them manually."
96-
fi
97-
fi
98-
fi
82+
# if ufw version &> /dev/null
83+
# then
84+
# ufw=$(ufw status)
85+
# if echo $ufw | grep -q "Status: active" &&
86+
# ! [ -e ${SNAP_DATA}/var/lock/skip.ufw ]
87+
# then
88+
# # These succeed regardless of whether the rule exists already or not
89+
# echo "Found enabled UFW: adding rules to allow in/out traffic on 'cali+' and 'vxlan.calico' devices"
90+
# if ! ufw allow in on vxlan.calico ||
91+
# ! ufw allow out on vxlan.calico ||
92+
# ! ufw allow in on cali+ ||
93+
# ! ufw allow out on cali+
94+
# then
95+
# echo "Failed to update UFW rules. You may want to set them manually."
96+
# fi
97+
# fi
98+
# fi
9999

100100
# wait for containerd socket
101101
if grep -e "--address " $SNAP_DATA/args/containerd &> /dev/null

scripts/cluster/common/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def try_set_file_permissions(file):
2121

2222
os.chmod(file, 0o660)
2323
try:
24-
shutil.chown(file, group="microk8s")
24+
shutil.chown(file, group="snap_microk8s")
2525
except LookupError:
2626
# not setting the group means only the current user can access the file
2727
pass

0 commit comments

Comments
 (0)