Fix per review request
Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
parent
2b8d6ca09b
commit
05444cb2cc
|
|
@ -483,8 +483,6 @@ func (c *Container) Wait(ctx context.Context) (int32, error) {
|
||||||
return c.WaitWithInterval(ctx, DefaultWaitInterval)
|
return c.WaitWithInterval(ctx, DefaultWaitInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
var errWaitingCanceled = errors.New("waiting was canceled")
|
|
||||||
|
|
||||||
// WaitWithInterval blocks until the container to exit and returns its exit
|
// WaitWithInterval blocks until the container to exit and returns its exit
|
||||||
// code. The argument is the interval at which checks the container's status.
|
// 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) {
|
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() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
chWait <- errWaitingCanceled
|
chWait <- define.ErrCanceled
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// ignore errors here (with exception of cancellation), it is only used to avoid waiting
|
// ignore errors here (with exception of cancellation), it is only used to avoid waiting
|
||||||
// too long.
|
// too long.
|
||||||
_, e := WaitForFile(exitFile, chWait, waitTimeout)
|
_, e := WaitForFile(exitFile, chWait, waitTimeout)
|
||||||
if e == errWaitingCanceled {
|
if e == define.ErrCanceled {
|
||||||
return -1, errWaitingCanceled
|
return -1, define.ErrCanceled
|
||||||
}
|
}
|
||||||
|
|
||||||
stopped, code, err := c.isStopped()
|
stopped, code, err := c.isStopped()
|
||||||
|
|
@ -599,7 +597,7 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
|
||||||
case result = <-resultChan:
|
case result = <-resultChan:
|
||||||
cancelFn()
|
cancelFn()
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
result = waitResult{-1, errWaitingCanceled}
|
result = waitResult{-1, define.ErrCanceled}
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
return result.code, result.err
|
return result.code, result.err
|
||||||
|
|
|
||||||
|
|
@ -198,4 +198,8 @@ var (
|
||||||
// ErrSecurityAttribute indicates that an error processing security attributes
|
// ErrSecurityAttribute indicates that an error processing security attributes
|
||||||
// for the container
|
// for the container
|
||||||
ErrSecurityAttribute = fmt.Errorf("%w: unable to process security attribute", ErrOCIRuntime)
|
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")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue