-
Notifications
You must be signed in to change notification settings - Fork 354
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-test-linux_rootfs_propagation #3024
base: main
Are you sure you want to change the base?
Conversation
I'm not sure if this is related, but this issue might be relevant: |
Hey, thanks for the PR! I will try to take a look soon. In the meantime, can you rebase on main and fix the conflicts? Thanks! |
Signed-off-by: Yusuke Sakurai <yusuke.sakurai@3-shake.com>
2979c20
to
c87a97e
Compare
It appears not to pass CI. May I ask you to check it? |
When I run
I also checked the following issue, but I'm not sure if it's related: I will continue investigating this on my side, but I would appreciate any advice you could provide. |
@saku3 Let me make sure the premise that runtime-tools only tests if the container comes up with |
@utam0k However, I am struggling because only Below are the results of my investigation. InvestigationInvestigation ApproachI manually created a container using the I added the following code to output the generated JSON configuration: println!(
"Spec contents as JSON: {}",
serde_json::to_string_pretty(&spec).unwrap()
); The output result is as follows. Click to expand code
Manual Execution of the Above Integration Testmkdir -p tutorial/rootfs
cd tutorial
docker export $(docker create busybox) | tar -C rootfs -xvf -
# Use the config.json output from the above test
# However, modify args to `sleep 300`
touch tutorial/config.json
./youki create -b tutorial youki
# Check the PID
# 1. Create the target directory
TARGET_DIR=$(mktemp -d -t target-XXXXXX)
echo "Created target directory: $TARGET_DIR"
# Bind-mount the root
mount --bind / $TARGET_DIR
# 2. Create a test mount directory and file
MOUNT_DIR=$(mktemp -d -t mount-XXXXXX)
TEST_DIR=$(mktemp -d -t test-XXXXXX)
echo "Created mount directory: $MOUNT_DIR"
echo "Created test directory: $TEST_DIR"
TMPFILE="$TEST_DIR/example"
touch "$TMPFILE"
echo "Created test file: $TMPFILE"
# 3. Bind-mount the test directory to another directory
mount --bind "$TEST_DIR" "$MOUNT_DIR"
echo "Bound $TEST_DIR to $MOUNT_DIR"
# 4. Check the file path inside the target directory
TARGET_FILE="$TARGET_DIR/$(echo $MOUNT_DIR | sed 's#^/##')/example"
ls $TARGET_FILE Similarly, I executed the same test using runc and crun. ResultsIn the case of youki
./youki create -b tutorial/ youki
./youki list
DEBUG youki: started by user 0 with ArgsOs { inner: ["./youki", "list"] }
ID PID STATUS BUNDLE CREATED CREATOR
youki 20927 Created /var/snap/amazon-ssm-agent/9881/youki/tutorial 2025-02-03T23:04:42+00:00 root
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# PID=20927
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# nsenter --target $PID --mount --uts --ipc --net --pid sh
/ # TARGET_DIR=$(mktemp -d -t target-XXXXXX)
/ # echo "Created target directory: $TARGET_DIR"
Created target directory: /tmp/target-zow2pU
/ # mount --bind / $TARGET_DIR
/ # MOUNT_DIR=$(mktemp -d -t mount-XXXXXX)
/ # TEST_DIR=$(mktemp -d -t test-XXXXXX)
/ # echo "Created mount directory: $MOUNT_DIR"
Created mount directory: /tmp/mount-VDjxd0
/ # echo "Created test directory: $TEST_DIR"
Created test directory: /tmp/test-JPQr2e
/ # TMPFILE="$TEST_DIR/example"
/ # touch "$TMPFILE"
/ # echo "Created test file: $TMPFILE"
Created test file: /tmp/test-JPQr2e/example
/ # mount --bind "$TEST_DIR" "$MOUNT_DIR"
/ # echo "Bound $TEST_DIR to $MOUNT_DIR"
Bound /tmp/test-JPQr2e to /tmp/mount-VDjxd0
/ # TARGET_FILE="$TARGET_DIR/$(echo $MOUNT_DIR | sed 's#^/##')/example"
/ #
/ # ls $TARGET_FILE
/tmp/target-zow2pU/tmp/mount-VDjxd0/example In the case of crun
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# crun create -b tutorial/ crun
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# crun list
NAME PID STATUS BUNDLE PATH CREATED OWNER
crun 20957 created /var/snap/amazon-ssm-agent/9881/youki/tutorial 2025-02-03T23:08:14.510045Z root
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# PID=20957
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# nsenter --target $PID --mount --uts --ipc --net --pid sh
/ # TARGET_DIR=$(mktemp -d -t target-XXXXXX)
/ # echo "Created target directory: $TARGET_DIR"
Created target directory: /tmp/target-SOD8P2
/ # mount --bind / $TARGET_DIR
/ # MOUNT_DIR=$(mktemp -d -t mount-XXXXXX)
/ # TEST_DIR=$(mktemp -d -t test-XXXXXX)
/ # echo "Created mount directory: $MOUNT_DIR"
Created mount directory: /tmp/mount-72pCxu
/ # echo "Created test directory: $TEST_DIR"
Created test directory: /tmp/test-g0fhU1
/ # TMPFILE="$TEST_DIR/example"
/ # touch "$TMPFILE"
/ # echo "Created test file: $TMPFILE"
Created test file: /tmp/test-g0fhU1/example
/ # mount --bind "$TEST_DIR" "$MOUNT_DIR"
/ # echo "Bound $TEST_DIR to $MOUNT_DIR"
Bound /tmp/test-g0fhU1 to /tmp/mount-72pCxu
/ # TARGET_FILE="$TARGET_DIR/$(echo $MOUNT_DIR | sed 's#^/##')/example"
/ #
/ # ls $TARGET_FILE
/tmp/target-SOD8P2/tmp/mount-72pCxu/example In the case of runc
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# runc create -b tutorial runc
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# runc list
ID PID STATUS BUNDLE CREATED OWNER
runc 20992 created /var/snap/amazon-ssm-agent/9881/youki/tutorial 2025-02-03T23:10:27.269997132Z root
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# PID=20992
root@ip-172-31-11-229:/var/snap/amazon-ssm-agent/9881/youki# nsenter --target $PID --mount --uts --ipc --net --pid sh
/ # TARGET_DIR=$(mktemp -d -t target-XXXXXX)
/ # echo "Created target directory: $TARGET_DIR"
Created target directory: /tmp/target-NO1xUG
/ # mount --bind / $TARGET_DIR
/ # MOUNT_DIR=$(mktemp -d -t mount-XXXXXX)
/ # TEST_DIR=$(mktemp -d -t test-XXXXXX)
/ # echo "Created mount directory: $MOUNT_DIR"
Created mount directory: /tmp/mount-1U0CTR
/ # echo "Created test directory: $TEST_DIR"
Created test directory: /tmp/test-bb90sL
/ # TMPFILE="$TEST_DIR/example"
/ # touch "$TMPFILE"
/ # echo "Created test file: $TMPFILE"
Created test file: /tmp/test-bb90sL/example
/ # mount --bind "$TEST_DIR" "$MOUNT_DIR"
/ # echo "Bound $TEST_DIR to $MOUNT_DIR"
Bound /tmp/test-bb90sL to /tmp/mount-1U0CTR
/ # TARGET_FILE="$TARGET_DIR/$(echo $MOUNT_DIR | sed 's#^/##')/example"
/ #
/ # ls $TARGET_FILE
ls: /tmp/target-NO1xUG/tmp/mount-1U0CTR/example: No such file or directory Additionally, I checked the rootfs propagation information using In the case of youkiThe 7th field in the corresponding line is cat /proc/20927/mountinfo
361 262 259:1 /var/snap/amazon-ssm-agent/9881/youki/tutorial/rootfs / rw,relatime shared:343 - ext4 /dev/root rw,discard,errors=remount-ro,commit=30 In the case of crunSimilar to youki, the 7th field is also cat /proc/20957/mountinfo
352 112 259:1 /var/snap/amazon-ssm-agent/9881/youki/tutorial/rootfs / rw,relatime shared:342 - ext4 /dev/root rw,discard,errors=remount-ro,commit=30 In the case of runcThe 7th field is cat /proc/20992/mountinfo
292 119 259:1 /var/snap/amazon-ssm-agent/9881/youki/tutorial/rootfs / rw,relatime - ext4 /dev/root rw,discard,errors=remount-ro,commit=30 This suggests that runc does not have shared mount propagation enabled, whereas youki and crun do.
|
@saku3 Your investigation is incredible. How about reporting the findings to the runc team? |
Maybe |
This implements the validation linux_rootfs_propagation in #361