Skip to content

Commit

Permalink
Strict patch
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsakalozos authored and berkayoz committed Jun 14, 2022
1 parent 4711817 commit af9a253
Show file tree
Hide file tree
Showing 15 changed files with 741 additions and 101 deletions.
87 changes: 74 additions & 13 deletions .github/workflows/build-snap.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
name: Build MicroK8s snap on PR and push to master

on:
push:
branches:
- master
pull_request:
branches:
- master
- push
- pull_request

### While we work on the strict feature we want the tests to run even if we do put PRs against the master.
### When this work get merged into master the following should be commented in.
# push:
# branches:
# - master
# pull_request:
# branches:
# - master

jobs:
build:
Expand Down Expand Up @@ -43,24 +48,80 @@ jobs:
- name: Running upgrade path test
run: |
set -x
sudo -E UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=`pwd`/`ls microk8s*.snap` pytest -s ./tests/test-upgrade-path.py
sudo snap remove microk8s --purge
- name: Running addons tests
# Remove the snapd refresh as soon as v2.52 lands
sudo snap refresh snapd --channel=latest/edge
- name: Check branches
run: |
set -x
(cd tests; pytest -s verify-branches.py)
- name: Running addons tests in strict mode
run: |
set -x
sudo snap install *.snap --classic --dangerous
sudo snap install microk8s.snap --dangerous
sudo ./tests/connect-all-interfaces.sh
./tests/smoke-test.sh
export UNDER_TIME_PRESSURE="True"
export SKIP_OPENEBS="True"
export SKIP_PROMETHEUS="False"
(cd tests; pytest -s verify-branches.py)
sudo -E bash -c "cd /var/snap/microk8s/common/addons/core/tests; pytest -s -ra test-addons.py"
sudo microk8s enable community
sudo -E bash -c "cd /var/snap/microk8s/common/addons/community/tests; pytest -s -ra test-addons.py"
grep -Po "Report tarball is at \K.+" |
sudo xargs -I {} mv {} inspection-report-strict-${{ strategy.job-index }}.tar.gz
sudo snap remove microk8s --purge
- name: Running upgrade tests
sudo rm -rf $HOME/.kube
sudo rm -rf $HOME/.config/helm
sudo dmesg | grep 'apparmor="DENIED"' > ./denials-${{ strategy.job-index }}.log
- name: Upload strict inspect tarball
uses: actions/upload-artifact@v2
with:
name: inspection-report-strict-actions
path: ./inspection-report-strict-${{ strategy.job-index }}.tar.gz
- name: Upload AppArmor denials
uses: actions/upload-artifact@v2
with:
name: apparmor-denials
path: ./denials-${{ strategy.job-index }}.log
- name: Running addons tests in devmode
run: |
set -x
sudo snap install *.snap --classic --dangerous
################ Until devmode of docker-support is fixed we skip this part of the tests #######
exit 0
sudo snap install microk8s.snap --devmode --dangerous
sudo ./tests/connect-all-interfaces.sh
./tests/smoke-test.sh
export UNDER_TIME_PRESSURE="True"
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"
export SKIP_OPENEBS="False"
export SKIP_PROMETHEUS="False"
(cd tests; sudo -E pytest -s -ra test-addons.py)
sudo microk8s inspect |
grep -Po "Report tarball is at \K.+" |
sudo xargs -I {} mv {} inspection-report-devmode-${{ strategy.job-index }}.tar.gz
sudo snap remove microk8s --purge
- name: Upload devmode inspect tarball
uses: actions/upload-artifact@v2
with:
name: inspection-report-devmode-actions
path: ./inspection-report-devmode-${{ strategy.job-index }}.tar.gz
- name: Generate AppArmor on failure
run: sudo dmesg | grep 'apparmor="DENIED"' > ./denials-${{ strategy.job-index }}.log
if: failure()
- name: Upload AppArmor denials failure
uses: actions/upload-artifact@v2
with:
name: apparmor-denials
path: ./denials-${{ strategy.job-index }}.log
if: failure()
- name: Generate inspect tarball
run: >
sudo microk8s inspect |
grep -Po "Report tarball is at \K.+" |
sudo xargs -I {} mv {} inspection-report-fail-${{ strategy.job-index }}.tar.gz
if: failure()
- name: Upload inspect tarball
uses: actions/upload-artifact@v2
with:
name: inspection-report-actions
path: ./inspection-report-fail-${{ strategy.job-index }}.tar.gz
if: failure()
9 changes: 8 additions & 1 deletion docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@ lxc file pull test-build/root/microk8s/microk8s_v1.9.6_amd64.snap .
After copying it, you can install it with:

```shell
snap install microk8s_*_amd64.snap --classic --dangerous
sudo snap install microk8s_latest_amd64.snap --dangerous
```

Finally, you need to connect the interfaces. To this end you can use the `connect-all-interfaces.sh` under the `tests` directory:

```shell
sudo tests/connect-all-interfaces.sh
```


## Assembling the Calico CNI manifest

The calico CNI manifest can be found under `upgrade-scripts/000-switch-to-calico/resources/calico.yaml`.
Expand Down
1 change: 1 addition & 0 deletions microk8s-resources/default-args/kubelet
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--client-ca-file=${SNAP_DATA}/certs/ca.crt
--anonymous-auth=false
--root-dir=${SNAP_COMMON}/var/lib/kubelet
--log-dir=${SNAP_COMMON}/var/log
--fail-swap-on=false
--feature-gates=DevicePlugins=true
--eviction-hard="memory.available<100Mi,nodefs.available<1Gi,imagefs.available<1Gi"
Expand Down
2 changes: 1 addition & 1 deletion scripts/cluster/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def try_set_file_permissions(file):

os.chmod(file, 0o660)
try:
shutil.chown(file, group="microk8s")
shutil.chown(file, group="snap_microk8s")
except LookupError:
# not setting the group means only the current user can access the file
pass
Expand Down
16 changes: 8 additions & 8 deletions scripts/inspect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ function suggest_fixes {
content+=' sudo ufw allow in on cali+ && sudo ufw allow out on cali+\n'
fi

if [[ ! -z "$content" ]]
then
echo printing
printf -- "$header"
printf -- "$content"
fi
fi
fi
# if [[ ! -z "$content" ]]
# then
# echo printing
# printf -- "$header"
# printf -- "$content"
# fi
# fi
# fi

# check for selinux. if enabled, print warning.
if getenforce 2>&1 | grep 'Enabled' > /dev/null
Expand Down
6 changes: 6 additions & 0 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

set -eux

if [ ! -f "${SNAP_DATA}/var/lock/installed.lock" ]
then
exit 0
fi

source $SNAP/actions/common/utils.sh

if [ ! -f "${SNAP_DATA}/var/lock/installed.lock" ]
Expand Down Expand Up @@ -685,3 +690,4 @@ then
fi
fi
fi

1 change: 0 additions & 1 deletion snap/hooks/remove
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ then
else
snapctl stop ${SNAP_NAME}.daemon-kubelet 2>&1 || true
fi
snapctl stop ${SNAP_NAME}.daemon-docker 2>&1 || true

# Sym link the host's /var/lib/kubelet to the Snap's. This will be fixed with layouts when
# this Snap is strictly confined.
Expand Down
Loading

0 comments on commit af9a253

Please sign in to comment.