mirror of
https://github.com/moby/buildkit.git
synced 2025-08-08 10:02:07 +03:00
replace WithTimeout with WithTimeoutCause
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@@ -42,6 +42,8 @@ linters-settings:
|
|||||||
- '^fmt\.Errorf(# use errors\.Errorf instead)?$'
|
- '^fmt\.Errorf(# use errors\.Errorf instead)?$'
|
||||||
- '^logrus\.(Trace|Debug|Info|Warn|Warning|Error|Fatal)(f|ln)?(# use bklog\.G or bklog\.L instead of logrus directly)?$'
|
- '^logrus\.(Trace|Debug|Info|Warn|Warning|Error|Fatal)(f|ln)?(# use bklog\.G or bklog\.L instead of logrus directly)?$'
|
||||||
- '^context\.WithCancel(# use context\.WithCancelCause instead)?$'
|
- '^context\.WithCancel(# use context\.WithCancelCause instead)?$'
|
||||||
|
- '^context\.WithTimeout(# use context\.WithTimeoutCause instead)?$'
|
||||||
|
- '^context\.WithDeadline(# use context\.WithDeadline instead)?$'
|
||||||
- '^ctx\.Err(# use context\.Cause instead)?$'
|
- '^ctx\.Err(# use context\.Cause instead)?$'
|
||||||
importas:
|
importas:
|
||||||
alias:
|
alias:
|
||||||
|
10
cache/remotecache/azblob/exporter.go
vendored
10
cache/remotecache/azblob/exporter.go
vendored
@@ -150,8 +150,9 @@ func (ce *exporter) uploadManifest(ctx context.Context, manifestKey string, read
|
|||||||
return errors.Wrap(err, "error creating container client")
|
return errors.Wrap(err, "error creating container client")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cnclFn := context.WithTimeout(ctx, time.Minute*5)
|
ctx, cnclFn := context.WithCancelCause(ctx)
|
||||||
defer cnclFn()
|
ctx, _ = context.WithTimeoutCause(ctx, time.Minute*5, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cnclFn(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
_, err = blobClient.Upload(ctx, reader, &azblob.BlockBlobUploadOptions{})
|
_, err = blobClient.Upload(ctx, reader, &azblob.BlockBlobUploadOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -170,8 +171,9 @@ func (ce *exporter) uploadBlobIfNotExists(ctx context.Context, blobKey string, r
|
|||||||
return errors.Wrap(err, "error creating container client")
|
return errors.Wrap(err, "error creating container client")
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadCtx, cnclFn := context.WithTimeout(ctx, time.Minute*5)
|
uploadCtx, cnclFn := context.WithCancelCause(ctx)
|
||||||
defer cnclFn()
|
uploadCtx, _ = context.WithTimeoutCause(uploadCtx, time.Minute*5, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cnclFn(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
// Only upload if the blob doesn't exist
|
// Only upload if the blob doesn't exist
|
||||||
eTagAny := azblob.ETagAny
|
eTagAny := azblob.ETagAny
|
||||||
|
15
cache/remotecache/azblob/utils.go
vendored
15
cache/remotecache/azblob/utils.go
vendored
@@ -133,8 +133,9 @@ func createContainerClient(ctx context.Context, config *Config) (*azblob.Contain
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cnclFn := context.WithTimeout(ctx, time.Second*60)
|
ctx, cnclFn := context.WithCancelCause(ctx)
|
||||||
defer cnclFn()
|
ctx, _ = context.WithTimeoutCause(ctx, time.Second*60, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cnclFn(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
containerClient, err := serviceClient.NewContainerClient(config.Container)
|
containerClient, err := serviceClient.NewContainerClient(config.Container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -148,8 +149,9 @@ func createContainerClient(ctx context.Context, config *Config) (*azblob.Contain
|
|||||||
|
|
||||||
var se *azblob.StorageError
|
var se *azblob.StorageError
|
||||||
if errors.As(err, &se) && se.ErrorCode == azblob.StorageErrorCodeContainerNotFound {
|
if errors.As(err, &se) && se.ErrorCode == azblob.StorageErrorCodeContainerNotFound {
|
||||||
ctx, cnclFn := context.WithTimeout(ctx, time.Minute*5)
|
ctx, cnclFn := context.WithCancelCause(ctx)
|
||||||
defer cnclFn()
|
ctx, _ = context.WithTimeoutCause(ctx, time.Minute*5, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cnclFn(errors.WithStack(context.Canceled))
|
||||||
_, err := containerClient.Create(ctx, &azblob.ContainerCreateOptions{})
|
_, err := containerClient.Create(ctx, &azblob.ContainerCreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to create cache container %s", config.Container)
|
return nil, errors.Wrapf(err, "failed to create cache container %s", config.Container)
|
||||||
@@ -177,8 +179,9 @@ func blobExists(ctx context.Context, containerClient *azblob.ContainerClient, bl
|
|||||||
return false, errors.Wrap(err, "error creating blob client")
|
return false, errors.Wrap(err, "error creating blob client")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cnclFn := context.WithTimeout(ctx, time.Second*60)
|
ctx, cnclFn := context.WithCancelCause(ctx)
|
||||||
defer cnclFn()
|
ctx, _ = context.WithTimeoutCause(ctx, time.Second*60, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cnclFn(errors.WithStack(context.Canceled))
|
||||||
_, err = blobClient.GetProperties(ctx, &azblob.BlobGetPropertiesOptions{})
|
_, err = blobClient.GetProperties(ctx, &azblob.BlobGetPropertiesOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return true, nil
|
return true, nil
|
||||||
|
5
cache/remotecache/local/local.go
vendored
5
cache/remotecache/local/local.go
vendored
@@ -105,8 +105,9 @@ func getContentStore(ctx context.Context, sm *session.Manager, g session.Group,
|
|||||||
if sessionID == "" {
|
if sessionID == "" {
|
||||||
return nil, errors.New("local cache exporter/importer requires session")
|
return nil, errors.New("local cache exporter/importer requires session")
|
||||||
}
|
}
|
||||||
timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
timeoutCtx, cancel := context.WithCancelCause(context.Background())
|
||||||
defer cancel()
|
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
caller, err := sm.Get(timeoutCtx, sessionID, false)
|
caller, err := sm.Get(timeoutCtx, sessionID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -933,7 +933,7 @@ func testClientGatewayContainerPID1Tty(t *testing.T, sb integration.Sandbox) {
|
|||||||
output := bytes.NewBuffer(nil)
|
output := bytes.NewBuffer(nil)
|
||||||
|
|
||||||
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
||||||
ctx, timeout := context.WithTimeout(ctx, 10*time.Second)
|
ctx, timeout := context.WithTimeoutCause(ctx, 10*time.Second, nil)
|
||||||
defer timeout()
|
defer timeout()
|
||||||
|
|
||||||
st := llb.Image("busybox:latest")
|
st := llb.Image("busybox:latest")
|
||||||
@@ -1015,7 +1015,7 @@ func testClientGatewayContainerCancelPID1Tty(t *testing.T, sb integration.Sandbo
|
|||||||
output := bytes.NewBuffer(nil)
|
output := bytes.NewBuffer(nil)
|
||||||
|
|
||||||
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
||||||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
ctx, cancel := context.WithTimeoutCause(ctx, 10*time.Second, nil)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
st := llb.Image("busybox:latest")
|
st := llb.Image("busybox:latest")
|
||||||
@@ -1141,7 +1141,7 @@ func testClientGatewayContainerExecTty(t *testing.T, sb integration.Sandbox) {
|
|||||||
inputR, inputW := io.Pipe()
|
inputR, inputW := io.Pipe()
|
||||||
output := bytes.NewBuffer(nil)
|
output := bytes.NewBuffer(nil)
|
||||||
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
||||||
ctx, timeout := context.WithTimeout(ctx, 10*time.Second)
|
ctx, timeout := context.WithTimeoutCause(ctx, 10*time.Second, nil)
|
||||||
defer timeout()
|
defer timeout()
|
||||||
st := llb.Image("busybox:latest")
|
st := llb.Image("busybox:latest")
|
||||||
|
|
||||||
@@ -1233,7 +1233,7 @@ func testClientGatewayContainerCancelExecTty(t *testing.T, sb integration.Sandbo
|
|||||||
inputR, inputW := io.Pipe()
|
inputR, inputW := io.Pipe()
|
||||||
output := bytes.NewBuffer(nil)
|
output := bytes.NewBuffer(nil)
|
||||||
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
||||||
ctx, timeout := context.WithTimeout(ctx, 10*time.Second)
|
ctx, timeout := context.WithTimeoutCause(ctx, 10*time.Second, nil)
|
||||||
defer timeout()
|
defer timeout()
|
||||||
st := llb.Image("busybox:latest")
|
st := llb.Image("busybox:latest")
|
||||||
|
|
||||||
@@ -2132,7 +2132,7 @@ func testClientGatewayContainerSignal(t *testing.T, sb integration.Sandbox) {
|
|||||||
product := "buildkit_test"
|
product := "buildkit_test"
|
||||||
|
|
||||||
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
b := func(ctx context.Context, c client.Client) (*client.Result, error) {
|
||||||
ctx, timeout := context.WithTimeout(ctx, 10*time.Second)
|
ctx, timeout := context.WithTimeoutCause(ctx, 10*time.Second, nil)
|
||||||
defer timeout()
|
defer timeout()
|
||||||
|
|
||||||
st := llb.Image("busybox:latest")
|
st := llb.Image("busybox:latest")
|
||||||
|
@@ -9832,7 +9832,7 @@ func testLLBMountPerformance(t *testing.T, sb integration.Sandbox) {
|
|||||||
def, err := st.Marshal(sb.Context())
|
def, err := st.Marshal(sb.Context())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
timeoutCtx, cancel := context.WithTimeout(sb.Context(), time.Minute)
|
timeoutCtx, cancel := context.WithTimeoutCause(sb.Context(), time.Minute, nil)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
_, err = c.Solve(timeoutCtx, def, SolveOpt{}, nil)
|
_, err = c.Solve(timeoutCtx, def, SolveOpt{}, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@@ -91,9 +91,10 @@ func ResolveClient(c *cli.Context) (*client.Client, error) {
|
|||||||
|
|
||||||
timeout := time.Duration(c.GlobalInt("timeout"))
|
timeout := time.Duration(c.GlobalInt("timeout"))
|
||||||
if timeout > 0 {
|
if timeout > 0 {
|
||||||
ctx2, cancel := context.WithTimeout(ctx, timeout*time.Second)
|
ctx2, cancel := context.WithCancelCause(ctx)
|
||||||
|
ctx2, _ = context.WithTimeoutCause(ctx2, timeout*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
ctx = ctx2
|
ctx = ctx2
|
||||||
defer cancel()
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
}
|
}
|
||||||
|
|
||||||
cl, err := client.New(ctx, c.GlobalString("addr"), opts...)
|
cl, err := client.New(ctx, c.GlobalString("addr"), opts...)
|
||||||
|
@@ -59,8 +59,9 @@ func (gwf *GatewayForwarder) lookupForwarder(ctx context.Context) (gateway.LLBBr
|
|||||||
return nil, errors.New("no buildid found in context")
|
return nil, errors.New("no buildid found in context")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
|
ctx, cancel := context.WithCancelCause(ctx)
|
||||||
defer cancel()
|
ctx, _ = context.WithTimeoutCause(ctx, 3*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
|
@@ -371,7 +371,7 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var cancel func()
|
var cancel func(error)
|
||||||
var killCtxDone <-chan struct{}
|
var killCtxDone <-chan struct{}
|
||||||
ctxDone := ctx.Done()
|
ctxDone := ctx.Done()
|
||||||
for {
|
for {
|
||||||
@@ -379,13 +379,14 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces
|
|||||||
case <-ctxDone:
|
case <-ctxDone:
|
||||||
ctxDone = nil
|
ctxDone = nil
|
||||||
var killCtx context.Context
|
var killCtx context.Context
|
||||||
killCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
killCtx, cancel = context.WithCancelCause(context.Background())
|
||||||
|
killCtx, _ = context.WithTimeoutCause(killCtx, 10*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
killCtxDone = killCtx.Done()
|
killCtxDone = killCtx.Done()
|
||||||
p.Kill(killCtx, syscall.SIGKILL)
|
p.Kill(killCtx, syscall.SIGKILL)
|
||||||
io.Cancel()
|
io.Cancel()
|
||||||
case status := <-statusCh:
|
case status := <-statusCh:
|
||||||
if cancel != nil {
|
if cancel != nil {
|
||||||
cancel()
|
cancel(errors.WithStack(context.Canceled))
|
||||||
}
|
}
|
||||||
trace.SpanFromContext(ctx).AddEvent(
|
trace.SpanFromContext(ctx).AddEvent(
|
||||||
"Container exited",
|
"Container exited",
|
||||||
@@ -411,7 +412,7 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces
|
|||||||
return nil
|
return nil
|
||||||
case <-killCtxDone:
|
case <-killCtxDone:
|
||||||
if cancel != nil {
|
if cancel != nil {
|
||||||
cancel()
|
cancel(errors.WithStack(context.Canceled))
|
||||||
}
|
}
|
||||||
io.Cancel()
|
io.Cancel()
|
||||||
return errors.Errorf("failed to kill process on cancel")
|
return errors.Errorf("failed to kill process on cancel")
|
||||||
|
@@ -532,8 +532,9 @@ func (k procKiller) Kill(ctx context.Context) (err error) {
|
|||||||
|
|
||||||
// this timeout is generally a no-op, the Kill ctx should already have a
|
// this timeout is generally a no-op, the Kill ctx should already have a
|
||||||
// shorter timeout but here as a fail-safe for future refactoring.
|
// shorter timeout but here as a fail-safe for future refactoring.
|
||||||
ctx, timeout := context.WithTimeout(ctx, 10*time.Second)
|
ctx, cancel := context.WithCancelCause(ctx)
|
||||||
defer timeout()
|
ctx, _ = context.WithTimeoutCause(ctx, 10*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
if k.pidfile == "" {
|
if k.pidfile == "" {
|
||||||
// for `runc run` process we use `runc kill` to terminate the process
|
// for `runc run` process we use `runc kill` to terminate the process
|
||||||
@@ -615,17 +616,17 @@ func runcProcessHandle(ctx context.Context, killer procKiller) (*procHandle, con
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
killCtx, timeout := context.WithTimeout(context.Background(), 7*time.Second)
|
killCtx, timeout := context.WithCancelCause(context.Background())
|
||||||
|
killCtx, _ = context.WithTimeoutCause(killCtx, 7*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
if err := p.killer.Kill(killCtx); err != nil {
|
if err := p.killer.Kill(killCtx); err != nil {
|
||||||
select {
|
select {
|
||||||
case <-killCtx.Done():
|
case <-killCtx.Done():
|
||||||
timeout()
|
|
||||||
cancel(errors.WithStack(context.Cause(ctx)))
|
cancel(errors.WithStack(context.Cause(ctx)))
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timeout()
|
timeout(errors.WithStack(context.Canceled))
|
||||||
select {
|
select {
|
||||||
case <-time.After(50 * time.Millisecond):
|
case <-time.After(50 * time.Millisecond):
|
||||||
case <-p.ended:
|
case <-p.ended:
|
||||||
@@ -673,10 +674,11 @@ func (p *procHandle) WaitForReady(ctx context.Context) error {
|
|||||||
// We wait for up to 10s for the runc pid to be reported. If the started
|
// We wait for up to 10s for the runc pid to be reported. If the started
|
||||||
// callback is non-nil it will be called after receiving the pid.
|
// callback is non-nil it will be called after receiving the pid.
|
||||||
func (p *procHandle) WaitForStart(ctx context.Context, startedCh <-chan int, started func()) error {
|
func (p *procHandle) WaitForStart(ctx context.Context, startedCh <-chan int, started func()) error {
|
||||||
startedCtx, timeout := context.WithTimeout(ctx, 10*time.Second)
|
ctx, cancel := context.WithCancelCause(ctx)
|
||||||
defer timeout()
|
ctx, _ = context.WithTimeoutCause(ctx, 10*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
select {
|
select {
|
||||||
case <-startedCtx.Done():
|
case <-ctx.Done():
|
||||||
return errors.New("go-runc started message never received")
|
return errors.New("go-runc started message never received")
|
||||||
case runcPid, ok := <-startedCh:
|
case runcPid, ok := <-startedCh:
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@@ -61,8 +61,9 @@ func (e *localExporter) Config() *exporter.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *localExporterInstance) Export(ctx context.Context, inp *exporter.Source, sessionID string) (map[string]string, exporter.DescriptorReference, error) {
|
func (e *localExporterInstance) Export(ctx context.Context, inp *exporter.Source, sessionID string) (map[string]string, exporter.DescriptorReference, error) {
|
||||||
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
timeoutCtx, cancel := context.WithCancelCause(ctx)
|
||||||
defer cancel()
|
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
if e.opts.Epoch == nil {
|
if e.opts.Epoch == nil {
|
||||||
if tm, ok, err := epoch.ParseSource(inp); err != nil {
|
if tm, ok, err := epoch.ParseSource(inp); err != nil {
|
||||||
|
@@ -198,8 +198,9 @@ func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source
|
|||||||
return nil, nil, errors.Errorf("invalid variant %q", e.opt.Variant)
|
return nil, nil, errors.Errorf("invalid variant %q", e.opt.Variant)
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
timeoutCtx, cancel := context.WithCancelCause(ctx)
|
||||||
defer cancel()
|
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID, false)
|
caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -143,8 +143,9 @@ func (e *localExporterInstance) Export(ctx context.Context, inp *exporter.Source
|
|||||||
fs = d.FS
|
fs = d.FS
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
timeoutCtx, cancel := context.WithCancelCause(ctx)
|
||||||
defer cancel()
|
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID, false)
|
caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -2692,8 +2692,9 @@ COPY . .
|
|||||||
fstest.CreateFile(".dockerignore", []byte("!\n"), 0600),
|
fstest.CreateFile(".dockerignore", []byte("!\n"), 0600),
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(sb.Context(), 15*time.Second)
|
ctx, cancel := context.WithCancelCause(sb.Context())
|
||||||
defer cancel()
|
ctx, _ = context.WithTimeoutCause(ctx, 15*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
c, err := client.New(ctx, sb.Address())
|
c, err := client.New(ctx, sb.Address())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@@ -43,8 +43,9 @@ type GrpcClient interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx context.Context, opts map[string]string, session, product string, c pb.LLBBridgeClient, w []client.WorkerInfo) (GrpcClient, error) {
|
func New(ctx context.Context, opts map[string]string, session, product string, c pb.LLBBridgeClient, w []client.WorkerInfo) (GrpcClient, error) {
|
||||||
pingCtx, pingCancel := context.WithTimeout(ctx, 15*time.Second)
|
pingCtx, pingCancel := context.WithCancelCause(ctx)
|
||||||
defer pingCancel()
|
pingCtx, _ = context.WithTimeoutCause(pingCtx, 15*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer pingCancel(errors.WithStack(context.Canceled))
|
||||||
resp, err := c.Ping(pingCtx, &pb.PingRequest{})
|
resp, err := c.Ping(pingCtx, &pb.PingRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@@ -72,8 +72,9 @@ func (sm *Manager) Any(ctx context.Context, g Group, f func(context.Context, str
|
|||||||
return errors.Errorf("no active sessions")
|
return errors.Errorf("no active sessions")
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
timeoutCtx, cancel := context.WithCancelCause(ctx)
|
||||||
defer cancel()
|
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
c, err := sm.Get(timeoutCtx, id, false)
|
c, err := sm.Get(timeoutCtx, id, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lastErr = err
|
lastErr = err
|
||||||
|
@@ -104,9 +104,11 @@ func monitorHealth(ctx context.Context, cc *grpc.ClientConn, cancelConn func(err
|
|||||||
healthcheckStart := time.Now()
|
healthcheckStart := time.Now()
|
||||||
|
|
||||||
timeout := time.Duration(math.Max(float64(defaultHealthcheckDuration), float64(lastHealthcheckDuration)*1.5))
|
timeout := time.Duration(math.Max(float64(defaultHealthcheckDuration), float64(lastHealthcheckDuration)*1.5))
|
||||||
ctx, cancel := context.WithTimeout(ctx, timeout)
|
|
||||||
|
ctx, cancel := context.WithCancelCause(ctx)
|
||||||
|
ctx, _ = context.WithTimeoutCause(ctx, timeout, errors.WithStack(context.DeadlineExceeded))
|
||||||
_, err := healthClient.Check(ctx, &grpc_health_v1.HealthCheckRequest{})
|
_, err := healthClient.Check(ctx, &grpc_health_v1.HealthCheckRequest{})
|
||||||
cancel()
|
cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
lastHealthcheckDuration = time.Since(healthcheckStart)
|
lastHealthcheckDuration = time.Since(healthcheckStart)
|
||||||
logFields := logrus.Fields{
|
logFields := logrus.Fields{
|
||||||
|
@@ -488,8 +488,9 @@ func (jl *Solver) NewJob(id string) (*Job, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (jl *Solver) Get(id string) (*Job, error) {
|
func (jl *Solver) Get(id string) (*Job, error) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second)
|
ctx, cancel := context.WithCancelCause(context.Background())
|
||||||
defer cancel()
|
ctx, _ = context.WithTimeoutCause(ctx, 6*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
|
@@ -195,8 +195,9 @@ func (s *Solver) recordBuildHistory(ctx context.Context, id string, req frontend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
ctx, cancel := context.WithCancelCause(context.Background())
|
||||||
defer cancel()
|
ctx, _ = context.WithTimeoutCause(ctx, 20*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
ch := make(chan *client.SolveStatus)
|
ch := make(chan *client.SolveStatus)
|
||||||
|
@@ -123,8 +123,9 @@ func (r *ociLayoutResolver) info(ctx context.Context, ref reference.Spec) (conte
|
|||||||
|
|
||||||
func (r *ociLayoutResolver) withCaller(ctx context.Context, f func(context.Context, session.Caller) error) error {
|
func (r *ociLayoutResolver) withCaller(ctx context.Context, f func(context.Context, session.Caller) error) error {
|
||||||
if r.store.SessionID != "" {
|
if r.store.SessionID != "" {
|
||||||
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
timeoutCtx, cancel := context.WithCancelCause(ctx)
|
||||||
defer cancel()
|
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
caller, err := r.sm.Get(timeoutCtx, r.store.SessionID, false)
|
caller, err := r.sm.Get(timeoutCtx, r.store.SessionID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -141,8 +141,9 @@ func (ls *localSourceHandler) Snapshot(ctx context.Context, g session.Group) (ca
|
|||||||
return ls.snapshotWithAnySession(ctx, g)
|
return ls.snapshotWithAnySession(ctx, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
timeoutCtx, cancel := context.WithCancelCause(ctx)
|
||||||
defer cancel()
|
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
caller, err := ls.sm.Get(timeoutCtx, sessionID, false)
|
caller, err := ls.sm.Get(timeoutCtx, sessionID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -67,8 +67,9 @@ http:
|
|||||||
}
|
}
|
||||||
deferF.Append(stop)
|
deferF.Append(stop)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithCancelCause(context.Background())
|
||||||
defer cancel()
|
ctx, _ = context.WithTimeoutCause(ctx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
url, err = detectPort(ctx, rc)
|
url, err = detectPort(ctx, rc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
|
@@ -71,8 +71,9 @@ func (c *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc
|
|||||||
|
|
||||||
ctx, cancel := c.connection.ContextWithStop(ctx)
|
ctx, cancel := c.connection.ContextWithStop(ctx)
|
||||||
defer cancel(errors.WithStack(context.Canceled))
|
defer cancel(errors.WithStack(context.Canceled))
|
||||||
ctx, tCancel := context.WithTimeout(ctx, 30*time.Second)
|
ctx, tCancel := context.WithCancelCause(ctx)
|
||||||
defer tCancel()
|
ctx, _ = context.WithTimeoutCause(ctx, 30*time.Second, errors.WithStack(context.DeadlineExceeded))
|
||||||
|
defer tCancel(errors.WithStack(context.Canceled))
|
||||||
|
|
||||||
ctx = c.connection.ContextWithMetadata(ctx)
|
ctx = c.connection.ContextWithMetadata(ctx)
|
||||||
err := func() error {
|
err := func() error {
|
||||||
|
@@ -49,7 +49,7 @@ func TestWorkerExec(t *testing.T, w *base.Worker) {
|
|||||||
id := identity.NewID()
|
id := identity.NewID()
|
||||||
|
|
||||||
// verify pid1 exits when stdin sees EOF
|
// verify pid1 exits when stdin sees EOF
|
||||||
ctxTimeout, cancelTimeout := context.WithTimeout(ctx, 5*time.Second)
|
ctxTimeout, cancelTimeout := context.WithTimeoutCause(ctx, 5*time.Second, nil)
|
||||||
started := make(chan struct{})
|
started := make(chan struct{})
|
||||||
pipeR, pipeW := io.Pipe()
|
pipeR, pipeW := io.Pipe()
|
||||||
go func() {
|
go func() {
|
||||||
|
Reference in New Issue
Block a user