Skip to content

Commit 70bc369

Browse files
authored
Merge pull request moby#3605 from tonistiigi/fix-snapshot-id-compat
cache: add fallback for snapshotID
2 parents 30df092 + 2c0c429 commit 70bc369

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cache/metadata.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,13 @@ func (md *cacheMetadata) queueMediaType(str string) error {
251251
}
252252

253253
func (md *cacheMetadata) getSnapshotID() string {
254-
return md.GetString(keySnapshot)
254+
sid := md.GetString(keySnapshot)
255+
// Note that historic buildkit releases did not always set the snapshot ID.
256+
// Fallback to record ID is needed for old build cache compatibility.
257+
if sid == "" {
258+
return md.ID()
259+
}
260+
return sid
255261
}
256262

257263
func (md *cacheMetadata) queueSnapshotID(str string) error {

0 commit comments

Comments
 (0)