Skip to content

tests/rootless.sh: fix skipping idmap tests for systemd - #5226

Merged
lifubang merged 2 commits into
opencontainers:mainfrom
kolyshkin:fix-rootless-systemd-idmap
Apr 8, 2026
Merged

lifubang merged 2 commits into
opencontainers:mainfrom
kolyshkin:fix-rootless-systemd-idmap

Conversation

@kolyshkin

Copy link
Copy Markdown
Contributor

When RUNC_USE_SYSTEMD is set, tests/rootless.sh is using

ssh -tt rootless@localhost

to run tests as rootless user. In this case, local environment is not passed to the user's ssh session (unless explicitly specified), and so the tests do not get ROOTLESS_FEATURES.

As a result we skip tests idmap-related tests when running as rootless using systemd cgroup driver, e.g.:

integration test (systemd driver)
...
[02] run rootless tests ... (idmap)
...
ok 286 runc run detached ({u,g}id != 0) # skip test requires rootless_idmap
...

Fix this.

Fixes: bf15cc9 ("cgroup v2: support rootless systemd")

@kolyshkin
kolyshkin force-pushed the fix-rootless-systemd-idmap branch 2 times, most recently from 07a857d to 0029b25 Compare April 6, 2026 22:58

@rata rata 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, thanks! There was also a typo in the cleanup function, I think we can fix it too.

Restarted the fedora job that was skipped.

Comment thread tests/rootless.sh Resolved
Comment thread tests/rootless.sh
# We use `ssh rootless@localhost` instead of `sudo -u rootless` for creating systemd user session.
# Alternatively we could use `machinectl shell`, but it is known not to work well on SELinux-enabled hosts as of April 2020:
# https://bugzilla.redhat.com/show_bug.cgi?id=1788616
ssh -t -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i "$HOME/.ssh/rootless.key" rootless@localhost -- PATH="$PATH" RUNC_USE_SYSTEMD="$RUNC_USE_SYSTEMD" bats -t "$ROOT/tests/integration$ROOTLESS_TESTPATH"

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.

Maybe we can use $(env | grep -E '\S' | xargs -d $'\n' printf 'export %q; ') in the ssh command?
I think this will ensure we don't miss any other envs in the future.

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.

I think both this PR and #5224 can be fixed by this way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, we do not want to supply ALL local variables, this will most probably break the test (values for $HOME etc). We don't want to supply all exported variables either.

It's probably better to have a list at the top of the file; I'll rework this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reworked; PTAL @lifubang @rata

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.

No, we do not want to supply ALL local variables, this will most probably break the test (values for $HOME etc). We don't want to supply all exported variables either.

Ah, I see, it's rootless, not root.

Also, fix the typo (AUX_DIX) in cleanup.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
kolyshkin force-pushed the fix-rootless-systemd-idmap branch from 0029b25 to 0825542 Compare April 7, 2026 18:26
When RUNC_USE_SYSTEMD is set, tests/rootless.sh is using

	ssh -tt rootless@localhost

to run tests as rootless user. In this case, local environment is not
passed to the user's ssh session (unless explicitly specified), and so
the tests do not get ROOTLESS_FEATURES.

As a result, idmap-related tests are skipped when running as rootless
using systemd cgroup driver:

	integration test (systemd driver)
	...
	[02] run rootless tests ... (idmap)
	...
	ok 286 runc run detached ({u,g}id != 0) # skip test requires rootless_idmap
	...

Fix this by creating a list of environment variables needed by the
tests, and adding those to ssh command line (in case of ssh) or
exporting (in case of sudo) so both cases work similarly.

Also, modify disable_idmap to unset variables set in enable_idmap so
they are not exported at all if idmap is not in features.

Fixes: bf15cc9 ("cgroup v2: support rootless systemd")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
kolyshkin requested review from lifubang and rata April 7, 2026 21:00
@kolyshkin
kolyshkin force-pushed the fix-rootless-systemd-idmap branch from 0825542 to 3e0829d Compare April 7, 2026 21:03

@rata rata 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, thanks!

@lifubang lifubang added backport/1.3-todo A PR in main branch which needs to be backported to release-1.3 backport/1.4-todo A PR in main branch which needs to backported to release-1.4 backport/1.5-todo A PR in main branch which needs to be backported to release-1.5 labels Apr 8, 2026
@lifubang
lifubang merged commit 65bf6dc into opencontainers:main Apr 8, 2026
55 checks passed
@kolyshkin kolyshkin added backport/1.3-done A PR in main branch which has been backported to release-1.3 backport/1.4-done A PR in main branch which has been backported to release-1.4 backport/1.5-done A PR in main branch which has been backported to release-1.5 and removed backport/1.3-todo A PR in main branch which needs to be backported to release-1.3 backport/1.4-todo A PR in main branch which needs to backported to release-1.4 backport/1.5-todo A PR in main branch which needs to be backported to release-1.5 labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci backport/1.3-done A PR in main branch which has been backported to release-1.3 backport/1.4-done A PR in main branch which has been backported to release-1.4 backport/1.5-done A PR in main branch which has been backported to release-1.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants