summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-05-05 15:44:29 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2021-05-05 17:58:39 +0200
commit68fe1950fe5bad7e29b7a75bb1e94a54fd7e5360 (patch)
tree8d8967ca6df08ce77e8aef98f391327fd23aec3c /libpod
parent4d2ba323f2e67fbfd6150582196c6e0229c70a8e (diff)
downloadpodman-68fe1950fe5bad7e29b7a75bb1e94a54fd7e5360.tar.gz
podman-68fe1950fe5bad7e29b7a75bb1e94a54fd7e5360.tar.bz2
podman-68fe1950fe5bad7e29b7a75bb1e94a54fd7e5360.zip
podman: set volatile storage flag for --rm containers
volatile containers are a storage optimization that disables *sync() syscalls for the container rootfs. If a container is created with --rm, then automatically set the volatile storage flag as anyway the container won't persist after a reboot or machine crash. [NO TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_config.go3
-rw-r--r--libpod/container_internal.go2
-rw-r--r--libpod/options.go13
3 files changed, 18 insertions, 0 deletions
diff --git a/libpod/container_config.go b/libpod/container_config.go
index ede6b1aab..da732c05b 100644
--- a/libpod/container_config.go
+++ b/libpod/container_config.go
@@ -151,6 +151,9 @@ type ContainerRootFSConfig struct {
Secrets []*secrets.Secret `json:"secrets,omitempty"`
// SecretPath is the secrets location in storage
SecretsPath string `json:"secretsPath"`
+ // 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"`
}
// ContainerSecurityConfig is an embedded sub-config providing security configuration
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 80c00a622..a293defd9 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -451,6 +451,8 @@ func (c *Container) setupStorage(ctx context.Context) error {
options.MountOpts = newOptions
}
+ options.Volatile = c.config.Volatile
+
c.setupStorageMapping(&options.IDMappingOptions, &c.config.IDMappings)
containerInfo, err := c.runtime.storageService.CreateContainerStorage(ctx, c.runtime.imageContext, c.config.RootfsImageName, c.config.RootfsImageID, c.config.Name, c.config.ID, options)
diff --git a/libpod/options.go b/libpod/options.go
index 39415a817..391cf0147 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -2318,3 +2318,16 @@ func WithPodSlirp4netns(networkOptions map[string][]string) PodCreateOption {
return nil
}
}
+
+// WithVolatile sets the volatile flag for the container storage.
+// The option can potentially cause data loss when used on a container that must survive a machine reboot.
+func WithVolatile() CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return define.ErrCtrFinalized
+ }
+
+ ctr.config.Volatile = true
+ return nil
+ }
+}