diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-10-15 13:14:39 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2021-10-18 14:44:10 -0400 |
commit | 087f8fc73bec664a30dcf0757cd3cb44ea150582 (patch) | |
tree | b2a04eb4de47d044c6644dcc2da366935a0f9214 /libpod | |
parent | e0ffc431fe7f016124fdcb36819698a90fe448a9 (diff) | |
download | podman-087f8fc73bec664a30dcf0757cd3cb44ea150582.tar.gz podman-087f8fc73bec664a30dcf0757cd3cb44ea150582.tar.bz2 podman-087f8fc73bec664a30dcf0757cd3cb44ea150582.zip |
Allow API to specify size and inode quota
Fixes: https://github.com/containers/podman/issues/11016
[NO NEW TESTS NEEDED] We have no easy way to tests this in
CI/CD systems. Requires quota to be setup on directories to work.
Fixes: https://github.com/containers/podman/issues/11016
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_config.go | 2 | ||||
-rw-r--r-- | libpod/container_internal.go | 12 | ||||
-rw-r--r-- | libpod/options.go | 11 |
3 files changed, 25 insertions, 0 deletions
diff --git a/libpod/container_config.go b/libpod/container_config.go index 54d102a71..33ea731fd 100644 --- a/libpod/container_config.go +++ b/libpod/container_config.go @@ -153,6 +153,8 @@ type ContainerRootFSConfig struct { Secrets []*ContainerSecret `json:"secrets,omitempty"` // SecretPath is the secrets location in storage SecretsPath string `json:"secretsPath"` + // StorageOpts to be used when creating rootfs + StorageOpts map[string]string `json:"storageOpts"` // Volatile specifies whether the container storage can be optimized // at the cost of not syncing all the dirty files in memory. Volatile bool `json:"volatile,omitempty"` diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 4e8074840..a7315dd55 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -443,6 +443,18 @@ func (c *Container) setupStorage(ctx context.Context) error { }, LabelOpts: c.config.LabelOpts, } + + nopts := len(c.config.StorageOpts) + if nopts > 0 { + options.StorageOpt = make(map[string]string, nopts) + for _, opt := range c.config.StorageOpts { + split2 := strings.SplitN(opt, "=", 2) + if len(split2) > 2 { + return errors.Wrapf(define.ErrInvalidArg, "invalid storage options %q for %s", opt, c.ID()) + } + options.StorageOpt[split2[0]] = split2[1] + } + } if c.restoreFromCheckpoint && !c.config.Privileged { // If restoring from a checkpoint, the root file-system // needs to be mounted with the same SELinux labels as diff --git a/libpod/options.go b/libpod/options.go index 553af43fd..9762de67e 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -310,6 +310,17 @@ func WithCDI(devices []string) CtrCreateOption { } } +// WithStorageOpts sets the devices to check for for CDI configuration. +func WithStorageOpts(storageOpts map[string]string) CtrCreateOption { + return func(ctr *Container) error { + if ctr.valid { + return define.ErrCtrFinalized + } + ctr.config.StorageOpts = storageOpts + return nil + } +} + // WithDefaultMountsFile sets the file to look at for default mounts (mainly // secrets). // Note we are not saving this in the database as it is for testing purposes |