From 6826b3a3c76f7877983c232e7353060f6b631579 Mon Sep 17 00:00:00 2001 From: Andrey Voronkov Date: Tue, 21 Feb 2023 01:16:36 +0300 Subject: [PATCH] Possible fix for `failed to get state for index` https://github.com/moby/buildkit/issues/3635 Signed-off-by: Andrey Voronkov --- solver/jobs.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/solver/jobs.go b/solver/jobs.go index d72eddcafb20..2fac876282f3 100644 --- a/solver/jobs.go +++ b/solver/jobs.go @@ -733,17 +733,16 @@ func (s *sharedOp) CalcSlowCache(ctx context.Context, index Index, p PreprocessF complete := true if p != nil { st := s.st.solver.getState(s.st.vtx.Inputs()[index]) - if st == nil { - return nil, errors.Errorf("failed to get state for index %d on %v", index, s.st.vtx.Name()) - } - ctx2 := progress.WithProgress(ctx, st.mpw) - if st.mspan.Span != nil { - ctx2 = trace.ContextWithSpan(ctx2, st.mspan) - } - err = p(ctx2, res, st) - if err != nil { - f = nil - ctx = ctx2 + if st != nil { + ctx2 := progress.WithProgress(ctx, st.mpw) + if st.mspan.Span != nil { + ctx2 = trace.ContextWithSpan(ctx2, st.mspan) + } + err = p(ctx2, res, st) + if err != nil { + f = nil + ctx = ctx2 + } } }