Skip to content

Commit

Permalink
set MediaType in BlobStatus from VerifyImageStatus
Browse files Browse the repository at this point in the history
The MediaType field should not be empty because this can affect correct
function of IsManifest() and IsIndex().

This commit additionally logs MediaType in all pubsub structs to
facilitate future debugging.

Signed-off-by: Paul Gaiduk <paulg@zededa.com>
  • Loading branch information
europaul committed Jan 7, 2025
1 parent c8996df commit 5f70ef8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/pillar/cmd/volumemgr/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ func lookupOrCreateBlobStatus(ctx *volumemgrContext, blobSha string) *types.Blob
State: vs.State,
Path: vs.FileLocation,
Size: uint64(vs.Size),
MediaType: vs.MediaType,
CurrentSize: vs.Size,
TotalSize: vs.Size,
Progress: 100,
Expand Down
4 changes: 3 additions & 1 deletion pkg/pillar/types/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (status BlobStatus) LogCreate(logBase *base.LogObject) {
logObject.CloneAndAddField("state", status.State.String()).
AddField("datastoreid-uuids", uuids).
AddField("size-int64", status.Size).
AddField("blobtype-string", status.MediaType).
AddField("mediatype", status.MediaType).
AddField("refcount-int64", status.RefCount).
AddField("has-verifier-ref-bool", status.HasVerifierRef).
AddField("has-downloader-ref-bool", status.HasDownloaderRef).
Expand All @@ -116,6 +116,7 @@ func (status BlobStatus) LogModify(logBase *base.LogObject, old interface{}) {
oldStatus.Size != status.Size {

logObject.CloneAndAddField("state", status.State.String()).
AddField("mediatype", status.MediaType).
AddField("refcount-int64", status.RefCount).
AddField("size-int64", status.Size).
AddField("has-verifier-ref-bool", status.HasVerifierRef).
Expand Down Expand Up @@ -145,6 +146,7 @@ func (status BlobStatus) LogDelete(logBase *base.LogObject) {
logObject := base.EnsureLogObject(logBase, base.BlobStatusLogType, status.RelativeURL,
nilUUID, status.LogKey())
logObject.CloneAndAddField("state", status.State.String()).
AddField("mediatype", status.MediaType).
AddField("refcount-int64", status.RefCount).
AddField("size-int64", status.Size).
AddField("has-verifier-ref-bool", status.HasVerifierRef).
Expand Down
6 changes: 6 additions & 0 deletions pkg/pillar/types/verifiertypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (config VerifyImageConfig) LogCreate(logBase *base.LogObject) {
return
}
logObject.CloneAndAddField("refcount-int64", config.RefCount).
AddField("mediatype", config.MediaType).
AddField("expired-bool", config.Expired).
Noticef("VerifyImage config create")
}
Expand All @@ -58,6 +59,7 @@ func (config VerifyImageConfig) LogModify(logBase *base.LogObject, old interface
oldConfig.Expired != config.Expired {

logObject.CloneAndAddField("refcount-int64", config.RefCount).
AddField("mediatype", config.MediaType).
AddField("expired-bool", config.Expired).
AddField("old-refcount-int64", oldConfig.RefCount).
AddField("old-expired-bool", oldConfig.Expired).
Expand All @@ -74,6 +76,7 @@ func (config VerifyImageConfig) LogDelete(logBase *base.LogObject) {
logObject := base.EnsureLogObject(logBase, base.VerifyImageConfigLogType, config.Name,
nilUUID, config.LogKey())
logObject.CloneAndAddField("refcount-int64", config.RefCount).
AddField("mediatype", config.MediaType).
AddField("expired-bool", config.Expired).
Noticef("VerifyImage config delete")

Expand Down Expand Up @@ -116,6 +119,7 @@ func (status VerifyImageStatus) LogCreate(logBase *base.LogObject) {
return
}
logObject.CloneAndAddField("state", status.State.String()).
AddField("mediatype", status.MediaType).
AddField("refcount-int64", status.RefCount).
AddField("expired-bool", status.Expired).
AddField("size-int64", status.Size).
Expand All @@ -139,6 +143,7 @@ func (status VerifyImageStatus) LogModify(logBase *base.LogObject, old interface
oldStatus.FileLocation != status.FileLocation {

logObject.CloneAndAddField("state", status.State.String()).
AddField("mediatype", status.MediaType).
AddField("refcount-int64", status.RefCount).
AddField("expired-bool", status.Expired).
AddField("size-int64", status.Size).
Expand Down Expand Up @@ -169,6 +174,7 @@ func (status VerifyImageStatus) LogDelete(logBase *base.LogObject) {
logObject := base.EnsureLogObject(logBase, base.VerifyImageStatusLogType, status.Name,
nilUUID, status.LogKey())
logObject.CloneAndAddField("state", status.State.String()).
AddField("mediatype", status.MediaType).
AddField("refcount-int64", status.RefCount).
AddField("expired-bool", status.Expired).
AddField("size-int64", status.Size).
Expand Down

0 comments on commit 5f70ef8

Please sign in to comment.