-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returns more than one additional image store #2096
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,8 +457,11 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) erro | |
if config.Storage.RootlessStoragePath != "" { | ||
storeOptions.RootlessStoragePath = config.Storage.RootlessStoragePath | ||
} | ||
for _, s := range config.Storage.Options.AdditionalImageStores { | ||
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, fmt.Sprintf("%s.imagestore=%s", config.Storage.Driver, s)) | ||
if len(config.Storage.Options.AdditionalImageStores) > 0 { | ||
imageStore := config.Storage.Options.AdditionalImageStores[0] | ||
additionalImageStores := strings.Join(config.Storage.Options.AdditionalImageStores, ",") | ||
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, fmt.Sprintf("%s.imagestore=%s", config.Storage.Driver, imageStore)) | ||
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, fmt.Sprintf("%s.additionalimagestores=%s", config.Storage.Driver, additionalImageStores)) | ||
Comment on lines
+463
to
+464
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can’t see any parser of a driver All entries in I especially don’t know why we would now add the first item twice. Also, if you look at the drivers’ option parsers, for the |
||
} | ||
for _, s := range config.Storage.Options.AdditionalLayerStores { | ||
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, fmt.Sprintf("%s.additionallayerstore=%s", config.Storage.Driver, s)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,13 +125,52 @@ func TestGetRootlessStorageOpts2(t *testing.T) { | |
} | ||
|
||
func TestReloadConfigurationFile(t *testing.T) { | ||
content := bytes.NewBufferString("") | ||
logrus.SetOutput(content) | ||
var storageOpts StoreOptions | ||
err := ReloadConfigurationFile("./storage_broken.conf", &storageOpts) | ||
require.NoError(t, err) | ||
assert.Equal(t, storageOpts.RunRoot, "/run/containers/test") | ||
logrus.SetOutput(os.Stderr) | ||
|
||
assert.Equal(t, strings.Contains(content.String(), "Failed to decode the keys [\\\"foo\\\" \\\"storage.options.graphroot\\\"] from \\\"./storage_broken.conf\\\"\""), true) | ||
t.Run("broken", func(t *testing.T) { | ||
content := bytes.NewBufferString("") | ||
logrus.SetOutput(content) | ||
var storageOpts StoreOptions | ||
err := ReloadConfigurationFile("./storage_broken.conf", &storageOpts) | ||
require.NoError(t, err) | ||
assert.Equal(t, storageOpts.RunRoot, "/run/containers/test") | ||
logrus.SetOutput(os.Stderr) | ||
assert.Equal(t, strings.Contains(content.String(), "Failed to decode the keys [\\\"foo\\\" \\\"storage.options.graphroot\\\"] from \\\"./storage_broken.conf\\\"\""), true) | ||
}) | ||
t.Run("imagestore-empty", func(t *testing.T) { | ||
expectedStore := "" | ||
expectedAdditionalStores := "" | ||
var storageOpts StoreOptions | ||
err := ReloadConfigurationFile("./storage_test.conf", &storageOpts) | ||
require.NoError(t, err) | ||
var actualStore, actualAdditionalStores string | ||
for _, o := range storageOpts.GraphDriverOptions { | ||
option := strings.Split(o, "=") | ||
switch option[0] { | ||
case storageOpts.GraphDriverName + ".imagestore": | ||
actualStore = option[1] | ||
case storageOpts.GraphDriverName + ".additionalimagestores": | ||
actualAdditionalStores = option[1] | ||
} | ||
} | ||
assert.Equal(t, actualStore, expectedStore) | ||
assert.Equal(t, actualAdditionalStores, expectedAdditionalStores) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (The parameter order is |
||
}) | ||
t.Run("imagestore-many", func(t *testing.T) { | ||
expectedStore := "/var/lib/containers/storage1" | ||
expectedAdditionalStores := "/var/lib/containers/storage1,/var/lib/containers/storage2" | ||
var storageOpts StoreOptions | ||
err := ReloadConfigurationFile("./storage_imagestores_test.conf", &storageOpts) | ||
require.NoError(t, err) | ||
var actualStore, actualAdditionalStores string | ||
for _, o := range storageOpts.GraphDriverOptions { | ||
option := strings.Split(o, "=") | ||
switch option[0] { | ||
case storageOpts.GraphDriverName + ".imagestore": | ||
actualStore = option[1] | ||
case storageOpts.GraphDriverName + ".additionalimagestores": | ||
actualAdditionalStores = option[1] | ||
} | ||
} | ||
assert.Equal(t, actualStore, expectedStore) | ||
assert.Equal(t, actualAdditionalStores, expectedAdditionalStores) | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[storage.options] | ||
additionalimagestores = [ | ||
"/var/lib/containers/storage1", | ||
"/var/lib/containers/storage2" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed to this way of doing things, but I think it'd be conceptually cleaner to add a new API field that was an array/list.
Squashing an array to a string like this comma-separated raises questions around e.g. "what happens if the store path has a comma in it" - to be clear not something that really we'd expect to happen in this case.
But as a general case these things can happen, and ad-hoc "stringification" can become a problem.
There's also the flip side in that in theory something could have been reading the prior field and relying on it only containing (the top?) store, and suddenly seeing multiple paths there would break a prior consumer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be specified multiple times, e.g.
podman --storage-opt overlay.additionalimagestore=/tmp/1 --storage-opt overlay.additionalimagestore=/tmp/2 ...
works fine.So instead of combining multiple additional image stores in a single option, we can have multiple
additionalimagestore
, one for each directory.Said so, we don't currently support commas in the path, as we have an explicit
strings.Split(val, ",")
inoverlay.go
.