Skip to content

Conversation

@lsm5
Copy link
Member

@lsm5 lsm5 commented Oct 10, 2025

Resolves: RUN-3567 (partly)

@github-actions github-actions bot added the common Related to "common" package label Oct 10, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 10, 2025
@podmanbot
Copy link

✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6423

@lsm5
Copy link
Member Author

lsm5 commented Oct 10, 2025

@containers/container-libs-maintainers I think it'd be nice to have a podman6 or cgv1 or some such label here as well. Mind creating one please?

@lsm5 lsm5 changed the title common: remove Cgroups v1 support common: remove Cgroups v1 support (podman6) Oct 10, 2025
@lsm5
Copy link
Member Author

lsm5 commented Oct 10, 2025

ah if it's manual merges here, then no need I guess.

@Luap99 Luap99 added the podman 6 breaking changes that should go only into podman 6 only label Oct 10, 2025
@Luap99
Copy link
Member

Luap99 commented Oct 10, 2025

yeah manual merge, keep the PR as draft until we branched.

Still a label to track all the things is still a good idea so I added the "podman 6" label.

podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 10, 2025
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

I know absolutely nothing about the problem space, this is just looking at the diff + immediately surrounding code.

// Load loads an existing cgroup control.
func Load(path string) (*CgroupControl, error) {
cgroup2, err := IsCgroup2UnifiedMode()
_, err := IsCgroup2UnifiedMode()
Copy link
Contributor

Choose a reason for hiding this comment

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

There are several other callers of this, and quite a few code paths that could potentially be deleted if this never returns false, nil. Do we want to update those as well? If not, what’s the exact scope of changes we do want to make?


Assuming we do change all of the callers to expect (_, err) or (true, nil), should wereplace the IsCgroup2UnifiedMode function by a function with some other name (IsProcCgroupMounted???), or perhaps remove it entirely?


But then again, note that non-Linux code is hard-coded to return (false, nil). Is that still what we want?

Copy link
Member Author

Choose a reason for hiding this comment

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

On #podman-dev matrix , there seemed to be agreement on having a single check for v1/v2 in main and removing everything else. Would that suffice for the common library too? So, basically remove all cgroup conditionals and v1 logic from the library and let the library users handle this via a single check (?).

podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 14, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 14, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 14, 2025
@TomSweeneyRedHat
Copy link
Member

Looks like a good start to me @lsm5

podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 16, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 16, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 16, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 16, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 17, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 17, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 17, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 17, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 17, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 21, 2025
@packit-as-a-service
Copy link

Packit jobs failed. @containers/packit-build please check.

3 similar comments
@packit-as-a-service
Copy link

Packit jobs failed. @containers/packit-build please check.

@packit-as-a-service
Copy link

Packit jobs failed. @containers/packit-build please check.

@packit-as-a-service
Copy link

Packit jobs failed. @containers/packit-build please check.

podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 21, 2025
@lsm5
Copy link
Member Author

lsm5 commented Oct 23, 2025

@containers/container-libs-maintainers Now that podman v5.7 is branched, when can we start merging v6 stuff in container-libs? I can remove draft status on this whenever we're ready to review/merge.

Removes all conditionals for IsCgroup2UnifiedMode and cgroupv2.Enabled
and assumes Cgroups v2. Also removes `cgroup2` and `additionalControllers` from
CgroupControl struct and all the conditionals resulting from it.

pkg/cgroups.IsCgroup2UnifiedMode is being retained as it will be used in
the dependent tools as a single check for v1/v2.

Fixes: RUN-3567 (partly)

Signed-off-by: Lokesh Mandvekar <[email protected]>
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 23, 2025
@mheon
Copy link
Member

mheon commented Oct 23, 2025

Only remaining question is whether we wait for the 6.0.0-dev bump... I think that's not really necessary though. Should be fine to un-draft

@lsm5 lsm5 marked this pull request as ready for review October 23, 2025 15:35
@lsm5
Copy link
Member Author

lsm5 commented Oct 23, 2025

@containers/container-libs-maintainers PTAL

@lsm5
Copy link
Member Author

lsm5 commented Oct 23, 2025

buildah PR: containers/buildah#6424
podman PR: containers/podman#27271

return false, nil
}
return ctr.createCgroupDirectory(Blkio)
return false, nil
Copy link
Member

Choose a reason for hiding this comment

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

if this function does nothing it should be removed

Copy link
Contributor

Choose a reason for hiding this comment

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

That might not be possible with the controllerHandler abstraction… but then all Destroy callbacks do something with a getCgroupv1Path, so there might be more opportunities to simplify.

After this PR, don’t all the Apply calls do exatly the same fs2.NewManager().Set() call? Does that do anything (well, does that do anything beneficial) to call that repeatedly?

I’m starting to have a vague impression that all of pkg/cgroups would be best replaced by direct calls of opencontainers/cgroups/fs2 — but I did not research that, and this is not the PR to do that. (It might not even be the PR to drop the controllerHandler abstraction, I have no opinion on that part.)

return false, nil
}
return ctr.createCgroupDirectory(CPU)
return false, nil
Copy link
Member

Choose a reason for hiding this comment

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

here as well it seem like we can remove this function

return false, nil
}
return ctr.createCgroupDirectory(Memory)
return false, nil
Copy link
Member

Choose a reason for hiding this comment

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

and here

}
enabled, err := cgroupv2.Enabled()
if err == nil && !enabled && unshare.IsRootless() {
if unshare.IsRootless() {
Copy link
Member

Choose a reason for hiding this comment

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

That seem wrong, the condition was if cgroupv1 && rootless I think, now it is just rootless which means we default to cgroupfs which sounds wrong and I would expect test failures because of that. I would assume this entire branch should just be deleted

sysInfo.cgroupCPUInfo = checkCgroupCPU(cgMounts, quiet)
sysInfo.cgroupBlkioInfo = checkCgroupBlkioInfo(cgMounts, quiet)
sysInfo.cgroupCpusetInfo = checkCgroupCpusetInfo(cgMounts, quiet)
sysInfo.cgroupPids = checkCgroupPids(cgMounts, quiet)
Copy link
Member

Choose a reason for hiding this comment

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

isn't this removing PidsLimit: true which was set before when cgroupv2 is used?

Copy link
Member Author

Choose a reason for hiding this comment

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

well, lint didn't complain about it earlier. Looks like it can be removed. So, just to confirm, should GetDefaultPidsLimit assume PidsLimit: true and just return 4096?`

@lsm5 lsm5 marked this pull request as draft October 23, 2025 18:38
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Just a local review looking at the package.

I’d find refactoring easier to review (and much safer to later find bugs in, via git bisect) if they were split into smaller commits, one idea at a time) — at least, please do so if you follow up on some of the newly available options pointed out below.

I’m overall unclear on the error handling — do we need to worry about e.g. /sys not being mounted at all, and IsCgroup2UnifiedMode returning (false, error) in such a situation — and that the reported errors are reasonable even after we remove the IsCgroup2UnifiedMode calls? Or is that something that we don’t care about (or perhaps something that can never happen)?

name: name,
symlink: !fileInfo.IsDir(),
name: controllerName,
symlink: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

symlink is always false (and never read?)

… and then I think the only remaining caller only extracts the name field, so maybe the whole controller type can be removed.

}

// AddPid moves the specified pid to the cgroup.
func (c *CgroupControl) AddPid(pid int) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

pid is not used, how does this work?! (I can’t see a Podman caller)

} else {
ioString = "BlockIOAccounting"
}
ioString := "IOAccounting"
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be inlined into the only user.

(Some similar opportunities exist elsewhere.)

}

uMap, sMap, bMap, iMap, structMap, err := resourcesToProps(resources, v2)
uMap, sMap, bMap, iMap, structMap, err := resourcesToProps(resources, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only caller, the v2 parameter can removed and the function simplified.

}

cgroupNS := "host"
if cgroup2, _ := cgroupv2.Enabled(); cgroup2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

cgroupv2.Enabled seems to be exactly the same code as cgroup.IsCgroup2UnifiedMode. Can one of the two be entirely removed?

if cgroup2, _ := cgroupv2.Enabled(); cgroup2 {
cgroupNS = "private"
}
cgroupNS := "private"
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be inlined into the only user.

@lsm5
Copy link
Member Author

lsm5 commented Oct 24, 2025

I’d find refactoring easier to review (and much safer to later find bugs in, via git bisect) if they were split into smaller commits, one idea at a time) — at least, please do so if you follow up on some of the newly available options pointed out below.

I think I could do that even for the existing stuff. Will reorganize this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package podman 6 breaking changes that should go only into podman 6 only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants