runtime: Handle the transient store options

This handles the transient store options from the container/storage
configuration in the runtime/engine.

Changes are:
 * Print transient store status in `podman info`
 * Print transient store status in runtime debug output
 * Add --transient-store argument to override config option
 * Propagate config state to conmon cleanup args so the callback podman
   gets the same config.

Note: This doesn't really change any behaviour yet (other than the changes
in containers/storage).

Signed-off-by: Alexander Larsson <alexl@redhat.com>
This commit is contained in:
Alexander Larsson
2022-11-09 11:34:18 +01:00
parent 56115d5e5b
commit 25d9af8f42
10 changed files with 38 additions and 6 deletions

View File

@ -464,6 +464,8 @@ func rootFlags(cmd *cobra.Command, podmanConfig *entities.PodmanConfig) {
pFlags.StringVar(&podmanConfig.Runroot, runrootFlagName, "", "Path to the 'run directory' where all state information is stored") pFlags.StringVar(&podmanConfig.Runroot, runrootFlagName, "", "Path to the 'run directory' where all state information is stored")
_ = cmd.RegisterFlagCompletionFunc(runrootFlagName, completion.AutocompleteDefault) _ = cmd.RegisterFlagCompletionFunc(runrootFlagName, completion.AutocompleteDefault)
pFlags.BoolVar(&podmanConfig.TransientStore, "transient-store", false, "Enable transient container storage")
runtimeFlagName := "runtime" runtimeFlagName := "runtime"
pFlags.StringVar(&podmanConfig.RuntimePath, runtimeFlagName, podmanConfig.ContainersConfDefaultsRO.Engine.OCIRuntime, "Path to the OCI-compatible binary used to run containers.") pFlags.StringVar(&podmanConfig.RuntimePath, runtimeFlagName, podmanConfig.ContainersConfDefaultsRO.Engine.OCIRuntime, "Path to the OCI-compatible binary used to run containers.")
_ = cmd.RegisterFlagCompletionFunc(runtimeFlagName, completion.AutocompleteDefault) _ = cmd.RegisterFlagCompletionFunc(runtimeFlagName, completion.AutocompleteDefault)

View File

@ -146,6 +146,7 @@ store:
imageStore: imageStore:
number: 5 number: 5
runRoot: /run/user/3267/containers runRoot: /run/user/3267/containers
transientStore: false
volumePath: /home/dwalsh/.local/share/containers/storage/volumes volumePath: /home/dwalsh/.local/share/containers/storage/volumes
version: version:
APIVersion: 4.0.0 APIVersion: 4.0.0
@ -263,7 +264,8 @@ $ podman info --format json
"number": 5 "number": 5
}, },
"runRoot": "/run/user/3267/containers", "runRoot": "/run/user/3267/containers",
"volumePath": "/home/dwalsh/.local/share/containers/storage/volumes" "volumePath": "/home/dwalsh/.local/share/containers/storage/volumes",
"transientStore": false
}, },
"registries": { "registries": {
"search": [ "search": [

View File

@ -162,6 +162,14 @@ Path to the tmp directory, for libpod runtime content. Defaults to `$XDG_RUNTIME
NOTE --tmpdir is not used for the temporary storage of downloaded images. Use the environment variable `TMPDIR` to change the temporary storage location of downloaded container images. Podman defaults to use `/var/tmp`. NOTE --tmpdir is not used for the temporary storage of downloaded images. Use the environment variable `TMPDIR` to change the temporary storage location of downloaded container images. Podman defaults to use `/var/tmp`.
#### **--transient-store**
Enables a global transient storaga mode where all container metadata is stored on non-persistant media (i.e. in the location specified by `--runroot`).
This mode allows starting containers faster, as well as guaranteeing a fresh state on boot in case of unclean shutdowns or other problems. However
it is not compabible with a traditional model where containers persist across reboots.
Default value for this is configured in `/etc/containers/storage.conf`.
#### **--url**=*value* #### **--url**=*value*
URL to access Podman service (default from `containers.conf`, rootless `unix://run/user/$UID/podman/podman.sock` or as root `unix://run/podman/podman.sock`). URL to access Podman service (default from `containers.conf`, rootless `unix://run/user/$UID/podman/podman.sock` or as root `unix://run/podman/podman.sock`).
Setting this option will switch the **--remote** option to true. Setting this option will switch the **--remote** option to true.

View File

@ -118,6 +118,7 @@ type StoreInfo struct {
ImageStore ImageStore `json:"imageStore"` ImageStore ImageStore `json:"imageStore"`
RunRoot string `json:"runRoot"` RunRoot string `json:"runRoot"`
VolumePath string `json:"volumePath"` VolumePath string `json:"volumePath"`
TransientStore bool `json:"transientStore"`
} }
// ImageStore describes the image store. Right now only the number // ImageStore describes the image store. Right now only the number

View File

@ -226,6 +226,7 @@ func (r *Runtime) storeInfo() (*define.StoreInfo, error) {
GraphOptions: nil, GraphOptions: nil,
VolumePath: r.config.Engine.VolumePath, VolumePath: r.config.Engine.VolumePath,
ConfigFile: configFile, ConfigFile: configFile,
TransientStore: r.store.TransientStore(),
} }
graphOptions := map[string]interface{}{} graphOptions := map[string]interface{}{}

View File

@ -109,6 +109,18 @@ func WithStorageConfig(config storage.StoreOptions) RuntimeOption {
} }
} }
func WithTransientStore(transientStore bool) RuntimeOption {
return func(rt *Runtime) error {
if rt.valid {
return define.ErrRuntimeFinalized
}
rt.storageConfig.TransientStore = transientStore
return nil
}
}
// WithSignaturePolicy specifies the path of a file which decides how trust is // WithSignaturePolicy specifies the path of a file which decides how trust is
// managed for images we've pulled. // managed for images we've pulled.
// If this is not specified, the system default configuration will be used // If this is not specified, the system default configuration will be used

View File

@ -396,6 +396,7 @@ func makeRuntime(runtime *Runtime) (retErr error) {
logrus.Debugf("Using static dir %s", runtime.config.Engine.StaticDir) logrus.Debugf("Using static dir %s", runtime.config.Engine.StaticDir)
logrus.Debugf("Using tmp dir %s", runtime.config.Engine.TmpDir) logrus.Debugf("Using tmp dir %s", runtime.config.Engine.TmpDir)
logrus.Debugf("Using volume path %s", runtime.config.Engine.VolumePath) logrus.Debugf("Using volume path %s", runtime.config.Engine.VolumePath)
logrus.Debugf("Using transient store: %v", runtime.storageConfig.TransientStore)
// Validate our config against the database, now that we've set our // Validate our config against the database, now that we've set our
// final storage configuration // final storage configuration

View File

@ -55,4 +55,5 @@ type PodmanConfig struct {
StorageOpts []string StorageOpts []string
SSHMode string SSHMode string
MachineMode bool MachineMode bool
TransientStore bool
} }

View File

@ -171,6 +171,9 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo
storageOpts.GraphDriverOptions = cfg.StorageOpts storageOpts.GraphDriverOptions = cfg.StorageOpts
} }
} }
if fs.Changed("transient-store") {
options = append(options, libpod.WithTransientStore(cfg.TransientStore))
}
if opts.migrate { if opts.migrate {
options = append(options, libpod.WithMigrate()) options = append(options, libpod.WithMigrate())
if opts.name != "" { if opts.name != "" {

View File

@ -282,6 +282,7 @@ func CreateExitCommandArgs(storageConfig storageTypes.StoreOptions, config *conf
"--network-config-dir", config.Network.NetworkConfigDir, "--network-config-dir", config.Network.NetworkConfigDir,
"--network-backend", config.Network.NetworkBackend, "--network-backend", config.Network.NetworkBackend,
"--volumepath", config.Engine.VolumePath, "--volumepath", config.Engine.VolumePath,
fmt.Sprintf("--transient-store=%t", storageConfig.TransientStore),
} }
if config.Engine.OCIRuntime != "" { if config.Engine.OCIRuntime != "" {
command = append(command, []string{"--runtime", config.Engine.OCIRuntime}...) command = append(command, []string{"--runtime", config.Engine.OCIRuntime}...)