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

Add fedora fix #670

Merged
merged 1 commit into from
Dec 3, 2024
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
1 change: 1 addition & 0 deletions containers.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[containers]
default_ulimits = []
default_sysctls = []

cgroup_conf=[
Expand Down
3 changes: 1 addition & 2 deletions plans/e2e/kvm-tier-0.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ discover:
filter: 'tier:0&tag:kvm'

prepare+:
#Enable copr and install rpms
- name: Expose /dev kvm to QM
- name: Enable copr and install rpms
script: |
cd tests/e2e
bash ./lib/repoutils
Expand Down
9 changes: 1 addition & 8 deletions plans/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ prepare:
order: 20
package:
- podman
- name: Remove unsupported /dev configs
how: shell
order: 60
script: |
if ! test -e /dev/kvm; then
dnf remove -y qm_mount_bind_kvm
fi

- bc

adjust:
- when: run == manual
Expand Down
9 changes: 9 additions & 0 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ echo " * agent hostname: ${AGENT_HOSTNAME}"
echo

if [ "${REMOVE_QM_ROOTFS}" == "Y" ]; then
# Unmount qm binds
qm_mounts="$(mount | grep /qm | cut -d" " -f3)"
if [ -z "$qm_mounts" ]; then
echo "No mount points found under /qm."
else
for mount in $qm_mounts; do
umount "$mount"
done
fi
# Get the one path below, i.e: /usr/lib/qm instead /usr/lib/qm/rootfs
path_qm_rootfs=$(${QM_ROOTFS_TOOL} | sed 's|/[^/]*$||')
rm -rf "${path_qm_rootfs}"
Expand Down
27 changes: 27 additions & 0 deletions tests/e2e/lib/repoutils
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,30 @@ install_qm_rpms() {

dnf install -y bluechi-ctl bluechi-agent bluechi-controller qm hostname
}

set_qm_rlimits() {
###########################################################################
# Description: #
# This function sets the QM containers.conf file to set specific resource #
# limits (rlimits) for QM containers, such as: #
# nofile (maximum open files). #
# nproc (maximum processes) #
# #
# Reference: https://github.com/containers/podman/issues/24692 #
# #
# Arguments: None #
###########################################################################
local ulimit_nofile
local ulimit_nproc
info_message "set_qm_rlimits(): prepare qm containers.conf file, update ulimits"
# Check if QM containers.conf exists
exec_cmd "test -e ${QM_CTR_CFG}"
# Calculate ulimits
ulimit_nofile=$(( $(ulimit -n) * U_NOFILE_PRCTG / 100 ))
ulimit_nproc=$(( $(ulimit -u) * U_NPROC_PRCTG / 100 ))
# Update containers.conf
exec_cmd "sed -i -E 's/(default_ulimits = \[)/\1\"nproc=$ulimit_nproc:$ulimit_nproc\",\"nofile=$ulimit_nofile:$ulimit_nofile\"/' $QM_CTR_CFG"
# Verify limits are set
info_message "fix_qm_rlimits(): verify limits are set"
exec_cmd "grep -o '\(nproc.*\",\|nofile.*\"\)' ${QM_CTR_CFG} | tr -d '\",' "
}
1 change: 1 addition & 0 deletions tests/e2e/lib/utils
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ exec_cmd() {
local cmd="$1"
eval "$cmd"
if_error_exit "Error: Command $cmd failed"
info_message "PASS: Command $cmd successful"
}

cleanup_node_services() {
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/set-ffi-env-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export QC_SOC="${QC_SOC_TYPE:-SA8775P}"
export SOC_DISTRO_FILE="${SOC_FILE:-/sys/devices/soc0/machine}"
export QC_SOC_DISK="${QC_DISK_NAME:-sde}"
export OS_DISTRO="${CS_DISTRO:-}"
export QM_CTR_CFG="${QM_CNTR_CONFIG:-/etc/qm/containers/containers.conf}"
export U_NOFILE_PRCTG=${NOFILE_RATIO:-50}
export U_NPROC_PRCTG=${NPROC_RATIO:-75}


export BUILD_BLUECHI_FROM_GH_URL=""
export QM_GH_URL=""
Expand Down Expand Up @@ -163,6 +167,8 @@ setup_qm_services() {
# Curl files into here,
# Fix: default setup:main should be removed on next qm release
/usr/share/qm/setup --hostname localrootfs
# Update QM relimits
set_qm_rlimits
cat > /etc/bluechi/controller.conf << 'EOF'
[bluechi-controller]
AllowedNodeNames=qm.localrootfs,localrootfs
Expand Down
14 changes: 4 additions & 10 deletions tests/qm-sanity-test/check_qm_podman_quadlet_is_ok.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ Exec=sleep 1000
WantedBy=multi-user.target default.target
EOF
info_message "check_qm_podman_quadlet_is_ok(): qm-sanity-test container reload & restart"
exec_cmd_with_pass_info "podman exec qm systemctl daemon-reload"
exec_cmd_with_pass_info "podman exec qm systemctl start qm-sanity-test"
exec_cmd_with_pass_info "podman exec qm systemctl status qm-sanity-test | grep -i started"
exec_cmd_with_pass_info "podman exec qm podman run fedora echo Hello QM"
exec_cmd "podman exec qm systemctl daemon-reload"
exec_cmd "podman exec qm systemctl start qm-sanity-test"
exec_cmd "podman exec qm systemctl status qm-sanity-test | grep -i started"
exec_cmd "podman exec qm podman run fedora echo Hello QM"
info_message "PASS: check_qm_podman_quadlet_is_ok()"
exit 0
}

exec_cmd_with_pass_info(){
local command="$1"
exec_cmd "${command}"
info_message "PASS: Command ${command} successful"
}

check_qm_podman_quadlet_is_ok
8 changes: 8 additions & 0 deletions tests/qm-sanity-test/check_qm_podman_ulimits_are_set.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
summary: Test podman ulimits qm are set
test: /bin/bash ./check_qm_podman_ulimits_are_set.sh
duration: 10m
tier: 0
tag: [kvm,setup]
#Need to run first for Fedora use case
order: 40
framework: shell
27 changes: 27 additions & 0 deletions tests/qm-sanity-test/check_qm_podman_ulimits_are_set.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -x

# shellcheck disable=SC1091
source ../e2e/lib/utils

U_NOFILE_PRCTG=${NOFILE_RATIO:-0.5}
U_NPROC_PRCTG=${NPROC_RATIO:-0.75}
QM_CTR_CFG=/etc/qm/containers/containers.conf

# Verify podman run and exec container inside qm with service file
check_qm_podman_ulimits_are_set(){
local ulimit_nofile
local ulimit_nproc=
info_message "check_qm_podman_ulimits_are_set(): \
prepare qm containers.conf file
refer issue #666"
info_message "check_qm_podman_ulimits_are_set(): qm-sanity-test update qm ulimits"
exec_cmd "test -e ${QM_CTR_CFG}"
ulimit_nofile=$(printf %.0f "$(echo "$(ulimit -n) * $U_NOFILE_PRCTG" | bc)")
ulimit_nproc=$(printf %.0f "$(echo "$(ulimit -u) * $U_NPROC_PRCTG" | bc)")
exec_cmd "sed -i -E 's/(default_ulimits = \[)/\1\"nproc=$ulimit_nproc:$ulimit_nproc\",\"nofile=$ulimit_nofile:$ulimit_nofile\"/' $QM_CTR_CFG"
info_message "check_qm_podman_ulimits_are_set(): qm-sanity-test verify limits are set"
exec_cmd "grep -oP \(nproc.*\",\|nofile.*\"\) ${QM_CTR_CFG} | tr -d '\t\",' "
exit 0
}

check_qm_podman_ulimits_are_set
2 changes: 1 addition & 1 deletion tests/qm-sanity-test/check_qm_setup_succeeds.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ duration: 10m
tier: 0
#Need to run first for Fedora use case
tag: [kvm,setup]
order: 40
order: 30
framework: shell
id: 310b2af2-6661-4b00-a563-67cc021e732b
Loading