mirror of https://github.com/k3s-io/k3s
Merge pull request #52588 from bobbypage/cristatsprovider-fixes
Automatic merge from submit-queue (batch tested with PRs 52486, 52588, 52524). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.. Fix nil pointer dereference in cri stats provider when there are no image file systems **What this PR does / why we need it**: This PR fixes a nil pointer dereference in CRI stats provider when there are no image filesystems. See https://github.com/kubernetes/kubernetes/pull/51152 for discussion. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note ``` /cc yujuhong yguo0905pull/6/head
commit
02731cc767
|
@ -258,21 +258,23 @@ func (p *criStatsProvider) makeContainerStats(
|
|||
result.Rootfs.InodesUsed = &stats.WritableLayer.InodesUsed.Value
|
||||
}
|
||||
}
|
||||
storageID := stats.WritableLayer.StorageId
|
||||
imageFsInfo, found := uuidToFsInfo[*storageID]
|
||||
if !found {
|
||||
imageFsInfo = p.getFsInfo(storageID)
|
||||
uuidToFsInfo[*storageID] = imageFsInfo
|
||||
}
|
||||
if imageFsInfo != nil {
|
||||
// The image filesystem UUID is unknown to the local node or there's an
|
||||
// error on retrieving the stats. In these cases, we omit those stats
|
||||
// and return the best-effort partial result. See
|
||||
// https://github.com/kubernetes/heapster/issues/1793.
|
||||
result.Rootfs.AvailableBytes = &imageFsInfo.Available
|
||||
result.Rootfs.CapacityBytes = &imageFsInfo.Capacity
|
||||
result.Rootfs.InodesFree = imageFsInfo.InodesFree
|
||||
result.Rootfs.Inodes = imageFsInfo.Inodes
|
||||
storageID := stats.GetWritableLayer().GetStorageId()
|
||||
if storageID != nil {
|
||||
imageFsInfo, found := uuidToFsInfo[*storageID]
|
||||
if !found {
|
||||
imageFsInfo = p.getFsInfo(storageID)
|
||||
uuidToFsInfo[*storageID] = imageFsInfo
|
||||
}
|
||||
if imageFsInfo != nil {
|
||||
// The image filesystem UUID is unknown to the local node or there's an
|
||||
// error on retrieving the stats. In these cases, we omit those stats
|
||||
// and return the best-effort partial result. See
|
||||
// https://github.com/kubernetes/heapster/issues/1793.
|
||||
result.Rootfs.AvailableBytes = &imageFsInfo.Available
|
||||
result.Rootfs.CapacityBytes = &imageFsInfo.Capacity
|
||||
result.Rootfs.InodesFree = imageFsInfo.InodesFree
|
||||
result.Rootfs.Inodes = imageFsInfo.Inodes
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue