When location of c/storage root changes, set VolumePath
We want named volumes to be created in a subdirectory of the c/storage graph root, the same as the libpod root directory is now. As such, we need to adjust its location when the graph root changes location. Also, make a change to how we set the default. There's no need to explicitly set it every time we initialize via an option - that might conflict with WithStorageConfig setting it based on graph root changes. Instead, just initialize it in the default config like our other settings. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
parent
8a5e103876
commit
da70c9db6f
|
|
@ -21,7 +21,7 @@ func GetRuntime(c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
|
||||||
func getRuntime(c *cliconfig.PodmanCommand, renumber bool) (*libpod.Runtime, error) {
|
func getRuntime(c *cliconfig.PodmanCommand, renumber bool) (*libpod.Runtime, error) {
|
||||||
options := []libpod.RuntimeOption{}
|
options := []libpod.RuntimeOption{}
|
||||||
|
|
||||||
storageOpts, volumePath, err := util.GetDefaultStoreOptions()
|
storageOpts, _, err := util.GetDefaultStoreOptions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -120,7 +120,6 @@ func getRuntime(c *cliconfig.PodmanCommand, renumber bool) (*libpod.Runtime, err
|
||||||
infraCommand, _ := c.Flags().GetString("infra-command")
|
infraCommand, _ := c.Flags().GetString("infra-command")
|
||||||
options = append(options, libpod.WithDefaultInfraCommand(infraCommand))
|
options = append(options, libpod.WithDefaultInfraCommand(infraCommand))
|
||||||
}
|
}
|
||||||
options = append(options, libpod.WithVolumePath(volumePath))
|
|
||||||
if c.Flags().Changed("config") {
|
if c.Flags().Changed("config") {
|
||||||
return libpod.NewRuntimeFromConfig(c.GlobalFlags.Config, options...)
|
return libpod.NewRuntimeFromConfig(c.GlobalFlags.Config, options...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,10 @@ func WithStorageConfig(config storage.StoreOptions) RuntimeOption {
|
||||||
rt.config.StaticDir = filepath.Join(config.GraphRoot, "libpod")
|
rt.config.StaticDir = filepath.Join(config.GraphRoot, "libpod")
|
||||||
rt.configuredFrom.libpodStaticDirSet = true
|
rt.configuredFrom.libpodStaticDirSet = true
|
||||||
|
|
||||||
|
// Also set libpod volume path, so we are a subdirectory
|
||||||
|
// of the c/storage store by default
|
||||||
|
rt.config.VolumePath = filepath.Join(config.GraphRoot, "volumes")
|
||||||
|
|
||||||
setField = true
|
setField = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,10 @@ type RuntimeConfig struct {
|
||||||
// Not included in on-disk config, use the dedicated containers/storage
|
// Not included in on-disk config, use the dedicated containers/storage
|
||||||
// configuration file instead
|
// configuration file instead
|
||||||
StorageConfig storage.StoreOptions `toml:"-"`
|
StorageConfig storage.StoreOptions `toml:"-"`
|
||||||
VolumePath string `toml:"volume_path"`
|
// VolumePath is the default location that named volumes will be created
|
||||||
|
// under. This convention is followed by the default volume driver, but
|
||||||
|
// may not be by other drivers.
|
||||||
|
VolumePath string `toml:"volume_path"`
|
||||||
// ImageDefaultTransport is the default transport method used to fetch
|
// ImageDefaultTransport is the default transport method used to fetch
|
||||||
// images
|
// images
|
||||||
ImageDefaultTransport string `toml:"image_default_transport"`
|
ImageDefaultTransport string `toml:"image_default_transport"`
|
||||||
|
|
@ -238,6 +241,7 @@ var (
|
||||||
defaultRuntimeConfig = RuntimeConfig{
|
defaultRuntimeConfig = RuntimeConfig{
|
||||||
// Leave this empty so containers/storage will use its defaults
|
// Leave this empty so containers/storage will use its defaults
|
||||||
StorageConfig: storage.StoreOptions{},
|
StorageConfig: storage.StoreOptions{},
|
||||||
|
VolumePath: filepath.Join(storage.DefaultStoreOptions.GraphRoot, "volumes"),
|
||||||
ImageDefaultTransport: DefaultTransport,
|
ImageDefaultTransport: DefaultTransport,
|
||||||
StateType: BoltDBStateStore,
|
StateType: BoltDBStateStore,
|
||||||
OCIRuntime: "runc",
|
OCIRuntime: "runc",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue