Skip to content

Commit

Permalink
Merge pull request #6910 from mheon/fix_out_of_range
Browse files Browse the repository at this point in the history
Fix a bug where --pids-limit was parsed incorrectly
  • Loading branch information
openshift-merge-robot authored Jul 15, 2020
2 parents 5262c53 + 9810e58 commit 2a36096
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/podman/containers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func createInit(c *cobra.Command) error {
}
if c.Flags().Changed("pids-limit") {
val := c.Flag("pids-limit").Value.String()
pidsLimit, err := strconv.ParseInt(val, 0, 10)
pidsLimit, err := strconv.ParseInt(val, 10, 32)
if err != nil {
return err
}
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,4 +1015,21 @@ USER mail`
Expect(session.ExitCode()).To(Equal(0))
}
})

It("podman run verify pids-limit", func() {
cgroupsv2, err := cgroups.IsCgroup2UnifiedMode()
Expect(err).To(BeNil())

if !cgroupsv2 {
// Need v2 to ensure that cgroupfs looks the way we
// expect.
Skip("Test requires cgroups v2 to be enabled")
}

limit := "4321"
session := podmanTest.Podman([]string{"run", "--pids-limit", limit, "--rm", ALPINE, "cat", "/sys/fs/cgroup/pids.max"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(session.OutputToString()).To(ContainSubstring(limit))
})
})

0 comments on commit 2a36096

Please sign in to comment.