Skip to content

Commit

Permalink
cmd: add warnings for --cgroup* options when --pod is set
Browse files Browse the repository at this point in the history
Signed-off-by: Misaki Kasumi <misakikasumi@outlook.com>
  • Loading branch information
ruihe774 committed Aug 23, 2024
1 parent 426aac3 commit 1d27de5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cmd/podman/containers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,27 @@ func CreateInit(c *cobra.Command, vals entities.ContainerCreateOptions, isInfra
}
vals.Env = env
}
if c.Flag("cgroups").Changed && vals.CgroupsMode == "split" && registry.IsRemote() {

cgroupsChanged := c.Flag("cgroups").Changed
if cgroupsChanged && vals.CgroupsMode == "split" && registry.IsRemote() {
return vals, fmt.Errorf("the option --cgroups=%q is not supported in remote mode", vals.CgroupsMode)
}

if c.Flag("pod").Changed && !strings.HasPrefix(c.Flag("pod").Value.String(), "new:") && c.Flag("userns").Changed {
return vals, errors.New("--userns and --pod cannot be set together")
}

if c.Flag("pod").Changed || c.Flag("pod-id-file").Changed {
if cgroupsChanged && (vals.CgroupsMode == "split" || vals.CgroupsMode == "disabled") {
logrus.Warnf("Setting --cgroups=%q ignores pod level cgroup resource limits.", vals.CgroupsMode)
}
if c.Flag("cgroupns").Changed && vals.CgroupNS != "private" {
logrus.Warnf("Setting --cgroupns may ignore pod level cgroup resource limits.")
}
if c.Flag("cgroup-parent").Changed {
logrus.Warnf("Setting --cgroup-parent may ignore pod level cgroup resource limits.")
}
}
}
if c.Flag("shm-size").Changed {
vals.ShmSize = c.Flag("shm-size").Value.String()
Expand Down

0 comments on commit 1d27de5

Please sign in to comment.