Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
idsulik committed Jan 30, 2024
1 parent c62e402 commit 8eb8b81
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
8 changes: 8 additions & 0 deletions pkg/skaffold/build/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ type ImageDetails struct {
ID string `yaml:"id,omitempty"`
}

func (d ImageDetails) HasID() bool {
return d.ID != ""
}

func (d ImageDetails) HasDigest() bool {
return d.Digest != ""
}

// ArtifactCache is a map of [artifact dependencies hash : ImageDetails]
type ArtifactCache map[string]ImageDetails

Expand Down
24 changes: 12 additions & 12 deletions pkg/skaffold/build/cache/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ func (c *cache) lookupRemote(ctx context.Context, hash, tag string, platforms []
return found{hash: hash}
}

log.Entry(ctx).Debugf("Found %s remote with a different digest", tag)

cachedEntry.Digest = remoteDigest
c.cacheMutex.Lock()
c.artifactCache[hash] = cachedEntry
c.cacheMutex.Unlock()
return needsRemoteTagging{hash: hash, tag: tag, digest: cachedEntry.Digest, platforms: platforms}
if !cacheHit {
log.Entry(ctx).Debugf("Added digest for %s to cache entry", tag)
cachedEntry.Digest = remoteDigest
c.cacheMutex.Lock()
c.artifactCache[hash] = cachedEntry
c.cacheMutex.Unlock()
}
}

if cacheHit {
if cachedEntry.HasDigest() {
// Image exists remotely with a different tag
fqn := tag + "@" + cachedEntry.Digest // Actual tag will be ignored but we need the registry and the digest part of it.
log.Entry(ctx).Debugf("Looking up %s tag with the full fqn %s", tag, cachedEntry.Digest)
Expand All @@ -148,11 +148,11 @@ func (c *cache) lookupRemote(ctx context.Context, hash, tag string, platforms []
return needsRemoteTagging{hash: hash, tag: tag, digest: cachedEntry.Digest, platforms: platforms}
}
}
}

// Image exists locally
if cachedEntry.ID != "" && c.client != nil && c.client.ImageExists(ctx, cachedEntry.ID) {
return needsPushing{hash: hash, tag: tag, imageID: cachedEntry.ID}
}
// Image exists locally
if cachedEntry.HasID() && c.client != nil && c.client.ImageExists(ctx, cachedEntry.ID) {
return needsPushing{hash: hash, tag: tag, imageID: cachedEntry.ID}
}

return needsBuilding{hash: hash}
Expand Down

0 comments on commit 8eb8b81

Please sign in to comment.