diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-08-16 16:01:46 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-08-17 22:39:48 +0200 |
commit | 86f665a1dabf5dd43a1715fb0f49417c92bb342f (patch) | |
tree | 9d4752414d9fb1ee028d52df33b3db3bb12ff1b3 /vendor | |
parent | 5de215e1447af96ec2b199794cd425b75a2da08a (diff) | |
download | podman-86f665a1dabf5dd43a1715fb0f49417c92bb342f.tar.gz podman-86f665a1dabf5dd43a1715fb0f49417c92bb342f.tar.bz2 podman-86f665a1dabf5dd43a1715fb0f49417c92bb342f.zip |
vendor: update containers/common
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/containers/common/pkg/config/config.go | 23 | ||||
-rw-r--r-- | vendor/github.com/containers/common/pkg/config/default.go | 60 | ||||
-rw-r--r-- | vendor/modules.txt | 2 |
3 files changed, 67 insertions, 18 deletions
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 |