Skip to content

Commit

Permalink
Debian support: addressing review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Rodny Molina <[email protected]>
  • Loading branch information
rodnymolina committed Nov 13, 2020
1 parent 1368ecc commit a7113a6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 207 deletions.
52 changes: 38 additions & 14 deletions scr/sysbox
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@
# Note: normally Sysbox is installed via a distro-specific package
# which sets up the Sysbox systemd units. This script is meant as a
# quick alternative to the installer to help launch Sysbox manually
# (e.g., for testing).
# (e.g. for development & testing).
#
# Usage: ./sysbox [testing-on]
#
# Note: "testing-on" attribute is useful to launch Sysbox inside a privileged
# container. In this context Sysbox may be unable to reach certain procfs
# nodes, due to kernel not exposing them in non-init namespaces. This flag
# alerts Sysbox of the need to obviate these potential errors when running
# in testing mode.
#

# Max number of user-namespaces to configure in distros supporting this knob.
sysbox_max_user_ns=10000


# Retry a command $1 times until it succeeds. Wait $2 seconds between retries.
# (copied from runc/tests/integration/helpers.bash)
Expand All @@ -32,9 +44,9 @@ function retry() {

# Ensure that kernel-modules expected by system-level apps (running within sys
# containers) are properly loaded.
load_required_modules() {
function load_required_modules() {

# Sysbox requires 'configfs' module to ensure proper operation of containarized
# Sysbox requires 'configfs' module to ensure proper operation of containerized
# apps requiring access to kernel's config file (e.g. kubeadm).
if ! modprobe configfs &> /dev/null; then
echo "Could not load configfs kernel module. Exiting ..."
Expand All @@ -52,7 +64,7 @@ function get_host_distro() {
echo $distro
}

# Ensures unprivileged user-ns are allowed.
# Ensures unprivileged user-ns's are allowed.
function setup_userns() {

local distro=$1
Expand All @@ -62,13 +74,12 @@ function setup_userns() {
echo "1" > /proc/sys/kernel/unprivileged_userns_clone

elif [[ "${distro}" == "centos" ]] ||
[[ "${distro}" == "fedora" ]] ||
[[ "${distro}" == "redhat" ]]; then
[[ "${distro}" == "fedora" ]]; then

# Setting 10k as max user-ns value.
# Setting user-ns max value.
max_user_ns=$(</proc/sys/user/max_user_namespaces)
if [[ $max_user_ns =~ ^[0-9]+$ ]] && [[ $max_user_ns -lt 10000 ]]; then
echo "10000" > /proc/sys/user/max_user_namespaces
if [[ $max_user_ns =~ ^[0-9]+$ ]] && [[ $max_user_ns -lt $sysbox_max_user_ns ]]; then
echo $sysbox_max_user_ns > /proc/sys/user/max_user_namespaces
fi

else
Expand Down Expand Up @@ -119,6 +130,7 @@ function setup_kernel_config() {
fi
}

# Increases system-level resources to satisfy Sysbox requirements.
function setup_maxs() {

# Increase default inotify resources to meet sys container's demands.
Expand Down Expand Up @@ -163,9 +175,11 @@ function sysbox_stop() {
done
}

# Start all Sysbox components
# Start all Sysbox components.
function sysbox_start() {

local testing_mode=$1

# Start sysbox-mgr.
sysbox-mgr --log /dev/stdout > /var/log/sysbox-mgr.log 2>&1 &
RES=$(retry 10 1 grep -q Ready /var/log/sysbox-mgr.log)
Expand All @@ -177,7 +191,12 @@ function sysbox_start() {

# Start sysbox-fs.
mkdir -p /var/lib/sysboxfs
sysbox-fs --log /dev/stdout > /var/log/sysbox-fs.log 2>&1 &

if [[ $testing_mode == "testing-on" ]]; then
sysbox-fs --ignore-handler-errors --log /dev/stdout > /var/log/sysbox-fs.log 2>&1 &
else
sysbox-fs --log /dev/stdout > /var/log/sysbox-fs.log 2>&1 &
fi
RES=$(retry 10 1 grep -q Initiating /var/log/sysbox-fs.log)
if [ $? -ne 0 ]; then
printf "\nsysbox-fs failed to start. Here is the log file:\n"
Expand All @@ -186,7 +205,12 @@ function sysbox_start() {
fi
}

function main() {

sysbox_stop
sysbox_setup
sysbox_start "$@"
}

main "$@"

sysbox_stop
sysbox_setup
sysbox_start
190 changes: 0 additions & 190 deletions tests/scr/sysbox

This file was deleted.

4 changes: 2 additions & 2 deletions tests/scr/testContainerInit
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ make sysbox-local --no-print-directory && make install
# Inside the test container we start sysbox with a dedicated script
# that sets some test-specific configs
echo "Starting sysbox with test-specific options"
install -D -m0755 tests/scr/sysbox /usr/local/sbin/sysbox
sysbox
install -D -m0755 scr/sysbox /usr/local/sbin/sysbox
sysbox testing-on

2 changes: 1 addition & 1 deletion tests/sysmgr/kill.bats
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function teardown() {
if [ -n "$SB_INSTALLER" ]; then
systemctl start sysbox
else
bats_bg sysbox
bats_bg sysbox testing-on
sleep 2
fi
}

0 comments on commit a7113a6

Please sign in to comment.