diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-04-22 11:45:31 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-04-22 14:25:40 -0700 |
commit | 565f93531eae65ca85c286bf6bd2aa07eb713976 (patch) | |
tree | a36ef0168a0edbd34a5eb539d24062b9ad788aa0 /pkg/domain/infra/runtime_libpod.go | |
parent | 142757bd7288ccdb88d8f1322932f999ffb18c02 (diff) | |
download | podman-565f93531eae65ca85c286bf6bd2aa07eb713976.tar.gz podman-565f93531eae65ca85c286bf6bd2aa07eb713976.tar.bz2 podman-565f93531eae65ca85c286bf6bd2aa07eb713976.zip |
V2 restore libpod.Shutdown() when exiting podman commands
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/domain/infra/runtime_libpod.go')
-rw-r--r-- | pkg/domain/infra/runtime_libpod.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/pkg/domain/infra/runtime_libpod.go b/pkg/domain/infra/runtime_libpod.go index a6974d251..7c9180d43 100644 --- a/pkg/domain/infra/runtime_libpod.go +++ b/pkg/domain/infra/runtime_libpod.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "os" + "sync" "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/cgroups" @@ -18,6 +19,14 @@ import ( flag "github.com/spf13/pflag" ) +var ( + // runtimeSync only guards the non-specialized runtime + runtimeSync sync.Once + // The default GetRuntime() always returns the same object and error + runtimeLib *libpod.Runtime + runtimeErr error +) + type engineOpts struct { name string renumber bool @@ -63,13 +72,16 @@ func GetRuntimeRenumber(ctx context.Context, fs *flag.FlagSet, cfg *entities.Pod // GetRuntime generates a new libpod runtime configured by command line options func GetRuntime(ctx context.Context, flags *flag.FlagSet, cfg *entities.PodmanConfig) (*libpod.Runtime, error) { - return getRuntime(ctx, flags, &engineOpts{ - renumber: false, - migrate: false, - noStore: false, - withFDS: true, - config: cfg, + runtimeSync.Do(func() { + runtimeLib, runtimeErr = getRuntime(ctx, flags, &engineOpts{ + renumber: false, + migrate: false, + noStore: false, + withFDS: true, + config: cfg, + }) }) + return runtimeLib, runtimeErr } // GetRuntimeNoStore generates a new libpod runtime configured by command line options |