Merge pull request #6341 from nalind/add-imagestore-flag

Support "--imagestore" global flags
This commit is contained in:
openshift-merge-bot[bot] 2025-08-15 23:38:01 +00:00 committed by GitHub
commit b7de827961
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 28 additions and 5 deletions

View File

@ -32,6 +32,9 @@ func getStore(c *cobra.Command) (storage.Store, error) {
options.GraphRoot = globalFlagResults.Root
options.RunRoot = globalFlagResults.RunRoot
}
if c.Flag("imagestore").Changed {
options.ImageStore = globalFlagResults.ImageStore
}
if c.Flag("storage-driver").Changed {
options.GraphDriverName = globalFlagResults.StorageDriver
// If any options setup in config, these should be dropped if user overrode the driver

View File

@ -29,6 +29,7 @@ func TestMain(m *testing.M) {
flag.StringVar(&options.GraphRoot, "root", "", "storage root dir")
flag.StringVar(&options.RunRoot, "runroot", "", "storage state dir")
flag.StringVar(&options.GraphDriverName, "storage-driver", "", "storage driver")
flag.StringVar(&options.ImageStore, "imagestore", "", "storage imagestore")
flag.StringVar(&testSystemContext.SystemRegistriesConfPath, "registries-conf", "", "registries list")
flag.BoolVar(&debug, "debug", false, "turn on debug logging")
flag.Parse()
@ -58,6 +59,7 @@ func TestGetStore(t *testing.T) {
flags := testCmd.PersistentFlags()
flags.String("root", storeOptions.GraphRoot, "")
flags.String("runroot", storeOptions.RunRoot, "")
flags.String("imagestore", storeOptions.ImageStore, "")
flags.String("storage-driver", storeOptions.GraphDriverName, "")
flags.String("signature-policy", "", "")
if err := flags.MarkHidden("signature-policy"); err != nil {

View File

@ -28,6 +28,7 @@ type globalFlags struct {
LogLevel string
Root string
RunRoot string
ImageStore string
StorageDriver string
RegistriesConf string
RegistriesConfDir string
@ -98,6 +99,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&globalFlagResults.RunRoot, "runroot", storageOptions.RunRoot, "storage state dir")
rootCmd.PersistentFlags().StringVar(&globalFlagResults.CgroupManager, "cgroup-manager", defaultContainerConfig.Engine.CgroupManager, "cgroup manager")
rootCmd.PersistentFlags().StringVar(&globalFlagResults.StorageDriver, "storage-driver", storageOptions.GraphDriverName, "storage-driver")
rootCmd.PersistentFlags().StringVar(&globalFlagResults.ImageStore, "imagestore", storageOptions.ImageStore, "storage imagestore")
rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.StorageOpts, "storage-opt", defaultStoreDriverOptions, "storage driver option")
rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.UserNSUID, "userns-uid-map", []string{}, "default `ctrID:hostID:length` UID mapping to use")
rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.UserNSGID, "userns-gid-map", []string{}, "default `ctrID:hostID:length` GID mapping to use")

View File

@ -27,6 +27,15 @@ The CGroup manager to use for container cgroups. Supported values are cgroupfs o
Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type.
Note: CGroup manager is not supported in rootless mode when using CGroups Version V1.
**--imagestore** *path*
Path under which content for pulled and built images will be stored. By default, the configured **--root** location
is used for pulled and built images as well as containers. If the storage driver is
*overlay*, then any images which have previously been written to the **--root** location will still
be available.
This will override the *imagestore* option in containers-storage.conf(5).
**--log-level** **value**
The log level to be used. Either "trace", "debug", "info", "warn", "error", "fatal", or "panic", defaulting to "warn".
@ -53,13 +62,13 @@ be used, as the default behavior of using the system-wide configuration
**--root** **value**
Storage root dir (default: "/var/lib/containers/storage" for UID 0, "$HOME/.local/share/containers/storage" for other users)
Default root dir is configured in /etc/containers/storage.conf
Storage root dir (default: "/var/lib/containers/storage" for UID 0, "$HOME/.local/share/containers/storage" for other users).
The default root dir is configured in /etc/containers/storage.conf.
**--runroot** **value**
Storage state dir (default: "/run/containers/storage" for UID 0, "/run/user/$UID" for other users)
Default state dir is configured in /etc/containers/storage.conf
Storage state dir (default: "/run/containers/storage" for UID 0, "/run/user/$UID" for other users).
The default state dir is configured in /etc/containers/storage.conf.
**--short-name-alias-conf** *path*

View File

@ -133,6 +133,7 @@ func storeInfo(store storage.Store) (map[string]any, error) {
info := map[string]any{}
info["GraphRoot"] = store.GraphRoot()
info["RunRoot"] = store.RunRoot()
info["GraphImageStore"] = store.ImageStore()
info["GraphDriverName"] = store.GraphDriverName()
info["GraphOptions"] = store.GraphOptions()
statusPairs, err := store.Status()
@ -144,6 +145,7 @@ func storeInfo(store storage.Store) (map[string]any, error) {
status[pair[0]] = pair[1]
}
info["GraphStatus"] = status
images, err := store.Images()
if err != nil {
logrus.Error(err, "error getting number of images")

View File

@ -141,6 +141,7 @@ func main() {
rootCmd.PersistentFlags().StringVar(&storeOptions.GraphRoot, "root", "", "storage root")
rootCmd.PersistentFlags().StringVar(&storeOptions.RunRoot, "runroot", "", "runtime root")
rootCmd.PersistentFlags().StringVar(&storeOptions.ImageStore, "imagestore", "", "storage imagestore")
rootCmd.PersistentFlags().StringVar(&storeOptions.GraphDriverName, "storage-driver", "", "storage driver")
rootCmd.PersistentFlags().StringSliceVar(&storeOptions.GraphDriverOptions, "storage-opt", nil, "storage option")
rootCmd.PersistentFlags().StringVar(&systemContext.SystemRegistriesConfPath, "registries-conf", "", "location of registries.conf")

View File

@ -391,7 +391,7 @@ function run_buildah() {
retry=$(( retry - 1 ))
# stdout is only emitted upon error; this echo is to help a debugger
echo "${_LOG_PROMPT} $BUILDAH_BINARY $*"
echo "${_LOG_PROMPT} ${BUILDAH_BINARY} $*"
run env CONTAINERS_CONF=${CONTAINERS_CONF:-$(dirname ${BASH_SOURCE})/containers.conf} timeout --foreground --kill=10 $BUILDAH_TIMEOUT ${BUILDAH_BINARY} ${BUILDAH_REGISTRY_OPTS} ${ROOTDIR_OPTS} "$@"
# without "quotes", multiple lines are glommed together into one
if [ -n "$output" ]; then

View File

@ -40,6 +40,7 @@ func main() {
root := flag.String("root", storeOptions.GraphRoot, "storage root directory")
runroot := flag.String("runroot", storeOptions.RunRoot, "storage runtime directory")
driver := flag.String("storage-driver", storeOptions.GraphDriverName, "storage driver")
imagestore := flag.String("imagestore", storeOptions.ImageStore, "storage imagestore")
opts := flag.String("storage-opts", "", "storage option list (comma separated)")
policy := flag.String("signature-policy", "", "signature policy file")
mtype := flag.String("expected-manifest-type", define.OCIv1ImageManifest, "expected manifest type")
@ -77,6 +78,9 @@ func main() {
storeOptions.GraphDriverName = *driver
storeOptions.GraphDriverOptions = nil
}
if imagestore != nil {
storeOptions.ImageStore = *imagestore
}
if opts != nil && *opts != "" {
storeOptions.GraphDriverOptions = strings.Split(*opts, ",")
}