diff --git a/go.mod b/go.mod index 99c27b9d66..32b7895101 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/containernetworking/cni v0.8.1 github.com/containernetworking/plugins v0.9.1 github.com/containers/buildah v1.21.0 - github.com/containers/common v0.38.14 + github.com/containers/common v0.38.15 github.com/containers/conmon v2.0.20+incompatible github.com/containers/image/v5 v5.12.0 github.com/containers/ocicrypt v1.1.1 diff --git a/go.sum b/go.sum index ac6daf432b..23ff96c8bd 100644 --- a/go.sum +++ b/go.sum @@ -218,8 +218,8 @@ github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRD github.com/containers/buildah v1.21.0 h1:LuwuqRPjan3X3AIdGwfkEkqMgmrDMNpQznFqNdHgCz8= github.com/containers/buildah v1.21.0/go.mod h1:yPdlpVd93T+i91yGxrJbW1YOWrqN64j5ZhHOZmHUejs= github.com/containers/common v0.38.4/go.mod h1:egfpX/Y3+19Dz4Wa1eRZDdgzoEOeneieF9CQppKzLBg= -github.com/containers/common v0.38.14 h1:6fp6+NpG/JhhGboRuUuc4fDaXHoHnSW9n/qL2iGQlLA= -github.com/containers/common v0.38.14/go.mod h1:egfpX/Y3+19Dz4Wa1eRZDdgzoEOeneieF9CQppKzLBg= +github.com/containers/common v0.38.15 h1:esHGxhaqjb5GihF9uO2KZoSGcydIB1PxjZojDipkN6E= +github.com/containers/common v0.38.15/go.mod h1:egfpX/Y3+19Dz4Wa1eRZDdgzoEOeneieF9CQppKzLBg= github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg= github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I= github.com/containers/image/v5 v5.12.0 h1:1hNS2QkzFQ4lH3GYQLyAXB0acRMhS1Ubm6oV++8vw4w= diff --git a/vendor/github.com/containers/common/libimage/import.go b/vendor/github.com/containers/common/libimage/import.go index 4cce4c9ca4..c11e86d67c 100644 --- a/vendor/github.com/containers/common/libimage/import.go +++ b/vendor/github.com/containers/common/libimage/import.go @@ -80,16 +80,12 @@ func (r *Runtime) Import(ctx context.Context, path string, options *ImportOption return "", err } - name := options.Tag - if name == "" { - name, err = getImageDigest(ctx, srcRef, r.systemContextCopy()) - if err != nil { - return "", err - } - name = "sha256:" + name[1:] // strip leading "@" + id, err := getImageDigest(ctx, srcRef, r.systemContextCopy()) + if err != nil { + return "", err } - destRef, err := storageTransport.Transport.ParseStoreReference(r.store, name) + destRef, err := storageTransport.Transport.ParseStoreReference(r.store, id) if err != nil { return "", err } @@ -104,5 +100,19 @@ func (r *Runtime) Import(ctx context.Context, path string, options *ImportOption return "", err } - return name, nil + // Strip the leading @ off the id. + name := id[1:] + + // If requested, tag the imported image. + if options.Tag != "" { + image, _, err := r.LookupImage(name, nil) + if err != nil { + return "", errors.Wrap(err, "looking up imported image") + } + if err := image.Tag(options.Tag); err != nil { + return "", err + } + } + + return "sha256:" + name, nil } diff --git a/vendor/github.com/containers/common/pkg/config/default.go b/vendor/github.com/containers/common/pkg/config/default.go index 133f9f0739..794efc32ea 100644 --- a/vendor/github.com/containers/common/pkg/config/default.go +++ b/vendor/github.com/containers/common/pkg/config/default.go @@ -191,7 +191,7 @@ func DefaultConfig() (*Config, error) { Init: false, InitPath: "", IPCNS: "private", - LogDriver: DefaultLogDriver, + LogDriver: defaultLogDriver(), LogSizeMax: DefaultLogSizeMax, NetNS: netns, NoHosts: false, diff --git a/vendor/github.com/containers/common/pkg/config/nosystemd.go b/vendor/github.com/containers/common/pkg/config/nosystemd.go index 5b82b13895..6e39a6ccdb 100644 --- a/vendor/github.com/containers/common/pkg/config/nosystemd.go +++ b/vendor/github.com/containers/common/pkg/config/nosystemd.go @@ -3,9 +3,17 @@ package config func defaultCgroupManager() string { - return "cgroupfs" + return CgroupfsCgroupsManager } func defaultEventsLogger() string { return "file" } + +func defaultLogDriver() string { + return DefaultLogDriver +} + +func useSystemd() bool { + return false +} diff --git a/vendor/github.com/containers/common/pkg/config/systemd.go b/vendor/github.com/containers/common/pkg/config/systemd.go index 02e5c4ac2f..ed014126b9 100644 --- a/vendor/github.com/containers/common/pkg/config/systemd.go +++ b/vendor/github.com/containers/common/pkg/config/systemd.go @@ -3,11 +3,23 @@ package config import ( + "io/ioutil" + "strings" + "sync" + "github.com/containers/common/pkg/cgroupv2" "github.com/containers/storage/pkg/unshare" ) +var ( + systemdOnce sync.Once + usesSystemd bool +) + func defaultCgroupManager() string { + if !useSystemd() { + return CgroupfsCgroupsManager + } enabled, err := cgroupv2.Enabled() if err == nil && !enabled && unshare.IsRootless() { return CgroupfsCgroupsManager @@ -15,6 +27,32 @@ func defaultCgroupManager() string { return SystemdCgroupsManager } + func defaultEventsLogger() string { - return "journald" + if useSystemd() { + return "journald" + } + return "file" +} + +func defaultLogDriver() string { + // If we decide to change the default for logdriver, it should be done here. + if useSystemd() { + return DefaultLogDriver + } + + return DefaultLogDriver + +} + +func useSystemd() bool { + systemdOnce.Do(func() { + dat, err := ioutil.ReadFile("/proc/1/comm") + if err == nil { + val := strings.TrimSuffix(string(dat), "\n") + usesSystemd = (val == "systemd") + } + return + }) + return usesSystemd } diff --git a/vendor/github.com/containers/common/version/version.go b/vendor/github.com/containers/common/version/version.go index 5e09d56a27..28da9dca45 100644 --- a/vendor/github.com/containers/common/version/version.go +++ b/vendor/github.com/containers/common/version/version.go @@ -1,4 +1,4 @@ package version // Version is the version of the build. -const Version = "0.38.14" +const Version = "0.38.15" diff --git a/vendor/modules.txt b/vendor/modules.txt index cada866cfa..adb83220dc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -91,7 +91,7 @@ github.com/containers/buildah/pkg/overlay github.com/containers/buildah/pkg/parse github.com/containers/buildah/pkg/rusage github.com/containers/buildah/util -# github.com/containers/common v0.38.14 +# github.com/containers/common v0.38.15 github.com/containers/common/libimage github.com/containers/common/libimage/manifests github.com/containers/common/pkg/apparmor