mirror of
https://github.com/containers/podman.git
synced 2025-06-27 05:26:50 +08:00
Merge pull request #14755 from cdoern/system
fix volume reporting in system df
This commit is contained in:
@ -319,8 +319,8 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
|
|||||||
}
|
}
|
||||||
|
|
||||||
dfVolumes := make([]*entities.SystemDfVolumeReport, 0, len(vols))
|
dfVolumes := make([]*entities.SystemDfVolumeReport, 0, len(vols))
|
||||||
var reclaimableSize uint64
|
|
||||||
for _, v := range vols {
|
for _, v := range vols {
|
||||||
|
var reclaimableSize uint64
|
||||||
var consInUse int
|
var consInUse int
|
||||||
mountPoint, err := v.MountPoint()
|
mountPoint, err := v.MountPoint()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -341,7 +341,7 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(inUse) == 0 {
|
if len(inUse) == 0 {
|
||||||
reclaimableSize += volSize
|
reclaimableSize = volSize
|
||||||
}
|
}
|
||||||
for _, viu := range inUse {
|
for _, viu := range inUse {
|
||||||
if cutil.StringInSlice(viu, runningContainers) {
|
if cutil.StringInSlice(viu, runningContainers) {
|
||||||
|
@ -70,6 +70,17 @@ var _ = Describe("podman system df", func() {
|
|||||||
Expect(containers[1]).To(Equal("2"), "total containers expected")
|
Expect(containers[1]).To(Equal("2"), "total containers expected")
|
||||||
Expect(volumes[2]).To(Equal("2"), "total volumes expected")
|
Expect(volumes[2]).To(Equal("2"), "total volumes expected")
|
||||||
Expect(volumes[6]).To(Equal("(50%)"), "percentage usage expected")
|
Expect(volumes[6]).To(Equal("(50%)"), "percentage usage expected")
|
||||||
|
|
||||||
|
session = podmanTest.Podman([]string{"rm", "container1"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(Exit(0))
|
||||||
|
session = podmanTest.Podman([]string{"system", "df"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(Exit(0))
|
||||||
|
volumes = strings.Fields(session.OutputToStringArray()[3])
|
||||||
|
// percentages on volumes were being calculated incorrectly. Make sure we only report 100% and not above
|
||||||
|
Expect(volumes[6]).To(Equal("(100%)"), "percentage usage expected")
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman system df image with no tag", func() {
|
It("podman system df image with no tag", func() {
|
||||||
|
Reference in New Issue
Block a user