fix(host): check image desc is empty (#22057)

image.inf record chksum or image id not matched will cause image desc empty
This commit is contained in:
wanyaoqi
2025-02-05 18:53:58 +08:00
committed by GitHub
parent 7b5785ad12
commit 91ae9fa50d
3 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -2709,7 +2709,7 @@ func (h *SHostInfo) getProcessesPids(processesPrefix []string) (map[string]strin
segs := strings.Split(cmdline, "\x00")
if utils.IsInStringArray(segs[0], processesPrefix) {
res[segs[0]] = f.Name()
log.Infof("getProcessesPids append %s %s", segs[0], f.Name())
log.Debugf("getProcessesPids append %s %s", segs[0], f.Name())
}
}
}
@@ -150,6 +150,8 @@ func (l *SLocalImageCache) Load() error {
if len(desc.Chksum) > 0 && len(desc.Id) > 0 && desc.Id == l.imageId {
l.Desc = desc
return nil
} else {
log.Errorf("image %s desc not correct, desc.Chksum %s desc.Id %s l.imageId %s", imgPath, desc.Chksum, desc.Id, l.imageId)
}
}
@@ -192,8 +192,11 @@ func (c *SLocalImageCacheManager) getTotalSize(ctx context.Context) (int64, map[
images := make(map[string]IImageCache)
c.cachedImages.Range(func(imgId, imgObj any) bool {
img := imgObj.(IImageCache)
total += img.GetDesc().SizeMb
images[imgId.(string)] = img
imgDesc := img.GetDesc()
if imgDesc != nil {
total += img.GetDesc().SizeMb
images[imgId.(string)] = img
}
return true
})
return total, images