diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-05-07 22:21:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 22:21:36 +0200 |
commit | 74dc9a45e3f85b4fc55a2d1cb2786885eb4489f5 (patch) | |
tree | f27f5b26b4076fe8dd2dad3afde8407640c77807 /pkg/adapter | |
parent | 2e40bdebfd245ff04e86b1ea42f663087d97fccf (diff) | |
parent | bc7b1ca03da88473c10e59197becd812cf341663 (diff) | |
download | podman-74dc9a45e3f85b4fc55a2d1cb2786885eb4489f5.tar.gz podman-74dc9a45e3f85b4fc55a2d1cb2786885eb4489f5.tar.bz2 podman-74dc9a45e3f85b4fc55a2d1cb2786885eb4489f5.zip |
Merge pull request #2977 from baude/makeitrain
enable integration tests for remote-client
Diffstat (limited to 'pkg/adapter')
-rw-r--r-- | pkg/adapter/containers_remote.go | 20 | ||||
-rw-r--r-- | pkg/adapter/errors.go | 31 | ||||
-rw-r--r-- | pkg/adapter/info_remote.go | 7 | ||||
-rw-r--r-- | pkg/adapter/pods_remote.go | 6 |
4 files changed, 52 insertions, 12 deletions
diff --git a/pkg/adapter/containers_remote.go b/pkg/adapter/containers_remote.go index c70db13ed..63b0f9d2f 100644 --- a/pkg/adapter/containers_remote.go +++ b/pkg/adapter/containers_remote.go @@ -234,15 +234,25 @@ func (r *LocalRuntime) StopContainers(ctx context.Context, cli *cliconfig.StopVa ids, err := iopodman.GetContainersByContext().Call(r.Conn, cli.All, cli.Latest, cli.InputArgs) if err != nil { - return ok, failures, err + return ok, failures, TranslateError(err) } for _, id := range ids { - stopped, err := iopodman.StopContainer().Call(r.Conn, id, int64(cli.Timeout)) - if err != nil { + if _, err := iopodman.StopContainer().Call(r.Conn, id, int64(cli.Timeout)); err != nil { + transError := TranslateError(err) + if errors.Cause(transError) == libpod.ErrCtrStopped { + ok = append(ok, id) + continue + } + if errors.Cause(transError) == libpod.ErrCtrStateInvalid && cli.All { + ok = append(ok, id) + continue + } failures[id] = err } else { - ok = append(ok, stopped) + // We should be using ID here because in varlink, only successful returns + // include the string id + ok = append(ok, id) } } return ok, failures, nil @@ -310,7 +320,7 @@ func (r *LocalRuntime) KillContainers(ctx context.Context, cli *cliconfig.KillVa func (r *LocalRuntime) RemoveContainers(ctx context.Context, cli *cliconfig.RmValues) ([]string, map[string]error, error) { ids, err := iopodman.GetContainersByContext().Call(r.Conn, cli.All, cli.Latest, cli.InputArgs) if err != nil { - return nil, nil, err + return nil, nil, TranslateError(err) } var ( diff --git a/pkg/adapter/errors.go b/pkg/adapter/errors.go new file mode 100644 index 000000000..7fbbabd93 --- /dev/null +++ b/pkg/adapter/errors.go @@ -0,0 +1,31 @@ +// +build remoteclient + +package adapter + +import ( + iopodman "github.com/containers/libpod/cmd/podman/varlink" + "github.com/containers/libpod/libpod" + "github.com/pkg/errors" +) + +// TranslateMapErrors translates the errors a typical podman output struct +// from varlink errors to libpod errors +func TranslateMapErrors(failures map[string]error) map[string]error { + for k, v := range failures { + failures[k] = TranslateError(v) + } + return failures +} + +// TranslateError converts a single varlink error to a libpod error +func TranslateError(err error) error { + switch err.(type) { + case *iopodman.ContainerNotFound: + return errors.Wrap(libpod.ErrNoSuchCtr, err.Error()) + case *iopodman.ErrCtrStopped: + return errors.Wrap(libpod.ErrCtrStopped, err.Error()) + case *iopodman.InvalidState: + return errors.Wrap(libpod.ErrCtrStateInvalid, err.Error()) + } + return err +} diff --git a/pkg/adapter/info_remote.go b/pkg/adapter/info_remote.go index 3b691ed17..3b2d02a5a 100644 --- a/pkg/adapter/info_remote.go +++ b/pkg/adapter/info_remote.go @@ -20,12 +20,7 @@ func (r RemoteRuntime) Info() ([]libpod.InfoData, error) { registries := make(map[string]interface{}) insecureRegistries := make(map[string]interface{}) - conn, err := r.Connect() - if err != nil { - return nil, err - } - defer conn.Close() - info, err := iopodman.GetInfo().Call(conn) + info, err := iopodman.GetInfo().Call(r.Conn) if err != nil { return nil, err } diff --git a/pkg/adapter/pods_remote.go b/pkg/adapter/pods_remote.go index 7cf38aac0..e2c97c36a 100644 --- a/pkg/adapter/pods_remote.go +++ b/pkg/adapter/pods_remote.go @@ -172,11 +172,15 @@ func (r *LocalRuntime) StartPods(ctx context.Context, cli *cliconfig.PodStartVal // CreatePod creates a pod for the remote client over a varlink connection func (r *LocalRuntime) CreatePod(ctx context.Context, cli *cliconfig.PodCreateValues, labels map[string]string) (string, error) { + var share []string + if cli.Share != "" { + share = strings.Split(cli.Share, ",") + } pc := iopodman.PodCreate{ Name: cli.Name, CgroupParent: cli.CgroupParent, Labels: labels, - Share: strings.Split(cli.Share, ","), + Share: share, Infra: cli.Infra, InfraCommand: cli.InfraCommand, InfraImage: cli.InfraCommand, |