diff --git a/Makefile b/Makefile index 5a54fbe9..74af2db0 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ sysbox-runc sysbox-runc-static sysbox-runc-debug \ sysbox-fs sysbox-fs-static sysbox-fs-debug \ sysbox-mgr sysbox-mgr-static sysbox-mgr-debug \ + shiftfs-test \ sysbox-ipc \ install uninstall \ test \ @@ -73,6 +74,7 @@ SYSMGR_DIR := sysbox-mgr SYSIPC_DIR := sysbox-ipc SYSLIBS_DIR := sysbox-libs LIB_SECCOMP_DIR := $(SYSLIBS_DIR)/libseccomp-golang +SHIFTFS_TEST_DIR := shiftfs-test SYSBOX_IN_DOCKER_DIR := sysbox-in-docker PROJECT := /root/nestybox/sysbox @@ -223,12 +225,12 @@ sysbox-static: test-img $(DOCKER_SYSBOX_BLD) /bin/bash -c "export HOST_UID=$(HOST_UID) && \ export HOST_GID=$(HOST_GID) && buildContainerInit sysbox-static-local" -sysbox-local: sysbox-ipc sysbox-runc sysbox-fs sysbox-mgr +sysbox-local: sysbox-ipc sysbox-runc sysbox-fs sysbox-mgr shiftfs-test @echo $(HOSTNAME)-$(TARGET_ARCH) > .buildinfo -sysbox-debug-local: sysbox-runc-debug sysbox-fs-debug sysbox-mgr-debug +sysbox-debug-local: sysbox-runc-debug sysbox-fs-debug sysbox-mgr-debug shiftfs-test -sysbox-static-local: sysbox-runc-static sysbox-fs-static sysbox-mgr-static +sysbox-static-local: sysbox-runc-static sysbox-fs-static sysbox-mgr-static shiftfs-test sysbox-runc: $(LIBSECCOMP) sysbox-ipc @cd $(SYSRUNC_DIR) && make @@ -276,6 +278,10 @@ $(LIBSECCOMP): $(LIBSECCOMP_SRC) @chown -R $(LIBSECCOMP_UID):$(LIBSECCOMP_GID) ./sysbox-libs/libseccomp @echo "Building libseccomp completed." +shiftfs-test: + @cd $(SHIFTFS_TEST_DIR) && make + @cd $(SHIFTFS_TEST_DIR) && chown -R $(HOST_UID):$(HOST_GID) build + # # install targets (require root privileges) # @@ -286,6 +292,7 @@ install: ## Install all sysbox binaries (requires root privileges) install -D -m0755 sysbox-fs/build/$(TARGET_ARCH)/sysbox-fs $(INSTALL_DIR)/sysbox-fs install -D -m0755 sysbox-mgr/build/$(TARGET_ARCH)/sysbox-mgr $(INSTALL_DIR)/sysbox-mgr install -D -m0755 sysbox-runc/build/$(TARGET_ARCH)/sysbox-runc $(INSTALL_DIR)/sysbox-runc + install -D -m0755 shiftfs-test/build/$(TARGET_ARCH)/shiftfs-test $(INSTALL_DIR)/sysbox-shiftfs-test install -D -m0755 scr/sysbox $(INSTALL_DIR)/sysbox uninstall: ## Uninstall all sysbox binaries (requires root privileges) @@ -293,6 +300,7 @@ uninstall: ## Uninstall all sysbox binaries (requires root privileges) rm -f $(INSTALL_DIR)/sysbox-fs rm -f $(INSTALL_DIR)/sysbox-mgr rm -f $(INSTALL_DIR)/sysbox-runc + rm -f $(INSTALL_DIR)/sysbox-shiftfs-test # # Test targets @@ -613,6 +621,7 @@ gomod-tidy: @cd $(SYSRUNC_DIR) && make gomod-tidy @cd $(SYSMGR_DIR) && make gomod-tidy @cd $(SYSFS_DIR) && make gomod-tidy + @cd $(SHIFTFS_TEST_DIR) && make gomod-tidy clean: ## Eliminate sysbox binaries clean: clean-libseccomp @@ -620,6 +629,7 @@ clean: clean-libseccomp cd $(SYSFS_DIR) && make clean TARGET_ARCH=$(TARGET_ARCH) cd $(SYSMGR_DIR) && make clean TARGET_ARCH=$(TARGET_ARCH) cd $(SYSIPC_DIR) && make clean TARGET_ARCH=$(TARGET_ARCH) + cd $(SHIFTFS_TEST_DIR) && make clean TARGET_ARCH=$(TARGET_ARCH) rm -rf ./build/$(TARGET_ARCH) diff --git a/tests/scr/testContainerInit b/tests/scr/testContainerInit index 3973559b..8008b366 100755 --- a/tests/scr/testContainerInit +++ b/tests/scr/testContainerInit @@ -108,17 +108,22 @@ function cleanup_docker_env() { function crio_config() { + # NOTE: we want to run dasel < v2.0.0 as the later introduces breaking + # changes; running old versions of dasel is easiest when dasel runs inside a + # docker container. + dasel_cmd="docker run --runtime=runc --rm -v /etc/crio/crio.conf:/etc/crio/crio.conf ghcr.io/tomwright/dasel:v1.27.3" + cp /etc/crio/crio.conf /etc/crio/crio.conf.orig # Add Sysbox to CRI-O's list of runtimes - ret=$(dasel put object -f /etc/crio/crio.conf -p toml -t string -t string "crio.runtime.runtimes.sysbox-runc" \ + ret=$($dasel_cmd put object -f /etc/crio/crio.conf -p toml -t string -t string "crio.runtime.runtimes.sysbox-runc" \ "runtime_path=/usr/bin/sysbox-runc" "runtime_type=oci") if [[ $? -ne 0 ]]; then echo "Failed to configure CRI-O: $ret" exit 1 fi - ret=$(dasel put string -f /etc/crio/crio.conf -p toml "crio.runtime.runtimes.sysbox-runc.allowed_annotations.[0]" \ + ret=$($dasel_cmd put string -f /etc/crio/crio.conf -p toml "crio.runtime.runtimes.sysbox-runc.allowed_annotations.[0]" \ "io.kubernetes.cri-o.userns-mode") if [[ $? -ne 0 ]]; then echo "Failed to configure CRI-O: $ret" @@ -126,13 +131,13 @@ function crio_config() { fi # Configure CRI-O storage driver (overlayfs) - ret=$(dasel put string -f /etc/crio/crio.conf -p toml -m 'crio.storage_driver' "overlay") + ret=$($dasel_cmd put string -f /etc/crio/crio.conf -p toml -m 'crio.storage_driver' "overlay") if [[ $? -ne 0 ]]; then echo "Failed to configure CRI-O: $ret" exit 1 fi - ret=$(dasel put string -f /etc/crio/crio.conf -p toml -m 'crio.storage_option.[]' "overlay.mountopt=metacopy=on") + ret=$($dasel_cmd put string -f /etc/crio/crio.conf -p toml -m 'crio.storage_option.[]' "overlay.mountopt=metacopy=on") if [[ $? -ne 0 ]]; then echo "Failed to configure CRI-O: $ret" exit 1 @@ -140,13 +145,13 @@ function crio_config() { # If we are not using systemd, configure CRI-O with the cgroupfs driver if ! systemd_env; then - ret=$(dasel put string -f /etc/crio/crio.conf -p toml "crio.runtime.cgroup_manager" "cgroupfs") + ret=$($dasel_cmd put string -f /etc/crio/crio.conf -p toml "crio.runtime.cgroup_manager" "cgroupfs") if [[ $? -ne 0 ]]; then echo "Failed to configure CRI-O: $ret" exit 1 fi - ret=$(dasel put string -f /etc/crio/crio.conf -p toml "crio.runtime.conmon_cgroup" "pod") + ret=$($dasel_cmd put string -f /etc/crio/crio.conf -p toml "crio.runtime.conmon_cgroup" "pod") if [[ $? -ne 0 ]]; then echo "Failed to configure CRI-O: $ret" exit 1 @@ -154,13 +159,15 @@ function crio_config() { fi # Configure crictl to use CRI-O - ret=$(dasel put string -f /etc/crictl.yaml -p yaml -m '.runtime-endpoint' "unix:///var/run/crio/crio.sock") + dasel_cmd="docker run --runtime=runc --rm -v /etc/crictl.yaml:/etc/crictl.yaml ghcr.io/tomwright/dasel:v1.27.3" + + ret=$($dasel_cmd put string -f /etc/crictl.yaml -p yaml -m '.runtime-endpoint' "unix:///var/run/crio/crio.sock") if [[ $? -ne 0 ]]; then echo "Failed to configure crictl: $ret" exit 1 fi - ret=$(dasel put string -f /etc/crictl.yaml -p yaml -m '.image-endpoint' "unix:///var/run/crio/crio.sock") + ret=$($dasel_cmd put string -f /etc/crictl.yaml -p yaml -m '.image-endpoint' "unix:///var/run/crio/crio.sock") if [[ $? -ne 0 ]]; then echo "Failed to configure crictl: $ret" exit 1