Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

volumemgr/updatestatus: fix crash by checking status.Blobs is not empty #2966

Merged
merged 2 commits into from
Dec 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/pillar/cmd/volumemgr/updatestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ func doUpdateContentTree(ctx *volumemgrContext, status *types.ContentTreeStatus)
if len(status.Blobs) == 0 {
AddBlobsToContentTreeStatus(ctx, status, rootBlob.Sha256)
}
} else {
// Not an OCI registry, thus must have a valid sha256
if status.ContentSha256 == "" {
err := fmt.Sprintf("doUpdateContentTree(%s) name %s: no content sha256 defined",
status.Key(), status.DisplayName)
log.Errorf(err)
status.SetErrorDescription(types.ErrorDescription{Error: err})
changed = true
return changed, false
}
}

// at this point, we at least are downloading
Expand Down Expand Up @@ -229,6 +239,11 @@ func doUpdateContentTree(ctx *volumemgrContext, status *types.ContentTreeStatus)
currentSize, totalSize, status.Progress)
}

if len(status.Blobs) == 0 {
log.Errorf("doUpdateContentTree(%s) name %s: blobs array is empty",
status.Key(), status.DisplayName)
return changed, false
}
rootBlob := lookupOrCreateBlobStatus(ctx, status.Blobs[0])
if rootBlob == nil {
log.Errorf("doUpdateContentTree(%s) name %s: could not find BlobStatus(%s)",
Expand Down