summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2022-06-02 14:15:06 -0400
committerMatthew Heon <mheon@redhat.com>2022-06-03 12:54:08 -0400
commit259c79963f12d18b42d5455babf69b8ffdbb6b08 (patch)
tree48a52da8cfe34022b9284d3018916a14363b8405 /libpod/options.go
parent2039445763f418720b08983b40949480e8754f9a (diff)
downloadpodman-259c79963f12d18b42d5455babf69b8ffdbb6b08.tar.gz
podman-259c79963f12d18b42d5455babf69b8ffdbb6b08.tar.bz2
podman-259c79963f12d18b42d5455babf69b8ffdbb6b08.zip
Improve robustness of `podman system reset`
Firstly, reset is now managed by the runtime itself as a part of initialization. This ensures that it can be used even with runtimes that would otherwise fail to be created - most notably, when the user has changed a core path (runroot/root/tmpdir/staticdir). Secondly, we now attempt a best-effort removal even if the store completely fails to be configured. Third, we now hold the alive lock for the entire reset operation. This ensures that no other Podman process can start while we are running a system reset, and removes any possibility of a race where a user tries to create containers or pull images while we are trying to perform a reset. [NO NEW TESTS NEEDED] we do not test reset last I checked. Fixes #9075 Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index a02c05537..4b6803c3f 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -435,6 +435,21 @@ func WithDefaultInfraCommand(cmd string) RuntimeOption {
}
}
+// WithReset instructs libpod to reset all storage to factory defaults.
+// All containers, pods, volumes, images, and networks will be removed.
+// All directories created by Libpod will be removed.
+func WithReset() RuntimeOption {
+ return func(rt *Runtime) error {
+ if rt.valid {
+ return define.ErrRuntimeFinalized
+ }
+
+ rt.doReset = true
+
+ return nil
+ }
+}
+
// WithRenumber instructs libpod to perform a lock renumbering while
// initializing. This will handle migrations from early versions of libpod with
// file locks to newer versions with SHM locking, as well as changes in the