aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-02-04 18:30:07 +0100
committerMatej Vasek <mvasek@redhat.com>2021-02-04 18:30:07 +0100
commit05444cb2ccf29515e6cb8f2711c64213b7cb3325 (patch)
treeaed1a97fa64f451ca95813f9412ff29f20827bd0 /libpod
parent2b8d6ca09be8610693ac18b6046b3a7a6d3d67dd (diff)
downloadpodman-05444cb2ccf29515e6cb8f2711c64213b7cb3325.tar.gz
podman-05444cb2ccf29515e6cb8f2711c64213b7cb3325.tar.bz2
podman-05444cb2ccf29515e6cb8f2711c64213b7cb3325.zip
Fix per review request
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go10
-rw-r--r--libpod/define/errors.go4
2 files changed, 8 insertions, 6 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index c64074d80..2473acec0 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -483,8 +483,6 @@ func (c *Container) Wait(ctx context.Context) (int32, error) {
return c.WaitWithInterval(ctx, DefaultWaitInterval)
}
-var errWaitingCanceled = errors.New("waiting was canceled")
-
// WaitWithInterval blocks until the container to exit and returns its exit
// code. The argument is the interval at which checks the container's status.
func (c *Container) WaitWithInterval(ctx context.Context, waitTimeout time.Duration) (int32, error) {
@@ -500,15 +498,15 @@ func (c *Container) WaitWithInterval(ctx context.Context, waitTimeout time.Durat
go func() {
<-ctx.Done()
- chWait <- errWaitingCanceled
+ chWait <- define.ErrCanceled
}()
for {
// ignore errors here (with exception of cancellation), it is only used to avoid waiting
// too long.
_, e := WaitForFile(exitFile, chWait, waitTimeout)
- if e == errWaitingCanceled {
- return -1, errWaitingCanceled
+ if e == define.ErrCanceled {
+ return -1, define.ErrCanceled
}
stopped, code, err := c.isStopped()
@@ -599,7 +597,7 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
case result = <-resultChan:
cancelFn()
case <-ctx.Done():
- result = waitResult{-1, errWaitingCanceled}
+ result = waitResult{-1, define.ErrCanceled}
}
wg.Wait()
return result.code, result.err
diff --git a/libpod/define/errors.go b/libpod/define/errors.go
index d37bc397e..2e85454b2 100644
--- a/libpod/define/errors.go
+++ b/libpod/define/errors.go
@@ -198,4 +198,8 @@ var (
// ErrSecurityAttribute indicates that an error processing security attributes
// for the container
ErrSecurityAttribute = fmt.Errorf("%w: unable to process security attribute", ErrOCIRuntime)
+
+ // ErrCanceled indicates that an operation has been cancelled by a user.
+ // Useful for potentially long running tasks.
+ ErrCanceled = errors.New("cancelled by user")
)