Merge pull request #26225 from Luap99/df-panic

system df --verbose don't crash
This commit is contained in:
openshift-merge-bot[bot] 2025-05-30 22:04:53 +00:00 committed by GitHub
commit 27593b9e33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -275,7 +275,10 @@ func (d *dfContainer) ContainerID() string {
}
func (d *dfContainer) Image() string {
return d.SystemDfContainerReport.Image[0:12]
if len(d.SystemDfContainerReport.Image) >= 12 {
return d.SystemDfContainerReport.Image[0:12]
}
return ""
}
func (d *dfContainer) Command() string {

View File

@ -34,6 +34,23 @@ function setup_file() {
is "$output" '.*"Local Volumes".*"Size":"0B"' "Total containers reported"
}
# Regression test for https://github.com/containers/podman/issues/26224
@test "podman system df - with rootfs container" {
pod=p-$(safename)
# create a pod which creates an infra container based on a rootfs
run_podman pod create --name $pod
run_podman system df
assert "${lines[1]}" =~ "Images *1 *0.*"
assert "${lines[2]}" =~ "Containers *1 *0.*"
run_podman system df --verbose
assert "${lines[5]}" =~ \
"[0-9a-f]{12} *0.*[0-9a-f]{12}-infra" \
"system df --verbose, 'Containers', infra line"
run_podman pod rm -f $pod
}
@test "podman system df --format json functionality" {
# Run two dummy containers, one which exits, one which stays running
cname_stopped=c-stopped-$(safename)