Set default storage from containers.conf for temporary images

Fixes: https://github.com/containers/podman/issues/11107

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2021-09-15 10:41:52 -04:00
parent 81f41ca0d2
commit 3e77f960f6
13 changed files with 162 additions and 72 deletions

View File

@ -234,6 +234,9 @@ type EngineConfig struct {
// EventsLogger determines where events should be logged.
EventsLogger string `toml:"events_logger,omitempty"`
// graphRoot internal stores the location of the graphroot
graphRoot string
// HelperBinariesDir is a list of directories which are used to search for
// helper binaries.
HelperBinariesDir []string `toml:"helper_binaries_dir"`
@ -384,6 +387,12 @@ type EngineConfig struct {
// before sending kill signal.
StopTimeout uint `toml:"stop_timeout,omitempty"`
// ImageCopyTmpDir is the default location for storing temporary
// container image content, Can be overridden with the TMPDIR
// environment variable. If you specify "storage", then the
// location of the container/storage tmp directory will be used.
ImageCopyTmpDir string `toml:"image_copy_tmp_dir,omitempty"`
// TmpDir is the path to a temporary directory to store per-boot container
// files. Must be stored in a tmpfs.
TmpDir string `toml:"tmp_dir,omitempty"`
@ -1148,3 +1157,22 @@ func (c *Config) FindHelperBinary(name string, searchPATH bool) (string, error)
}
return "", errors.Errorf("could not find %q in one of %v", name, c.Engine.HelperBinariesDir)
}
// ImageCopyTmpDir default directory to store tempory image files during copy
func (c *Config) ImageCopyTmpDir() (string, error) {
if path, found := os.LookupEnv("TMPDIR"); found {
return path, nil
}
switch c.Engine.ImageCopyTmpDir {
case "":
return "", nil
case "storage":
return filepath.Join(c.Engine.graphRoot, "tmp"), nil
default:
if filepath.IsAbs(c.Engine.ImageCopyTmpDir) {
return c.Engine.ImageCopyTmpDir, nil
}
}
return "", errors.Errorf("invalid image_copy_tmp_dir value %q (relative paths are not accepted)", c.Engine.ImageCopyTmpDir)
}

View File

@ -451,15 +451,20 @@ default_sysctls = [
# List of the OCI runtimes that support --format=json. When json is supported
# engine will use it for reporting nicer errors.
#
#runtime_supports_json = ["crun", "runc", "kata", "runsc"]
#runtime_supports_json = ["crun", "runc", "kata", "runsc", "krun"]
# List of the OCI runtimes that supports running containers with KVM Separation.
#
#runtime_supports_kvm = ["kata"]
#runtime_supports_kvm = ["kata", "krun"]
# List of the OCI runtimes that supports running containers without cgroups.
#
#runtime_supports_nocgroups = ["crun"]
#runtime_supports_nocgroups = ["crun", "krun"]
# Default location for storing temporary container image content. Can be overridden with the TMPDIR environment
# variable. If you specify "storage", then the location of the
# container/storage tmp directory will be used.
# image_copy_tmp_dir="/var/tmp"
# Directory for persistent engine files (database, etc)
# By default, this will be configured relative to where the containers/storage
@ -498,7 +503,7 @@ default_sysctls = [
#
#volume_path = "/var/lib/containers/storage/volumes"
# Paths to look for a valid OCI runtime (crun, runc, kata, runsc, etc)
# Paths to look for a valid OCI runtime (crun, runc, kata, runsc, krun, etc)
[engine.runtimes]
#crun = [
# "/usr/bin/crun",
@ -541,6 +546,11 @@ default_sysctls = [
# "/run/current-system/sw/bin/runsc",
#]
#krun = [
# "/usr/bin/krun",
# "/usr/local/bin/krun",
#]
[engine.volume_plugins]
#testplugin = "/run/podman/plugins/test.sock"

View File

@ -244,6 +244,8 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
logrus.Warnf("Storage configuration is unset - using hardcoded default graph root %q", _defaultGraphRoot)
storeOpts.GraphRoot = _defaultGraphRoot
}
c.graphRoot = storeOpts.GraphRoot
c.ImageCopyTmpDir = "/var/tmp"
c.StaticDir = filepath.Join(storeOpts.GraphRoot, "libpod")
c.VolumePath = filepath.Join(storeOpts.GraphRoot, "volumes")
@ -297,6 +299,10 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
"/sbin/runsc",
"/run/current-system/sw/bin/runsc",
},
"krun": {
"/usr/bin/krun",
"/usr/local/bin/krun",
},
}
// Needs to be called after populating c.OCIRuntimes
c.OCIRuntime = c.findRuntime()
@ -320,9 +326,10 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
"runc",
"kata",
"runsc",
"krun",
}
c.RuntimeSupportsNoCgroups = []string{"crun"}
c.RuntimeSupportsKVM = []string{"kata", "kata-runtime", "kata-qemu", "kata-fc"}
c.RuntimeSupportsNoCgroups = []string{"crun", "krun"}
c.RuntimeSupportsKVM = []string{"kata", "kata-runtime", "kata-qemu", "kata-fc", "krun"}
c.InitPath = DefaultInitPath
c.NoPivotRoot = false

View File

@ -1,4 +1,4 @@
package version
// Version is the version of the build.
const Version = "0.44.0"
const Version = "0.44.1-dev"