From c9f763456cd8263c3f2d84c6b2b6e17ad81cf3ba Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 31 May 2018 11:47:17 -0700 Subject: libpod: Execute poststop hooks locally Instead of delegating to the runtime, since some runtimes do not seem to handle these reliably [1]. [1]: https://github.com/projectatomic/libpod/issues/730#issuecomment-392959938 Signed-off-by: W. Trevor King Closes: #864 Approved by: rhatdan --- pkg/varlinkapi/containers.go | 6 ++++-- pkg/varlinkapi/images.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'pkg/varlinkapi') diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go index 2b84151a9..71e5c31d0 100644 --- a/pkg/varlinkapi/containers.go +++ b/pkg/varlinkapi/containers.go @@ -409,6 +409,7 @@ func (i *LibpodAPI) WaitContainer(call ioprojectatomicpodman.VarlinkCall, name s // RemoveContainer ... func (i *LibpodAPI) RemoveContainer(call ioprojectatomicpodman.VarlinkCall, name string, force bool) error { + ctx := getContext() runtime, err := libpodruntime.GetRuntime(i.Cli) if err != nil { return call.ReplyRuntimeError(err.Error()) @@ -417,7 +418,7 @@ func (i *LibpodAPI) RemoveContainer(call ioprojectatomicpodman.VarlinkCall, name if err != nil { return call.ReplyContainerNotFound(name) } - if err := runtime.RemoveContainer(ctr, force); err != nil { + if err := runtime.RemoveContainer(ctx, ctr, force); err != nil { return call.ReplyErrorOccurred(err.Error()) } return call.ReplyRemoveContainer(ctr.ID()) @@ -426,6 +427,7 @@ func (i *LibpodAPI) RemoveContainer(call ioprojectatomicpodman.VarlinkCall, name // DeleteStoppedContainers ... func (i *LibpodAPI) DeleteStoppedContainers(call ioprojectatomicpodman.VarlinkCall) error { + ctx := getContext() var deletedContainers []string runtime, err := libpodruntime.GetRuntime(i.Cli) if err != nil { @@ -441,7 +443,7 @@ func (i *LibpodAPI) DeleteStoppedContainers(call ioprojectatomicpodman.VarlinkCa return call.ReplyErrorOccurred(err.Error()) } if state != libpod.ContainerStateRunning { - if err := runtime.RemoveContainer(ctr, false); err != nil { + if err := runtime.RemoveContainer(ctx, ctr, false); err != nil { return call.ReplyErrorOccurred(err.Error()) } deletedContainers = append(deletedContainers, ctr.ID()) diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go index 551eb781c..d80c7043a 100644 --- a/pkg/varlinkapi/images.go +++ b/pkg/varlinkapi/images.go @@ -360,6 +360,7 @@ func (i *LibpodAPI) TagImage(call ioprojectatomicpodman.VarlinkCall, name, tag s // RemoveImage accepts a image name or ID as a string and force bool to determine if it should // remove the image even if being used by stopped containers func (i *LibpodAPI) RemoveImage(call ioprojectatomicpodman.VarlinkCall, name string, force bool) error { + ctx := getContext() runtime, err := libpodruntime.GetRuntime(i.Cli) if err != nil { return call.ReplyRuntimeError(err.Error()) @@ -368,7 +369,7 @@ func (i *LibpodAPI) RemoveImage(call ioprojectatomicpodman.VarlinkCall, name str if err != nil { return call.ReplyImageNotFound(name) } - imageID, err := runtime.RemoveImage(newImage, force) + imageID, err := runtime.RemoveImage(ctx, newImage, force) if err != nil { return call.ReplyErrorOccurred(err.Error()) } -- cgit v1.2.3-54-g00ecf