Skip to content

[Carry 133278] kubelet: Don't ignore idsPerPod config #133278 #133373

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented Aug 4, 2025

Carry #133278, so as to address my own comments (tests/e2e_node: Add test for userNamespaces.idsPerPod)


(Below is copied from #133278)

The idsPerPod where completely ignored since they were introduced in PR: #130028

The problem was the following:

  1. The userns manager (as well as all managers) is created before the config is copied to the kubelet object1
  2. The userns manager on creation is calling the kubelet_getter GetUserNamespacesIDsPerPod to get the idsPerPod
  3. The getter checks the configuration stored in the kubelet object, which hasn't been set at that point.
  4. As the config ss nil (unset), it returns the default value.

Therefore, the value was ignored.

To solve this, let's just pass the idsPerPod as a parameter to MakeUserNsManager(). This is the common pattern already used in the kubelet initialization.

cc @AkihiroSuda @giuseppe

What type of PR is this?

/kind bug

What this PR does / why we need it:

We now honor the idsPerPod config from the kubelet.

Which issue(s) this PR is related to:

Fixes: #133144

Special notes for your reviewer:

Does this PR introduce a user-facing change?

The kubelet now honors the configuration userNamespaces.idsPerPod. Before it was ignored.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


rata added 4 commits August 4, 2025 19:05
The idsPerPod where completely ignored since they were introduced in PR:
	kubernetes#130028

The problem was the following:
	1. The userns manager (as well as all managers) is created
	   before the config is copied to the kubelet object[1]
	2. The userns manager on creation is calling the kubelet_getter
	   GetUserNamespacesIDsPerPod to get the idsPerPod
	3. The getter checks the configuration stored in the kubelet
	   object, which hasn't been set at that point.
	4. As the config is nil (unset), it returns the default value.

Therefore, the value was ignored.

To solve this, let's just pass the idsPerPod as a parameter to
MakeUserNsManager(). This is the common pattern already used in the
kubelet initialization.

[1]: https://github.com/kubernetes/kubernetes/blob/461ba83084ab7cb91ab692687bb7aedb05c6eb65/pkg/kubelet/kubelet.go#L1078-L1087
[2]: https://github.com/kubernetes/kubernetes/blob/461ba83084ab7cb91ab692687bb7aedb05c6eb65/pkg/kubelet/kubelet_getters.go#L145

Signed-off-by: Rodrigo Campos <[email protected]>
The first UID used for userns mappings needs to be at least the
idsPerPod. When idsPerPod is extended to be 65536*2, for example, then
the default UID of 65536 doesn't work.

While this can be configured by the user, let's just improve the default
first UID to be the same as idsPerPod. This makes the default first UID
work out of the box if the user just wants to tune that.

This also simplifies testing, as we don't need to create a system user
and /etc/subuid and /etc/subgid files to test the idsPerPod setting.

Signed-off-by: Rodrigo Campos <[email protected]>
Golang allows to call methods on a nil object, as long as the methods
don't dereference the nil object. This is what we do here.

This makes all the userns configurations (idsPerPod or mapping configs
in /etc/subuid or /etc/subgid) to be ignored if the feature is off.

Signed-off-by: Rodrigo Campos <[email protected]>
Signed-off-by: Rodrigo Campos <[email protected]>
Signed-off-by: Akihiro Suda <[email protected]>
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 4, 2025
@k8s-ci-robot k8s-ci-robot added area/kubelet area/test sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Aug 4, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Aug 4, 2025
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 4, 2025
@AkihiroSuda
Copy link
Member Author

/retest

2 similar comments
@AkihiroSuda
Copy link
Member Author

/retest

@AkihiroSuda
Copy link
Member Author

/retest

@rata
Copy link
Member

rata commented Aug 5, 2025

/test pull-kubernetes-node-crio-cgrpv2-userns-e2e-serial

@rata
Copy link
Member

rata commented Aug 5, 2025

@AkihiroSuda Thanks for improving the tests!

Copy link
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

LGTM

@SergeyKanzhelev can you please add this one to the milestone?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AkihiroSuda, rata
Once this PR has been reviewed and has the lgtm label, please assign tallclair for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@bart0sh bart0sh moved this from Triage to Needs Reviewer in SIG Node: code and documentation PRs Aug 8, 2025
@bart0sh
Copy link
Contributor

bart0sh commented Aug 8, 2025

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 8, 2025
@haircommander haircommander moved this from Triage to Archive-it in SIG Node CI/Test Board Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: Archive-it
Development

Successfully merging this pull request may close these issues.

After getting UserNamespaces configured and setting idsPerPod, the uid/gid maps inside containers are not seeing the settings propagate
4 participants