Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AWS nested container fix #280

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion plans/e2e/ffi.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ adjust:

- name: Set QM env
how: shell
# FIXME: On new QM release remove
# qm-setup-from-gh-url, branch-qm option
script: |
cd tests/e2e
./set-ffi-env-e2e --qm-setup-from-gh-url=https://raw.githubusercontent.com/containers
./set-ffi-env-e2e --branch-qm=main --qm-setup-from-gh-url=https://raw.githubusercontent.com/containers --set-qm-disk-part=Y
when: scenario == ffi and distro == centos-stream-9, fedora

execute:
Expand Down
4 changes: 4 additions & 0 deletions qm.container
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Exec=/sbin/init
Network=host
PodmanArgs=--pids-limit=-1 --security-opt label=nested --security-opt unmask=all
ReadOnly=true
# FIXME: QM is failing to start podman command
# Add back once this ReadOnlyTmpfs added to quadlet
# Ref: https://github.com/containers/podman/issues/20439
VolatileTmp=true
Rootfs=${ROOTFS}

# FIXME: QM is failing to start if SecurityLabelNested is enabled.
Expand Down
6 changes: 5 additions & 1 deletion setup
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ INSTALLDIR="/usr/share/qm"
ROOTFS="/usr/lib/qm/rootfs"
RWETCFS="/etc/qm"
RWVARFS="/var/qm"
TMP_QM_IMG_DIR="tmp-img-dir"
AGENT_HOSTNAME="$(hostname)"
AGENTCONF="/etc/bluechi/agent.conf.d/agent.conf"
QM_CONTAINER_IDS=1000000000:1500000000
Expand Down Expand Up @@ -92,14 +93,17 @@ storage() {
ROOTFS=$1
if ! test -f "${ROOTFS}/etc/containers/storage.conf"; then
mkdir -p "${ROOTFS}/var/lib/shared/overlay-images" \
"${ROOTFS}/var/lib/shared/overlay-layers"
"${ROOTFS}/var/lib/shared/overlay-layers" \
"${ROOTFS}/var/${TMP_QM_IMG_DIR}"
touch "${ROOTFS}/var/lib/shared/overlay-images/images.lock" \
"${ROOTFS}/var/lib/shared/overlay-layers/layers.lock"

sed -e '/additionalimage.*/a "/var/lib/shared",' \
-e 's|^#.*transient_store.*|transient_store=true|g' \
"${ROOTFS}/usr/share/containers/storage.conf" \
> "${ROOTFS}/etc/containers/storage.conf"
sed -i "s|^#env = \[\]|env = \[\"TMPDIR=/var/${TMP_QM_IMG_DIR}\"\]|" \
"${ROOTFS}/usr/share/containers/containers.conf"
fi
}

Expand Down
20 changes: 15 additions & 5 deletions tests/e2e/set-ffi-env-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export ARCH=""
export BUILD_BLUECHI_FROM_GH_URL=""
export QM_GH_URL=""
export BRANCH_QM=""
export SET_QM_PART=""

RED='\033[91m'
GRN='\033[92m'
Expand All @@ -54,6 +55,7 @@ CLR='\033[0m'
ARGUMENT_LIST=(
"qm-setup-from-gh-url"
"branch-qm"
"set-qm-disk-part"
)

usage() {
Expand All @@ -69,6 +71,8 @@ Usage: ./set-ffi-env-e2e [OPTIONS]
--branch-qm
Specify which branch the GitHub repo will be set. Requires --qm-setup-from-gh-url

--set-qm-disk-part
Specify if disk partition neede for /var/qm needed

Examples:

Expand All @@ -79,6 +83,7 @@ Examples:
./set-ffi-env-e2e \\
--branch-qm=superfeature \\
--qm-setup-from-gh-url=https://raw.githubusercontent.com/MYUSER/ \\
--set-qm-disk-part=Y \\

EOF
exit 0
Expand All @@ -105,7 +110,12 @@ while [ $# -gt 0 ]; do
if [ -z "${BRANCH_QM}" ]; then
BRANCH_QM="main"
fi
#QM_GH_URL="${2}/qm/${BRANCH_QM}/setup"
QM_GH_URL="${2}/qm/${BRANCH_QM}/setup"
shift 2
;;

--set-qm-disk-part)
SET_QM_PART="${2}"
shift 2
;;

Expand All @@ -129,7 +139,7 @@ create_qm_disks() {
mkdir /var/qm
for disk in $disks_arr; do
if [[ ${disk} == "vda" || \
$(echo "${disk_table}" | grep -c "${disk}" ) -eq 1 ]];then
$(echo "${disk_table}" | grep -c "${disk}" ) -eq 1 && ${disk} != "zram0" ]];then
Yarboa marked this conversation as resolved.
Show resolved Hide resolved
new_part="$( (echo n; echo p; echo ; echo ; echo ; echo w) | fdisk "/dev/${disk}")"
part_id="$(echo "${new_part}" | grep -Po "new partition \K([0-9])")"
if [[ $(echo "${disk}" | grep -c nvme) -eq 1 ]]; then
Expand All @@ -146,7 +156,6 @@ install_qm_rpms() {

info_message "Installing qm setup rpm"
ARCH=$(arch)
dnf update -y
dnf install -y 'dnf-command(config-manager)'
dnf config-manager --set-enabled crb
dnf copr enable -y @centos-automotive-sig/bluechi-snapshot centos-stream-9-"${ARCH}"
Expand Down Expand Up @@ -185,7 +194,6 @@ EOF
systemctl start bluechi-agent
# Restart qm to read lates bluechi-agent.conf
systemctl restart qm

}

info_message "Starting setup"
Expand All @@ -204,7 +212,9 @@ info_message "Preparing QM environment"
info_message "=============================="

# Creates the QM env on VM
create_qm_disks
if [ -n "${SET_QM_PART}" ]; then
create_qm_disks
fi
install_qm_rpms
setup_qm_services

Expand Down
10 changes: 8 additions & 2 deletions tests/ffi/common/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ prepare_test() {
if_error_exit "cannot create temp dir under /tmp/"
exec_cmd "cp ${qm_service_file} ${qm_service_backup}"
# Remove 'DropCapability=sys_resource' enable nested container in QM
exec_cmd "sed -i 's/DropCapability=sys_resource/#DropCapability=sys_resource/' \
/etc/containers/systemd/qm.container"
exec_cmd "sed -i 's|DropCapability=sys_resource|#DropCapability=sys_resource|' \
${qm_service_file}"
# FIXME: QM is failing to start podman command
# Add back once this ReadOnlyTmpfs added to quadlet
# Ref: https://github.com/containers/podman/issues/20439
if ! grep "Volatile" "${qm_service_file}" ; then
exec_cmd "sed -i 's|ReadOnly=true|&\nVolatileTmp=true|' ${qm_service_file}"
fi
}

disk_cleanup() {
Expand Down
11 changes: 6 additions & 5 deletions tests/ffi/disk/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ disk_cleanup
prepare_test
reload_config

podman exec -it qm /bin/bash -c \
"podman run -d --replace --name ffi-qm quay.io/centos-sig-automotive/ffi-tools:latest \
tail -f /dev/null"
exec_cmd "podman exec -it qm /bin/bash -c \
'podman run -d --replace --name ffi-qm \
quay.io/centos-sig-automotive/ffi-tools:latest \
tail -f /dev/null'"

podman exec -it qm /bin/bash -c \
"podman exec -it ffi-qm ./QM/file-allocate > /dev/null"
exec_cmd "podman exec -it qm /bin/bash -c \
'podman exec -it ffi-qm ./QM/file-allocate > /dev/null'"

if ! eval "fallocate -l 2G /root/file.lock" ; then
echo "No space left on device"
Expand Down