mirror of
https://github.com/containers/podman.git
synced 2025-12-11 09:18:34 +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:
10
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
10
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
@@ -579,6 +579,7 @@ type SecretConfig struct {
|
||||
// ConfigMapConfig represents the "configmap" TOML config table
|
||||
//
|
||||
// revive does not like the name because the package is already called config
|
||||
//
|
||||
//nolint:revive
|
||||
type ConfigMapConfig struct {
|
||||
// Driver specifies the configmap driver to use.
|
||||
@@ -1037,10 +1038,11 @@ func (c *Config) Capabilities(user string, addCapabilities, dropCapabilities []s
|
||||
|
||||
// Device parses device mapping string to a src, dest & permissions string
|
||||
// Valid values for device looklike:
|
||||
// '/dev/sdc"
|
||||
// '/dev/sdc:/dev/xvdc"
|
||||
// '/dev/sdc:/dev/xvdc:rwm"
|
||||
// '/dev/sdc:rm"
|
||||
//
|
||||
// '/dev/sdc"
|
||||
// '/dev/sdc:/dev/xvdc"
|
||||
// '/dev/sdc:/dev/xvdc:rwm"
|
||||
// '/dev/sdc:rm"
|
||||
func Device(device string) (src, dst, permissions string, err error) {
|
||||
permissions = "rwm"
|
||||
split := strings.Split(device, ":")
|
||||
|
||||
1
vendor/github.com/containers/common/pkg/config/default.go
generated
vendored
1
vendor/github.com/containers/common/pkg/config/default.go
generated
vendored
@@ -685,4 +685,3 @@ func useUserConfigLocations() bool {
|
||||
// GetRootlessUID == -1 on Windows, so exclude negative range
|
||||
return unshare.GetRootlessUID() > 0
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/containers/common/pkg/config/default_freebsd.go
generated
vendored
2
vendor/github.com/containers/common/pkg/config/default_freebsd.go
generated
vendored
@@ -7,7 +7,7 @@ func getDefaultCgroupsMode() string {
|
||||
// In theory, FreeBSD should be able to use shm locks but in practice,
|
||||
// this causes cryptic error messages from the kernel that look like:
|
||||
//
|
||||
// comm podman pid 90813: handling rb error 22
|
||||
// comm podman pid 90813: handling rb error 22
|
||||
//
|
||||
// These seem to be related to fork/exec code paths. Fall back to
|
||||
// file-based locks.
|
||||
|
||||
3
vendor/github.com/containers/common/pkg/config/default_linux.go
generated
vendored
3
vendor/github.com/containers/common/pkg/config/default_linux.go
generated
vendored
@@ -2,7 +2,6 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -37,7 +36,7 @@ func getDefaultProcessLimits() []string {
|
||||
rlim := unix.Rlimit{Cur: oldMaxSize, Max: oldMaxSize}
|
||||
oldrlim := rlim
|
||||
// Attempt to set file limit and process limit to pid_max in OS
|
||||
dat, err := ioutil.ReadFile("/proc/sys/kernel/pid_max")
|
||||
dat, err := os.ReadFile("/proc/sys/kernel/pid_max")
|
||||
if err == nil {
|
||||
val := strings.TrimSuffix(string(dat), "\n")
|
||||
max, err := strconv.ParseUint(val, 10, 64)
|
||||
|
||||
8
vendor/github.com/containers/common/pkg/config/systemd.go
generated
vendored
8
vendor/github.com/containers/common/pkg/config/systemd.go
generated
vendored
@@ -4,7 +4,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -53,7 +53,7 @@ func defaultLogDriver() string {
|
||||
|
||||
func useSystemd() bool {
|
||||
systemdOnce.Do(func() {
|
||||
dat, err := ioutil.ReadFile("/proc/1/comm")
|
||||
dat, err := os.ReadFile("/proc/1/comm")
|
||||
if err == nil {
|
||||
val := strings.TrimSuffix(string(dat), "\n")
|
||||
usesSystemd = (val == "systemd")
|
||||
@@ -68,13 +68,13 @@ func useJournald() bool {
|
||||
return
|
||||
}
|
||||
for _, root := range []string{"/run/log/journal", "/var/log/journal"} {
|
||||
dirs, err := ioutil.ReadDir(root)
|
||||
dirs, err := os.ReadDir(root)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
for _, d := range dirs {
|
||||
if d.IsDir() {
|
||||
if _, err := ioutil.ReadDir(filepath.Join(root, d.Name())); err == nil {
|
||||
if _, err := os.ReadDir(filepath.Join(root, d.Name())); err == nil {
|
||||
usesJournald = true
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user