mirror of
https://github.com/containers/podman.git
synced 2025-10-28 03:45:54 +08:00
system df: fix image-size calculations
Fix two bugs in `system df`:
1. The total size was calculated incorrectly as it was creating the sum
of all image sizes but did not consider that a) the same image may
be listed more than once (i.e., for each repo-tag pair), and that
b) images share layers.
The total size is now calculated directly in `libimage` by taking
multi-layer use into account.
2. The reclaimable size was calculated incorrectly. This number
indicates which data we can actually remove which means the total
size minus what containers use (i.e., the "unique" size of the image
in use by containers).
NOTE: The c/storage version is pinned back to the previous commit as it
is buggy. c/common already requires the buggy version, so use a
`replace` to force/pin.
Fixes: #16135
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
11
vendor/github.com/containers/common/pkg/cgroups/cgroups.go
generated
vendored
11
vendor/github.com/containers/common/pkg/cgroups/cgroups.go
generated
vendored
@ -8,7 +8,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -143,7 +142,7 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool)
|
||||
basePath := cgroupRoot + userSlice
|
||||
controllersFile = fmt.Sprintf("%s/cgroup.controllers", basePath)
|
||||
}
|
||||
controllersFileBytes, err := ioutil.ReadFile(controllersFile)
|
||||
controllersFileBytes, err := os.ReadFile(controllersFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed while reading controllers for cgroup v2: %w", err)
|
||||
}
|
||||
@ -294,7 +293,7 @@ func (c *CgroupControl) initialize() (err error) {
|
||||
}
|
||||
|
||||
func readFileAsUint64(path string) (uint64, error) {
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -310,7 +309,7 @@ func readFileAsUint64(path string) (uint64, error) {
|
||||
}
|
||||
|
||||
func readFileByKeyAsUint64(path, key string) (uint64, error) {
|
||||
content, err := ioutil.ReadFile(path)
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -533,7 +532,7 @@ func (c *CgroupControl) AddPid(pid int) error {
|
||||
|
||||
if c.cgroup2 {
|
||||
p := filepath.Join(cgroupRoot, c.path, "cgroup.procs")
|
||||
if err := ioutil.WriteFile(p, pidString, 0o644); err != nil {
|
||||
if err := os.WriteFile(p, pidString, 0o644); err != nil {
|
||||
return fmt.Errorf("write %s: %w", p, err)
|
||||
}
|
||||
return nil
|
||||
@ -556,7 +555,7 @@ func (c *CgroupControl) AddPid(pid int) error {
|
||||
continue
|
||||
}
|
||||
p := filepath.Join(c.getCgroupv1Path(n), "tasks")
|
||||
if err := ioutil.WriteFile(p, pidString, 0o644); err != nil {
|
||||
if err := os.WriteFile(p, pidString, 0o644); err != nil {
|
||||
return fmt.Errorf("write %s: %w", p, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user