summaryrefslogtreecommitdiff
path: root/pkg/domain/infra
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-23 18:27:32 +0200
committerGitHub <noreply@github.com>2020-04-23 18:27:32 +0200
commite5a3e46746a0db9fcd9b701693d557438420d1e4 (patch)
tree5a3cf2e6853a681ec9522f1917b33b9b899fbdb2 /pkg/domain/infra
parent397dcc358a60eef1de22384c662480892a317ec4 (diff)
parent565f93531eae65ca85c286bf6bd2aa07eb713976 (diff)
downloadpodman-e5a3e46746a0db9fcd9b701693d557438420d1e4.tar.gz
podman-e5a3e46746a0db9fcd9b701693d557438420d1e4.tar.bz2
podman-e5a3e46746a0db9fcd9b701693d557438420d1e4.zip
Merge pull request #5946 from jwhonce/wip/shutdown
V2 restore libpod.Shutdown() when exiting podman commands
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r--pkg/domain/infra/abi/containers.go7
-rw-r--r--pkg/domain/infra/abi/images.go7
-rw-r--r--pkg/domain/infra/abi/runtime.go4
-rw-r--r--pkg/domain/infra/runtime_libpod.go24
-rw-r--r--pkg/domain/infra/tunnel/containers.go4
-rw-r--r--pkg/domain/infra/tunnel/images.go4
6 files changed, 44 insertions, 6 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index 73a0d8ec3..a77b18ce1 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -957,3 +957,10 @@ func (ic *ContainerEngine) ContainerPort(ctx context.Context, nameOrId string, o
}
return reports, nil
}
+
+// Shutdown Libpod engine
+func (ic *ContainerEngine) Shutdown(_ context.Context) {
+ shutdownSync.Do(func() {
+ _ = ic.Libpod.Shutdown(false)
+ })
+}
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index 8a2771a4c..64d9c9f12 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -556,3 +556,10 @@ func (ir *ImageEngine) Remove(ctx context.Context, images []string, opts entitie
return
}
+
+// Shutdown Libpod engine
+func (ir *ImageEngine) Shutdown(_ context.Context) {
+ shutdownSync.Do(func() {
+ _ = ir.Libpod.Shutdown(false)
+ })
+}
diff --git a/pkg/domain/infra/abi/runtime.go b/pkg/domain/infra/abi/runtime.go
index 7394cadfc..fba422d8e 100644
--- a/pkg/domain/infra/abi/runtime.go
+++ b/pkg/domain/infra/abi/runtime.go
@@ -1,6 +1,8 @@
package abi
import (
+ "sync"
+
"github.com/containers/libpod/libpod"
)
@@ -13,3 +15,5 @@ type ImageEngine struct {
type ContainerEngine struct {
Libpod *libpod.Runtime
}
+
+var shutdownSync sync.Once
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
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 8867ce27f..18d6613f4 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -379,3 +379,7 @@ func (ic *ContainerEngine) ContainerPort(ctx context.Context, nameOrId string, o
func (ic *ContainerEngine) ContainerCp(ctx context.Context, source, dest string, options entities.ContainerCpOptions) (*entities.ContainerCpReport, error) {
return nil, errors.New("not implemented")
}
+
+// Shutdown Libpod engine
+func (ic *ContainerEngine) Shutdown(_ context.Context) {
+}
diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go
index 27ed9f1ec..66e4e6e3f 100644
--- a/pkg/domain/infra/tunnel/images.go
+++ b/pkg/domain/infra/tunnel/images.go
@@ -260,3 +260,7 @@ func (ir *ImageEngine) Build(ctx context.Context, containerFiles []string, opts
func (ir *ImageEngine) Tree(ctx context.Context, nameOrId string, opts entities.ImageTreeOptions) (*entities.ImageTreeReport, error) {
return nil, errors.New("not implemented yet")
}
+
+// Shutdown Libpod engine
+func (ir *ImageEngine) Shutdown(_ context.Context) {
+}