Skip to content

Commit 83b1db2

Browse files
authored
Merge pull request moby#4187 from goller/fix/stargz-label-panic
fix: check snapshot labels to avoid panic
2 parents 84648b5 + 395e72c commit 83b1db2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cache/refs.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,17 @@ func (sr *immutableRef) prepareRemoteSnapshotsStargzMode(ctx context.Context, s
10991099
if err == nil { // usable as remote snapshot without unlazying.
11001100
defer func() {
11011101
// Remove tmp labels appended in this func
1102-
for k := range tmpLabels {
1103-
info.Labels[k] = ""
1102+
if info.Labels != nil {
1103+
for k := range tmpLabels {
1104+
info.Labels[k] = ""
1105+
}
1106+
} else {
1107+
// We are logging here to track to try to debug when and why labels are nil.
1108+
// Log can be removed when not happening anymore.
1109+
bklog.G(ctx).
1110+
WithField("snapshotID", snapshotID).
1111+
WithField("name", info.Name).
1112+
Debug("snapshots exist but labels are nil")
11041113
}
11051114
if _, err := r.cm.Snapshotter.Update(ctx, info, tmpFields...); err != nil {
11061115
bklog.G(ctx).Warn(errors.Wrapf(err,

0 commit comments

Comments
 (0)