Skip to content

ci: propagate RUNC_ALLOW_UNSAFE_TESTS to ssh session - #5224

Merged
kolyshkin merged 1 commit into
opencontainers:mainfrom
RedMakeUp:cirrus-unsafe-env
Apr 10, 2026
Merged

kolyshkin merged 1 commit into
opencontainers:mainfrom
RedMakeUp:cirrus-unsafe-env

Conversation

@RedMakeUp

@RedMakeUp RedMakeUp commented Apr 6, 2026 •

Copy link
Copy Markdown
Contributor

The RUNC_ALLOW_UNSAFE_TESTS variable set in the Cirrus CI env block does not reach the integration tests because they are executed via ssh -tt localhost "make ...", which starts a new login shell that does not inherit the caller's environment. As a result, unsafe tests are always skipped in Cirrus CI even though the intent is to run them.

Fix this by exporting the variable in /root/.bashrc (same way we already handle PATH), so the ssh session picks it up.

See #5212 (comment).

@RedMakeUp
RedMakeUp force-pushed the cirrus-unsafe-env branch from 052437c to 4a93d77 Compare April 6, 2026 06:29
@RedMakeUp

Copy link
Copy Markdown
Contributor Author

I've already checked the logs in CI:
ok 46 checkpoint and restore with container specific CRIU config without the # skip test requires unsafe comment,

which comfirm the RUNC_ALLOW_UNSAFE_TESTS works

@kolyshkin kolyshkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we always use integration tests via ssh, we can remove the var from the environment and add it to .bashrc directly. IOW

diff --git a/.cirrus.yml b/.cirrus.yml
index 0f845eb8..7ec3b1d6 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -15,8 +15,6 @@ task:
     BATS_VERSION: "v1.12.0"
     LIBPATHRS_VERSION: "0.2.4"
     RPMS: gcc git-core iptables jq glibc-static libseccomp-devel make criu fuse-sshfs container-selinux policycoreutils cargo lld wget
-    # Allow potentially unsafe tests.
-    RUNC_ALLOW_UNSAFE_TESTS: yes
     # yamllint disable rule:key-duplicates
     matrix:
       - DISTRO: almalinux-8
@@ -85,6 +83,8 @@ task:
     /home/runc/script/setup_rootless.sh
     # set PATH
     echo 'export PATH=/usr/local/go/bin:/usr/local/bin:$PATH' >> /root/.bashrc
+    # Allow potentially unsafe tests.
+    echo 'export RUNC_ALLOW_UNSAFE_TESTS=yes' >> /root/.bashrc
     # Setup ssh localhost for terminal emulation (script -e did not work)
     ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ""
     cat /root/.ssh/id_ed25519.pub >> /root/.ssh/authorized_keys

@kolyshkin

Copy link
Copy Markdown
Contributor

Can you please add

Fixes: 9932ad19 ("tests/int: introduce the concept of unsafe tests")

just before the Signed-off-by: line?

@kolyshkin

Copy link
Copy Markdown
Contributor

NB: we do not have this problem with rootless tests (which are also executed via ssh -tt, see tests/rootless.sh) because all unsafe tests also require root.

Comment thread .cirrus.yml Resolved
@RedMakeUp
RedMakeUp force-pushed the cirrus-unsafe-env branch 2 times, most recently from 108ee3d to 9778f89 Compare April 8, 2026 12:12
@RedMakeUp

Copy link
Copy Markdown
Contributor Author

Can you please add

Fixes: 9932ad19 ("tests/int: introduce the concept of unsafe tests")

just before the Signed-off-by: line?

Done

@RedMakeUp

Copy link
Copy Markdown
Contributor Author

Since we always use integration tests via ssh, we can remove the var from the environment and add it to .bashrc directly. IOW

diff --git a/.cirrus.yml b/.cirrus.yml
index 0f845eb8..7ec3b1d6 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -15,8 +15,6 @@ task:
     BATS_VERSION: "v1.12.0"
     LIBPATHRS_VERSION: "0.2.4"
     RPMS: gcc git-core iptables jq glibc-static libseccomp-devel make criu fuse-sshfs container-selinux policycoreutils cargo lld wget
-    # Allow potentially unsafe tests.
-    RUNC_ALLOW_UNSAFE_TESTS: yes
     # yamllint disable rule:key-duplicates
     matrix:
       - DISTRO: almalinux-8
@@ -85,6 +83,8 @@ task:
     /home/runc/script/setup_rootless.sh
     # set PATH
     echo 'export PATH=/usr/local/go/bin:/usr/local/bin:$PATH' >> /root/.bashrc
+    # Allow potentially unsafe tests.
+    echo 'export RUNC_ALLOW_UNSAFE_TESTS=yes' >> /root/.bashrc
     # Setup ssh localhost for terminal emulation (script -e did not work)
     ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ""
     cat /root/.ssh/id_ed25519.pub >> /root/.ssh/authorized_keys

Done

Comment thread .cirrus.yml Resolved

@kolyshkin kolyshkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for a minor nit about the set PATH comment being modified.

@RedMakeUp
RedMakeUp force-pushed the cirrus-unsafe-env branch from 9778f89 to 671958f Compare April 9, 2026 09:52
The RUNC_ALLOW_UNSAFE_TESTS variable set in the Cirrus CI env block
does not reach the integration tests because they are executed via
"ssh -tt localhost make ...", which starts a new login shell that
does not inherit the caller's environment. As a result, unsafe tests
are always skipped in Cirrus CI even though the intent is to run them.

Fix this by exporting the variable in /root/.bashrc (same way we
already handle PATH), so the ssh session picks it up.

See opencontainers#5212 (comment).

Fixes: 9932ad1 ("tests/int: introduce the concept of unsafe tests")
Signed-off-by: RedMakeUp <girafeeblue@gmail.com>
@RedMakeUp
RedMakeUp force-pushed the cirrus-unsafe-env branch from 671958f to 8178af4 Compare April 9, 2026 10:03
@RedMakeUp

Copy link
Copy Markdown
Contributor Author

LGTM except for a minor nit about the set PATH comment being modified.

oh, sorry about that. I've removed the unnecessary comment change.

Comment thread .cirrus.yml
unit_tests_script: |
ssh -tt localhost "make -C /home/runc localunittest"
integration_systemd_script: |
ssh -tt localhost "make -C /home/runc localintegration RUNC_USE_SYSTEMD=yes"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works and follows the existing pattern (same as how PATH is propagated), so I'm not opposed to merging it. That said, I want to flag a subtle correctness concern for future reference.

ssh -tt localhost "make ..." -- even with -tt forcing PTY allocation -- runs a non-interactive shell because a command is provided. According to bash rules, a non-interactive shell does not source ~/.bashrc. The reason this works in practice is likely that this CI environment's /root/.bash_profile sources ~/.bashrc (a common distro default).

This means the fix is environment-specific and could silently break if the base image changes or a different distro is used.

A more portable alternative would be:

# Option 1: inline the variable in the ssh command itself
ssh -tt localhost "RUNC_ALLOW_UNSAFE_TESTS=yes make ..."

# Option 2: write to .bash_profile instead of .bashrc,
# since login shells source .bash_profile, not .bashrc directly
echo 'export RUNC_ALLOW_UNSAFE_TESTS=yes' >> /root/.bash_profile

If the team is confident the CI image always sources .bashrc from .bash_profile (which is reasonable given the PATH precedent), a short comment in .cirrus.yml explaining why .bashrc is used here would help future maintainers avoid confusion.

Minor concern overall -- the fix is pragmatic and demonstrably works. Just worth documenting the assumption.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right in everything, including that most distros source ~/.bash_profile from ~/.bashrc, this is even described in bash manual:

   So, typically, your ‘~/.bash_profile’ contains the line
     if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
after (or before) any login-specific initializations.

Therefore I guess we can rely on that.

In any case, I think if PATH is not set the tests won't work (go binary missing etc).

@lifubang lifubang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, feel free to merge.

@kolyshkin
kolyshkin merged commit 23072fd into opencontainers:main Apr 10, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants