summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/containers_create.go1
-rw-r--r--pkg/api/handlers/compat/images.go14
-rw-r--r--pkg/api/handlers/compat/secrets.go8
-rw-r--r--pkg/api/handlers/compat/system.go1
-rw-r--r--pkg/domain/entities/containers.go10
-rw-r--r--pkg/domain/infra/abi/containers.go26
-rw-r--r--pkg/domain/infra/abi/system.go2
-rw-r--r--pkg/domain/infra/tunnel/containers.go22
-rw-r--r--pkg/domain/infra/tunnel/helpers.go23
-rw-r--r--pkg/specgen/generate/oci.go5
10 files changed, 77 insertions, 35 deletions
diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go
index 6e85872b2..4a39e9563 100644
--- a/pkg/api/handlers/compat/containers_create.go
+++ b/pkg/api/handlers/compat/containers_create.go
@@ -47,6 +47,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
rtc, err := runtime.GetConfig()
if err != nil {
utils.Error(w, "unable to obtain runtime config", http.StatusInternalServerError, errors.Wrap(err, "unable to get runtime config"))
+ return
}
newImage, err := runtime.ImageRuntime().NewFromLocal(body.Config.Image)
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index 85708912b..0d75d1a94 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -10,7 +10,6 @@ import (
"strings"
"github.com/containers/buildah"
- "github.com/containers/common/pkg/config"
"github.com/containers/image/v5/manifest"
"github.com/containers/podman/v2/libpod"
image2 "github.com/containers/podman/v2/libpod/image"
@@ -18,6 +17,7 @@ import (
"github.com/containers/podman/v2/pkg/api/handlers/utils"
"github.com/containers/podman/v2/pkg/auth"
"github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/util"
"github.com/gorilla/schema"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
@@ -236,16 +236,6 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) {
if sys := runtime.SystemContext(); sys != nil {
registryOpts.DockerCertPath = sys.DockerCertPath
}
- rtc, err := runtime.GetConfig()
- if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
- return
- }
- pullPolicy, err := config.ValidatePullPolicy(rtc.Engine.PullPolicy)
- if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
- return
- }
img, err := runtime.ImageRuntime().New(r.Context(),
fromImage,
"", // signature policy
@@ -254,7 +244,7 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) {
&registryOpts,
image2.SigningOptions{},
nil, // label
- pullPolicy,
+ util.PullImageAlways,
)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
diff --git a/pkg/api/handlers/compat/secrets.go b/pkg/api/handlers/compat/secrets.go
index 571888eba..ff737cddc 100644
--- a/pkg/api/handlers/compat/secrets.go
+++ b/pkg/api/handlers/compat/secrets.go
@@ -30,7 +30,9 @@ func ListSecrets(w http.ResponseWriter, r *http.Request) {
return
}
if len(query.Filters) > 0 {
- utils.Error(w, "filters not supported", http.StatusBadRequest, errors.New("bad parameter"))
+ utils.Error(w, "filters not supported", http.StatusBadRequest,
+ errors.Wrapf(errors.New("bad parameter"), "filters not supported"))
+ return
}
ic := abi.ContainerEngine{Libpod: runtime}
reports, err := ic.SecretList(r.Context())
@@ -95,7 +97,9 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
return
}
if len(createParams.Labels) > 0 {
- utils.Error(w, "labels not supported", http.StatusBadRequest, errors.New("bad parameter"))
+ utils.Error(w, "labels not supported", http.StatusBadRequest,
+ errors.Wrapf(errors.New("bad parameter"), "labels not supported"))
+ return
}
decoded, _ := base64.StdEncoding.DecodeString(createParams.Data)
diff --git a/pkg/api/handlers/compat/system.go b/pkg/api/handlers/compat/system.go
index e21ae160a..66b4236f9 100644
--- a/pkg/api/handlers/compat/system.go
+++ b/pkg/api/handlers/compat/system.go
@@ -19,6 +19,7 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) {
df, err := ic.SystemDf(r.Context(), options)
if err != nil {
utils.InternalServerError(w, err)
+ return
}
imgs := make([]*docker.ImageSummary, len(df.Images))
diff --git a/pkg/domain/entities/containers.go b/pkg/domain/entities/containers.go
index 2d50d6826..116da888d 100644
--- a/pkg/domain/entities/containers.go
+++ b/pkg/domain/entities/containers.go
@@ -88,8 +88,9 @@ type StopOptions struct {
}
type StopReport struct {
- Err error
- Id string //nolint
+ Err error
+ Id string //nolint
+ RawInput string
}
type TopOptions struct {
@@ -109,8 +110,9 @@ type KillOptions struct {
}
type KillReport struct {
- Err error
- Id string //nolint
+ Err error
+ Id string //nolint
+ RawInput string
}
type RestartOptions struct {
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index 7a672d863..0ee4048d1 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -138,10 +138,16 @@ func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []st
}
func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []string, options entities.StopOptions) ([]*entities.StopReport, error) {
names := namesOrIds
- ctrs, err := getContainersByContext(options.All, options.Latest, names, ic.Libpod)
+ ctrs, rawInputs, err := getContainersAndInputByContext(options.All, options.Latest, names, ic.Libpod)
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchCtr) {
return nil, err
}
+ ctrMap := map[string]string{}
+ if len(rawInputs) == len(ctrs) {
+ for i := range ctrs {
+ ctrMap[ctrs[i].ID()] = rawInputs[i]
+ }
+ }
errMap, err := parallelctr.ContainerOp(ctx, ctrs, func(c *libpod.Container) error {
var err error
if options.Timeout != nil {
@@ -174,6 +180,11 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
for ctr, err := range errMap {
report := new(entities.StopReport)
report.Id = ctr.ID()
+ if options.All {
+ report.RawInput = ctr.ID()
+ } else {
+ report.RawInput = ctrMap[ctr.ID()]
+ }
report.Err = err
reports = append(reports, report)
}
@@ -197,15 +208,22 @@ func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []strin
if err != nil {
return nil, err
}
- ctrs, err := getContainersByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
+ ctrs, rawInputs, err := getContainersAndInputByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
if err != nil {
return nil, err
}
+ ctrMap := map[string]string{}
+ if len(rawInputs) == len(ctrs) {
+ for i := range ctrs {
+ ctrMap[ctrs[i].ID()] = rawInputs[i]
+ }
+ }
reports := make([]*entities.KillReport, 0, len(ctrs))
for _, con := range ctrs {
reports = append(reports, &entities.KillReport{
- Id: con.ID(),
- Err: con.Kill(uint(sig)),
+ Id: con.ID(),
+ Err: con.Kill(uint(sig)),
+ RawInput: ctrMap[con.ID()],
})
}
return reports, nil
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index f29b98696..c68a12414 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -82,7 +82,7 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command)
unitName := fmt.Sprintf("podman-%d.scope", os.Getpid())
if runsUnderSystemd || conf.Engine.CgroupManager == config.SystemdCgroupsManager {
if err := utils.RunUnderSystemdScope(os.Getpid(), "user.slice", unitName); err != nil {
- logrus.Warnf("Failed to add podman to systemd sandbox cgroup: %v", err)
+ logrus.Debugf("Failed to add podman to systemd sandbox cgroup: %v", err)
}
}
}
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index c2c282ef9..b0a07cd27 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -82,16 +82,23 @@ func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []st
func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []string, opts entities.StopOptions) ([]*entities.StopReport, error) {
reports := []*entities.StopReport{}
- ctrs, err := getContainersByContext(ic.ClientCtx, opts.All, opts.Ignore, namesOrIds)
+ ctrs, rawInputs, err := getContainersAndInputByContext(ic.ClientCtx, opts.All, opts.Ignore, namesOrIds)
if err != nil {
return nil, err
}
+ ctrMap := map[string]string{}
+ for i := range ctrs {
+ ctrMap[ctrs[i].ID] = rawInputs[i]
+ }
options := new(containers.StopOptions).WithIgnore(opts.Ignore)
if to := opts.Timeout; to != nil {
options.WithTimeout(*to)
}
for _, c := range ctrs {
- report := entities.StopReport{Id: c.ID}
+ report := entities.StopReport{
+ Id: c.ID,
+ RawInput: ctrMap[c.ID],
+ }
if err = containers.Stop(ic.ClientCtx, c.ID, options); err != nil {
// These first two are considered non-fatal under the right conditions
if errors.Cause(err).Error() == define.ErrCtrStopped.Error() {
@@ -117,16 +124,21 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
}
func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []string, opts entities.KillOptions) ([]*entities.KillReport, error) {
- ctrs, err := getContainersByContext(ic.ClientCtx, opts.All, false, namesOrIds)
+ ctrs, rawInputs, err := getContainersAndInputByContext(ic.ClientCtx, opts.All, false, namesOrIds)
if err != nil {
return nil, err
}
+ ctrMap := map[string]string{}
+ for i := range ctrs {
+ ctrMap[ctrs[i].ID] = rawInputs[i]
+ }
options := new(containers.KillOptions).WithSignal(opts.Signal)
reports := make([]*entities.KillReport, 0, len(ctrs))
for _, c := range ctrs {
reports = append(reports, &entities.KillReport{
- Id: c.ID,
- Err: containers.Kill(ic.ClientCtx, c.ID, options),
+ Id: c.ID,
+ Err: containers.Kill(ic.ClientCtx, c.ID, options),
+ RawInput: ctrMap[c.ID],
})
}
return reports, nil
diff --git a/pkg/domain/infra/tunnel/helpers.go b/pkg/domain/infra/tunnel/helpers.go
index e40e27596..5fa70bffa 100644
--- a/pkg/domain/infra/tunnel/helpers.go
+++ b/pkg/domain/infra/tunnel/helpers.go
@@ -14,16 +14,26 @@ import (
// FIXME: the `ignore` parameter is very likely wrong here as it should rather
// be used on *errors* from operations such as remove.
func getContainersByContext(contextWithConnection context.Context, all, ignore bool, namesOrIDs []string) ([]entities.ListContainer, error) {
+ ctrs, _, err := getContainersAndInputByContext(contextWithConnection, all, ignore, namesOrIDs)
+ return ctrs, err
+}
+
+func getContainersAndInputByContext(contextWithConnection context.Context, all, ignore bool, namesOrIDs []string) ([]entities.ListContainer, []string, error) {
if all && len(namesOrIDs) > 0 {
- return nil, errors.New("cannot lookup containers and all")
+ return nil, nil, errors.New("cannot lookup containers and all")
}
options := new(containers.ListOptions).WithAll(true).WithSync(true)
allContainers, err := containers.List(contextWithConnection, options)
if err != nil {
- return nil, err
+ return nil, nil, err
}
+ rawInputs := []string{}
if all {
- return allContainers, err
+ for i := range allContainers {
+ rawInputs = append(rawInputs, allContainers[i].ID)
+ }
+
+ return allContainers, rawInputs, err
}
// Note: it would be nicer if the lists endpoint would support that as
@@ -42,7 +52,7 @@ func getContainersByContext(contextWithConnection context.Context, all, ignore b
if ignore && errorhandling.Contains(err, define.ErrNoSuchCtr) {
continue
}
- return nil, err
+ return nil, nil, err
}
// Now we can do a full match of the ID to find the right
@@ -52,16 +62,17 @@ func getContainersByContext(contextWithConnection context.Context, all, ignore b
for _, ctr := range allContainers {
if ctr.ID == inspectData.ID {
filtered = append(filtered, ctr)
+ rawInputs = append(rawInputs, nameOrID)
found = true
break
}
}
if !found && !ignore {
- return nil, errors.Wrapf(define.ErrNoSuchCtr, "unable to find container %q", nameOrID)
+ return nil, nil, errors.Wrapf(define.ErrNoSuchCtr, "unable to find container %q", nameOrID)
}
}
- return filtered, nil
+ return filtered, rawInputs, nil
}
func getPodsByContext(contextWithConnection context.Context, all bool, namesOrIDs []string) ([]*entities.ListPodsReport, error) {
diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go
index 1a0ec08a5..eefe45dfe 100644
--- a/pkg/specgen/generate/oci.go
+++ b/pkg/specgen/generate/oci.go
@@ -105,7 +105,10 @@ func makeCommand(ctx context.Context, s *specgen.SpecGenerator, img *image.Image
entrypoint = newEntry
}
- finalCommand = append(finalCommand, entrypoint...)
+ // Don't append the entrypoint if it is [""]
+ if len(entrypoint) != 1 || entrypoint[0] != "" {
+ finalCommand = append(finalCommand, entrypoint...)
+ }
// Only use image command if the user did not manually set an
// entrypoint.