summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--libpod/runtime.go113
-rw-r--r--vendor/github.com/containers/common/pkg/config/config.go23
-rw-r--r--vendor/github.com/containers/common/pkg/config/default.go60
-rw-r--r--vendor/modules.txt2
6 files changed, 71 insertions, 133 deletions
diff --git a/go.mod b/go.mod
index 742c3c21d..635c0a17d 100644
--- a/go.mod
+++ b/go.mod
@@ -12,7 +12,7 @@ require (
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.1.1
github.com/containers/buildah v1.27.0
- github.com/containers/common v0.49.2-0.20220809074359-b0ea008ba661
+ github.com/containers/common v0.49.2-0.20220817132854-f6679f170eca
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/image/v5 v5.22.0
github.com/containers/ocicrypt v1.1.5
diff --git a/go.sum b/go.sum
index 644f03dd6..5053589c5 100644
--- a/go.sum
+++ b/go.sum
@@ -395,8 +395,8 @@ github.com/containernetworking/plugins v1.1.1/go.mod h1:Sr5TH/eBsGLXK/h71HeLfX19
github.com/containers/buildah v1.27.0 h1:LJ1ks7vKxwPzJGr5BWVvigbtVL9w7XeHtNEmiIOPJqI=
github.com/containers/buildah v1.27.0/go.mod h1:anH3ExvDXRNP9zLQCrOc1vWb5CrhqLF/aYFim4tslvA=
github.com/containers/common v0.49.1/go.mod h1:ueM5hT0itKqCQvVJDs+EtjornAQtrHYxQJzP2gxeGIg=
-github.com/containers/common v0.49.2-0.20220809074359-b0ea008ba661 h1:2Ldzg1st4REr5uUJRhjsye1zCbu0i/89RBh87Xc/cTY=
-github.com/containers/common v0.49.2-0.20220809074359-b0ea008ba661/go.mod h1:eT2iSsNzjOlF5VFLkyj9OU2SXznURvEYndsioQImuoE=
+github.com/containers/common v0.49.2-0.20220817132854-f6679f170eca h1:OjhEBVpFskIJ6Vq9nikYW7M6YXfkTxOBu+EQBoCyhuM=
+github.com/containers/common v0.49.2-0.20220817132854-f6679f170eca/go.mod h1:eT2iSsNzjOlF5VFLkyj9OU2SXznURvEYndsioQImuoE=
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.22.0 h1:KemxPmD4D2YYOFZN2SgoTk7nBFcnwPiPW0MqjYtknSE=
diff --git a/libpod/runtime.go b/libpod/runtime.go
index ea4b34954..684f4abd7 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -2,15 +2,11 @@ package libpod
import (
"bufio"
- "bytes"
"context"
"errors"
"fmt"
"os"
- "os/exec"
"path/filepath"
- "regexp"
- "strconv"
"strings"
"sync"
"syscall"
@@ -44,17 +40,6 @@ import (
"github.com/sirupsen/logrus"
)
-const (
- // conmonMinMajorVersion is the major version required for conmon.
- conmonMinMajorVersion = 2
-
- // conmonMinMinorVersion is the minor version required for conmon.
- conmonMinMinorVersion = 0
-
- // conmonMinPatchVersion is the sub-minor version required for conmon.
- conmonMinPatchVersion = 24
-)
-
// A RuntimeOption is a functional option which alters the Runtime created by
// NewRuntime
type RuntimeOption func(*Runtime) error
@@ -308,7 +293,7 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) {
// Sets up containers/storage, state store, OCI runtime
func makeRuntime(runtime *Runtime) (retErr error) {
// Find a working conmon binary
- cPath, err := findConmon(runtime.config.Engine.ConmonPath)
+ cPath, err := runtime.config.FindConmon()
if err != nil {
return err
}
@@ -670,102 +655,6 @@ func makeRuntime(runtime *Runtime) (retErr error) {
return nil
}
-// findConmon iterates over conmonPaths and returns the path
-// to the first conmon binary with a new enough version. If none is found,
-// we try to do a path lookup of "conmon".
-func findConmon(conmonPaths []string) (string, error) {
- foundOutdatedConmon := false
- for _, path := range conmonPaths {
- stat, err := os.Stat(path)
- if err != nil {
- continue
- }
- if stat.IsDir() {
- continue
- }
- if err := probeConmon(path); err != nil {
- logrus.Warnf("Conmon at %s invalid: %v", path, err)
- foundOutdatedConmon = true
- continue
- }
- logrus.Debugf("Using conmon: %q", path)
- return path, nil
- }
-
- // Search the $PATH as last fallback
- if path, err := exec.LookPath("conmon"); err == nil {
- if err := probeConmon(path); err != nil {
- logrus.Warnf("Conmon at %s is invalid: %v", path, err)
- foundOutdatedConmon = true
- } else {
- logrus.Debugf("Using conmon from $PATH: %q", path)
- return path, nil
- }
- }
-
- if foundOutdatedConmon {
- return "", fmt.Errorf(
- "please update to v%d.%d.%d or later: %w",
- conmonMinMajorVersion, conmonMinMinorVersion, conmonMinPatchVersion, define.ErrConmonOutdated)
- }
-
- return "", fmt.Errorf(
- "could not find a working conmon binary (configured options: %v): %w",
- conmonPaths, define.ErrInvalidArg)
-}
-
-// probeConmon calls conmon --version and verifies it is a new enough version for
-// the runtime expectations the container engine currently has.
-func probeConmon(conmonBinary string) error {
- cmd := exec.Command(conmonBinary, "--version")
- var out bytes.Buffer
- cmd.Stdout = &out
- err := cmd.Run()
- if err != nil {
- return err
- }
- r := regexp.MustCompile(`^conmon version (?P<Major>\d+).(?P<Minor>\d+).(?P<Patch>\d+)`)
-
- matches := r.FindStringSubmatch(out.String())
- if len(matches) != 4 {
- return fmt.Errorf("%v: %w", define.ErrConmonVersionFormat, err)
- }
- major, err := strconv.Atoi(matches[1])
- if err != nil {
- return fmt.Errorf("%v: %w", define.ErrConmonVersionFormat, err)
- }
- if major < conmonMinMajorVersion {
- return define.ErrConmonOutdated
- }
- if major > conmonMinMajorVersion {
- return nil
- }
-
- minor, err := strconv.Atoi(matches[2])
- if err != nil {
- return fmt.Errorf("%v: %w", define.ErrConmonVersionFormat, err)
- }
- if minor < conmonMinMinorVersion {
- return define.ErrConmonOutdated
- }
- if minor > conmonMinMinorVersion {
- return nil
- }
-
- patch, err := strconv.Atoi(matches[3])
- if err != nil {
- return fmt.Errorf("%v: %w", define.ErrConmonVersionFormat, err)
- }
- if patch < conmonMinPatchVersion {
- return define.ErrConmonOutdated
- }
- if patch > conmonMinPatchVersion {
- return nil
- }
-
- return nil
-}
-
// TmpDir gets the current Libpod temporary files directory.
func (r *Runtime) TmpDir() (string, error) {
if !r.valid {
diff --git a/vendor/github.com/containers/common/pkg/config/config.go b/vendor/github.com/containers/common/pkg/config/config.go
index a6276fbef..de1d91ae3 100644
--- a/vendor/github.com/containers/common/pkg/config/config.go
+++ b/vendor/github.com/containers/common/pkg/config/config.go
@@ -234,6 +234,10 @@ type EngineConfig struct {
// The first path pointing to a valid file will be used.
ConmonPath []string `toml:"conmon_path,omitempty"`
+ // ConmonRsPath is the path to the Conmon-rs binary used for managing containers.
+ // The first path pointing to a valid file will be used.
+ ConmonRsPath []string `toml:"conmonrs_path,omitempty"`
+
// CompatAPIEnforceDockerHub enforces using docker.io for completing
// short names in Podman's compatibility REST API. Note that this will
// ignore unqualified-search-registries and short-name aliases defined
@@ -915,8 +919,12 @@ func (c *NetworkConfig) Validate() error {
// to first (version) matching conmon binary. If non is found, we try
// to do a path lookup of "conmon".
func (c *Config) FindConmon() (string, error) {
+ return findConmonPath(c.Engine.ConmonPath, "conmon", _conmonMinMajorVersion, _conmonMinMinorVersion, _conmonMinPatchVersion)
+}
+
+func findConmonPath(paths []string, binaryName string, major int, minor int, patch int) (string, error) {
foundOutdatedConmon := false
- for _, path := range c.Engine.ConmonPath {
+ for _, path := range paths {
stat, err := os.Stat(path)
if err != nil {
continue
@@ -934,7 +942,7 @@ func (c *Config) FindConmon() (string, error) {
}
// Search the $PATH as last fallback
- if path, err := exec.LookPath("conmon"); err == nil {
+ if path, err := exec.LookPath(binaryName); err == nil {
if err := probeConmon(path); err != nil {
logrus.Warnf("Conmon at %s is invalid: %v", path, err)
foundOutdatedConmon = true
@@ -946,11 +954,18 @@ func (c *Config) FindConmon() (string, error) {
if foundOutdatedConmon {
return "", fmt.Errorf("please update to v%d.%d.%d or later: %w",
- _conmonMinMajorVersion, _conmonMinMinorVersion, _conmonMinPatchVersion, ErrConmonOutdated)
+ major, minor, patch, ErrConmonOutdated)
}
return "", fmt.Errorf("could not find a working conmon binary (configured options: %v: %w)",
- c.Engine.ConmonPath, ErrInvalidArg)
+ paths, ErrInvalidArg)
+}
+
+// FindConmonRs iterates over (*Config).ConmonRsPath and returns the path
+// to first (version) matching conmonrs binary. If non is found, we try
+// to do a path lookup of "conmonrs".
+func (c *Config) FindConmonRs() (string, error) {
+ return findConmonPath(c.Engine.ConmonRsPath, "conmonrs", _conmonrsMinMajorVersion, _conmonrsMinMinorVersion, _conmonrsMinPatchVersion)
}
// GetDefaultEnv returns the environment variables for the container.
diff --git a/vendor/github.com/containers/common/pkg/config/default.go b/vendor/github.com/containers/common/pkg/config/default.go
index c7ddf90ee..6bca7312a 100644
--- a/vendor/github.com/containers/common/pkg/config/default.go
+++ b/vendor/github.com/containers/common/pkg/config/default.go
@@ -33,6 +33,15 @@ const (
// _conmonMinPatchVersion is the sub-minor version required for conmon.
_conmonMinPatchVersion = 1
+ // _conmonrsMinMajorVersion is the major version required for conmonrs.
+ _conmonrsMinMajorVersion = 0
+
+ // _conmonrsMinMinorVersion is the minor version required for conmonrs.
+ _conmonrsMinMinorVersion = 1
+
+ // _conmonrsMinPatchVersion is the sub-minor version required for conmonrs.
+ _conmonrsMinPatchVersion = 0
+
// _conmonVersionFormatErr is used when the expected versio-format of conmon
// has changed.
_conmonVersionFormatErr = "conmon version changed format: %w"
@@ -276,7 +285,9 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
c.CompatAPIEnforceDockerHub = true
if path, ok := os.LookupEnv("CONTAINERS_STORAGE_CONF"); ok {
- types.SetDefaultConfigFilePath(path)
+ if err := types.SetDefaultConfigFilePath(path); err != nil {
+ return nil, err
+ }
}
storeOpts, err := types.DefaultStoreOptions(unshare.IsRootless(), unshare.GetRootlessUID())
if err != nil {
@@ -372,6 +383,16 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
"/usr/local/sbin/conmon",
"/run/current-system/sw/bin/conmon",
}
+ c.ConmonRsPath = []string{
+ "/usr/libexec/podman/conmonrs",
+ "/usr/local/libexec/podman/conmonrs",
+ "/usr/local/lib/podman/conmonrs",
+ "/usr/bin/conmonrs",
+ "/usr/sbin/conmonrs",
+ "/usr/local/bin/conmonrs",
+ "/usr/local/sbin/conmonrs",
+ "/run/current-system/sw/bin/conmonrs",
+ }
c.PullPolicy = DefaultPullPolicy
c.RuntimeSupportsJSON = []string{
"crun",
@@ -434,42 +455,55 @@ func probeConmon(conmonBinary string) error {
if err := cmd.Run(); err != nil {
return err
}
- r := regexp.MustCompile(`^conmon version (?P<Major>\d+).(?P<Minor>\d+).(?P<Patch>\d+)`)
+ r := regexp.MustCompile(`^(version:|conmon version)? (?P<Major>\d+).(?P<Minor>\d+).(?P<Patch>\d+)`)
matches := r.FindStringSubmatch(out.String())
- if len(matches) != 4 {
- return errors.New(_conmonVersionFormatErr)
+ if len(matches) != 5 {
+ return fmt.Errorf(_conmonVersionFormatErr, errors.New("invalid version format"))
+ }
+ major, err := strconv.Atoi(matches[2])
+
+ var minMajor, minMinor, minPatch int
+ // conmon-rs returns "^version:"
+ if matches[1] == "version:" {
+ minMajor = _conmonrsMinMajorVersion
+ minMinor = _conmonrsMinMinorVersion
+ minPatch = _conmonrsMinPatchVersion
+ } else {
+ minMajor = _conmonMinMajorVersion
+ minMinor = _conmonMinMinorVersion
+ minPatch = _conmonMinPatchVersion
}
- major, err := strconv.Atoi(matches[1])
+
if err != nil {
return fmt.Errorf(_conmonVersionFormatErr, err)
}
- if major < _conmonMinMajorVersion {
+ if major < minMajor {
return ErrConmonOutdated
}
- if major > _conmonMinMajorVersion {
+ if major > minMajor {
return nil
}
- minor, err := strconv.Atoi(matches[2])
+ minor, err := strconv.Atoi(matches[3])
if err != nil {
return fmt.Errorf(_conmonVersionFormatErr, err)
}
- if minor < _conmonMinMinorVersion {
+ if minor < minMinor {
return ErrConmonOutdated
}
- if minor > _conmonMinMinorVersion {
+ if minor > minMinor {
return nil
}
- patch, err := strconv.Atoi(matches[3])
+ patch, err := strconv.Atoi(matches[4])
if err != nil {
return fmt.Errorf(_conmonVersionFormatErr, err)
}
- if patch < _conmonMinPatchVersion {
+ if patch < minPatch {
return ErrConmonOutdated
}
- if patch > _conmonMinPatchVersion {
+ if patch > minPatch {
return nil
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 9cf63d41b..eb9c7a34d 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -114,7 +114,7 @@ github.com/containers/buildah/pkg/rusage
github.com/containers/buildah/pkg/sshagent
github.com/containers/buildah/pkg/util
github.com/containers/buildah/util
-# github.com/containers/common v0.49.2-0.20220809074359-b0ea008ba661
+# github.com/containers/common v0.49.2-0.20220817132854-f6679f170eca
## explicit
github.com/containers/common/libimage
github.com/containers/common/libimage/define