Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 652bdb4

Browse files
authored
Upstream-commit: bc6f4cc7032544553d2304a5b47ba235dbfe5b9c
Component: engine
2 parents 34ed21a + d11d1f3 commit 652bdb4

File tree

1 file changed

+11
-5
lines changed
  • components/engine/builder/builder-next/adapters/containerimage

1 file changed

+11
-5
lines changed

components/engine/builder/builder-next/adapters/containerimage/pull.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func (is *Source) Resolve(ctx context.Context, id source.Identifier, sm *session
183183
type puller struct {
184184
is *Source
185185
resolveLocalOnce sync.Once
186+
g flightcontrol.Group
186187
src *source.ImageIdentifier
187188
desc ocispec.Descriptor
188189
ref string
@@ -253,9 +254,7 @@ func (p *puller) resolveLocal() {
253254
}
254255

255256
func (p *puller) resolve(ctx context.Context, g session.Group) error {
256-
// key is used to synchronize resolutions that can happen in parallel when doing multi-stage.
257-
key := "resolve::" + p.ref + "::" + platforms.Format(p.platform)
258-
_, err := p.is.g.Do(ctx, key, func(ctx context.Context) (_ interface{}, err error) {
257+
_, err := p.g.Do(ctx, "", func(ctx context.Context) (_ interface{}, err error) {
259258
resolveProgressDone := oneOffProgress(ctx, "resolve "+p.src.Reference.String())
260259
defer func() {
261260
resolveProgressDone(err)
@@ -329,6 +328,10 @@ func (p *puller) CacheKey(ctx context.Context, g session.Group, index int) (stri
329328
return dgst.String(), nil, false, nil
330329
}
331330

331+
if len(p.config) == 0 {
332+
return "", nil, false, errors.Errorf("invalid empty config file resolved for %s", p.src.Reference.String())
333+
}
334+
332335
k := cacheKeyFromConfig(p.config).String()
333336
if k == "" {
334337
dgst, err := p.mainManifestKey(p.platform)
@@ -360,8 +363,10 @@ func (p *puller) getRef(ctx context.Context, diffIDs []layer.DiffID, opts ...cac
360363

361364
func (p *puller) Snapshot(ctx context.Context, g session.Group) (cache.ImmutableRef, error) {
362365
p.resolveLocal()
363-
if err := p.resolve(ctx, g); err != nil {
364-
return nil, err
366+
if len(p.config) == 0 {
367+
if err := p.resolve(ctx, g); err != nil {
368+
return nil, err
369+
}
365370
}
366371

367372
if p.config != nil {
@@ -801,6 +806,7 @@ func cacheKeyFromConfig(dt []byte) digest.Digest {
801806
var img ocispec.Image
802807
err := json.Unmarshal(dt, &img)
803808
if err != nil {
809+
logrus.WithError(err).Errorf("failed to unmarshal image config for cache key %v", err)
804810
return digest.FromBytes(dt)
805811
}
806812
if img.RootFS.Type != "layers" || len(img.RootFS.DiffIDs) == 0 {

0 commit comments

Comments
 (0)