Skip to content

Commit

Permalink
Add new storage.conf option "transient_store"
Browse files Browse the repository at this point in the history
This just adds the support for setting and handling this key, it
doesn't really do anything yet.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
  • Loading branch information
alexlarsson committed Nov 8, 2022
1 parent a6c46b0 commit bb54554
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions storage.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ graphroot = "/var/lib/containers/storage"
#
# rootless_storage_path = "$HOME/.local/share/containers/storage"

# Transient store mode makes all container metadata be saved in temporary storage
# (i.e. runroot above). This is faster, but doesn't persist across reboots.
# transient_store = true

[storage.options]
# Storage options to be passed to underlying storage drivers

Expand Down
7 changes: 7 additions & 0 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ type Store interface {
// settings that were passed to GetStore() when the object was created.
RunRoot() string
GraphRoot() string
TransientStore() bool
GraphDriverName() string
GraphOptions() []string
PullOptions() map[string]string
Expand Down Expand Up @@ -594,6 +595,7 @@ type store struct {
containerStore rwContainerStore
digestLockRoot string
disableVolatile bool
transientStore bool
}

// GetStore attempts to find an already-created Store object matching the
Expand Down Expand Up @@ -701,6 +703,7 @@ func GetStore(options types.StoreOptions) (Store, error) {
additionalGIDs: nil,
usernsLock: usernsLock,
disableVolatile: options.DisableVolatile,
transientStore: options.TransientStore,
pullOptions: options.PullOptions,
}
if err := s.load(); err != nil {
Expand Down Expand Up @@ -748,6 +751,10 @@ func (s *store) GraphRoot() string {
return s.graphRoot
}

func (s *store) TransientStore() bool {
return s.transientStore
}

func (s *store) GraphOptions() []string {
return s.graphOptions
}
Expand Down
4 changes: 4 additions & 0 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type TomlConfig struct {
RunRoot string `toml:"runroot,omitempty"`
GraphRoot string `toml:"graphroot,omitempty"`
RootlessStoragePath string `toml:"rootless_storage_path,omitempty"`
TransientStore bool `toml:"transient_store,omitempty"`
Options cfg.OptionsConfig `toml:"options,omitempty"`
} `toml:"storage"`
}
Expand Down Expand Up @@ -234,6 +235,8 @@ type StoreOptions struct {
PullOptions map[string]string `toml:"pull_options"`
// DisableVolatile doesn't allow volatile mounts when it is set.
DisableVolatile bool `json:"disable-volatile,omitempty"`
// If transient, don't persist containers over boot (stores db in runroot)
TransientStore bool `json:"transient_store,omitempty"`
}

// isRootlessDriver returns true if the given storage driver is valid for containers running as non root
Expand Down Expand Up @@ -452,6 +455,7 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) erro
}

storeOptions.DisableVolatile = config.Storage.Options.DisableVolatile
storeOptions.TransientStore = config.Storage.TransientStore

storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, cfg.GetGraphDriverOptions(storeOptions.GraphDriverName, config.Storage.Options)...)

Expand Down

0 comments on commit bb54554

Please sign in to comment.