Also force an update of c/image to prevent a downgrade.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-02-20 16:09:01 +01:00
parent bac20d1917
commit adacd3b127
123 changed files with 10220 additions and 10917 deletions

View File

@@ -251,6 +251,9 @@ type EngineConfig struct {
// in containers-registries.conf(5).
CompatAPIEnforceDockerHub bool `toml:"compat_api_enforce_docker_hub,omitempty"`
// DBBackend is the database backend to be used by Podman.
DBBackend string `toml:"database_backend,omitempty"`
// DetachKeys is the sequence of keys used to detach a container.
DetachKeys string `toml:"detach_keys,omitempty"`
@@ -609,7 +612,7 @@ type MachineConfig struct {
CPUs uint64 `toml:"cpus,omitempty,omitzero"`
// DiskSize is the size of the disk in GB created when init-ing a podman-machine VM
DiskSize uint64 `toml:"disk_size,omitempty,omitzero"`
// MachineImage is the image used when init-ing a podman-machine VM
// Image is the image used when init-ing a podman-machine VM
Image string `toml:"image,omitempty"`
// Memory in MB a machine is created with.
Memory uint64 `toml:"memory,omitempty,omitzero"`
@@ -617,6 +620,8 @@ type MachineConfig struct {
User string `toml:"user,omitempty"`
// Volumes are host directories mounted into the VM by default.
Volumes []string `toml:"volumes"`
// Provider is the virtualization provider used to run podman-machine VM
Provider string `toml:"provider,omitempty"`
}
// Destination represents destination for remote service
@@ -896,6 +901,11 @@ func (c *EngineConfig) Validate() error {
if _, err := ValidatePullPolicy(pullPolicy); err != nil {
return fmt.Errorf("invalid pull type from containers.conf %q: %w", c.PullPolicy, err)
}
if _, err := ParseDBBackend(c.DBBackend); err != nil {
return err
}
return nil
}
@@ -1330,9 +1340,13 @@ func (c *Config) FindHelperBinary(name string, searchPATH bool) (string, error)
path = filepath.Join(bindirPath, strings.TrimPrefix(path, bindirPrefix+string(filepath.Separator)))
}
}
fullpath := filepath.Join(path, name)
if fi, err := os.Stat(fullpath); err == nil && fi.Mode().IsRegular() {
return fullpath, nil
// Absolute path will force exec.LookPath to check for binary existence instead of lookup everywhere in PATH
if abspath, err := filepath.Abs(filepath.Join(path, name)); err == nil {
// exec.LookPath from absolute path on Unix is equal to os.Stat + IsNotDir + check for executable bits in FileMode
// exec.LookPath from absolute path on Windows is equal to os.Stat + IsNotDir for `file.ext` or loops through extensions from PATHEXT for `file`
if lp, err := exec.LookPath(abspath); err == nil {
return lp, nil
}
}
}
if searchPATH {

View File

@@ -693,7 +693,7 @@ default_sysctls = [
# "https://example.com/linux/amd64/foobar.ami" on a Linux AMD machine.
# The default value is `testing`.
#
# image = "testing"
#image = "testing"
# Memory in MB a machine is created with.
#
@@ -709,10 +709,15 @@ default_sysctls = [
# the source and destination. An optional third field `:ro` can be used to
# tell the container engines to mount the volume readonly.
#
# volumes = [
#volumes = [
# "$HOME:$HOME",
#]
# Virtualization provider used to run Podman machine.
# If it is empty or commented out, the default provider will be used.
#
#provider = ""
# The [machine] table MUST be the last entry in this file.
# (Unless another table is added)
# TOML does not provide a way to end a table other than a further table being

View File

@@ -626,10 +626,15 @@ default_sysctls = [
# the source and destination. An optional third field `:ro` can be used to
# tell the container engines to mount the volume readonly.
#
# volumes = [
#volumes = [
# "$HOME:$HOME",
#]
# Virtualization provider used to run Podman machine.
# If it is empty or commented out, the default provider will be used.
#
#provider = ""
# The [machine] table MUST be the last entry in this file.
# (Unless another table is added)
# TOML does not provide a way to end a table other than a further table being

View File

@@ -0,0 +1,60 @@
package config
import "fmt"
// DBBackend determines which supported database backend Podman should use.
type DBBackend int
const (
// Unsupported database backend. Used as a sane base value for the type.
DBBackendUnsupported DBBackend = iota
// BoltDB backend.
DBBackendBoltDB
// SQLite backend.
DBBackendSQLite
stringBoltDB = "boltdb"
stringSQLite = "sqlite"
)
// String returns the DBBackend's string representation.
func (d DBBackend) String() string {
switch d {
case DBBackendBoltDB:
return stringBoltDB
case DBBackendSQLite:
return stringSQLite
default:
return fmt.Sprintf("unsupported database backend: %d", d)
}
}
// Validate returns whether the DBBackend is supported.
func (d DBBackend) Validate() error {
switch d {
case DBBackendBoltDB, DBBackendSQLite:
return nil
default:
return fmt.Errorf("unsupported database backend: %d", d)
}
}
// ParseDBBackend parses the specified string into a DBBackend.
// An error is return for unsupported backends.
func ParseDBBackend(raw string) (DBBackend, error) {
// NOTE: this function should be used for parsing the user-specified
// values on Podman's CLI.
switch raw {
case stringBoltDB:
return DBBackendBoltDB, nil
case stringSQLite:
return DBBackendSQLite, nil
default:
return DBBackendUnsupported, fmt.Errorf("unsupported database backend: %q", raw)
}
}
// DBBackend returns the configured database backend.
func (c *Config) DBBackend() (DBBackend, error) {
return ParseDBBackend(c.Engine.DBBackend)
}

View File

@@ -104,6 +104,8 @@ const (
CgroupfsCgroupsManager = "cgroupfs"
// DefaultApparmorProfile specifies the default apparmor profile for the container.
DefaultApparmorProfile = apparmor.Profile
// DefaultDBBackend specifies the default database backend to be used by Podman.
DefaultDBBackend = DBBackendBoltDB
// DefaultHostsFile is the default path to the hosts file.
DefaultHostsFile = "/etc/hosts"
// SystemdCgroupsManager represents systemd native cgroup manager.
@@ -387,6 +389,7 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
"/run/current-system/sw/bin/conmonrs",
}
c.PullPolicy = DefaultPullPolicy
c.DBBackend = stringBoltDB
c.RuntimeSupportsJSON = []string{
"crun",
"runc",