Skip to content

Commit

Permalink
Merge pull request #9309 from baude/issue9303
Browse files Browse the repository at this point in the history
Display correct value for unlimited ulimit
  • Loading branch information
openshift-merge-robot authored Feb 10, 2021
2 parents 4d604c1 + 5ccb159 commit db64865
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libpod/container_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,8 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
for _, limit := range ctrSpec.Process.Rlimits {
newLimit := define.InspectUlimit{}
newLimit.Name = limit.Type
newLimit.Soft = limit.Soft
newLimit.Hard = limit.Hard
newLimit.Soft = int64(limit.Soft)
newLimit.Hard = int64(limit.Hard)
hostConfig.Ulimits = append(hostConfig.Ulimits, newLimit)
}
}
Expand Down
4 changes: 2 additions & 2 deletions libpod/define/container_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ type InspectUlimit struct {
// Name is the name (type) of the ulimit.
Name string `json:"Name"`
// Soft is the soft limit that will be applied.
Soft uint64 `json:"Soft"`
Soft int64 `json:"Soft"`
// Hard is the hard limit that will be applied.
Hard uint64 `json:"Hard"`
Hard int64 `json:"Hard"`
}

// InspectDevice is a single device that will be mounted into the container.
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,28 @@ var _ = Describe("Podman inspect", func() {
Expect(len(inspect)).To(Equal(1))
Expect(len(inspect[0].NetworkSettings.Networks)).To(Equal(1))
})

It("Container inspect with unlimited uilimits should be -1", func() {
ctrName := "testctr"
session := podmanTest.Podman([]string{"run", "-d", "--ulimit", "core=-1:-1", "--name", ctrName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(BeZero())

inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
Expect(inspect.ExitCode()).To(BeZero())

data := inspect.InspectContainerToJSON()
ulimits := data[0].HostConfig.Ulimits
Expect(len(ulimits)).To(BeNumerically(">", 0))
found := false
for _, ulimit := range ulimits {
if ulimit.Name == "RLIMIT_CORE" {
found = true
Expect(ulimit.Soft).To(BeNumerically("==", -1))
Expect(ulimit.Hard).To(BeNumerically("==", -1))
}
}
Expect(found).To(BeTrue())
})
})

0 comments on commit db64865

Please sign in to comment.