mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
Merge pull request #78222 from humblec/volume_stats
Fix nil pointer dereference in metrics value calculator.
This commit is contained in:
commit
2dc0c01068
@ -138,12 +138,26 @@ func (s *volumeStatCalculator) calcAndStoreStats() {
|
|||||||
|
|
||||||
// parsePodVolumeStats converts (internal) volume.Metrics to (external) stats.VolumeStats structures
|
// parsePodVolumeStats converts (internal) volume.Metrics to (external) stats.VolumeStats structures
|
||||||
func (s *volumeStatCalculator) parsePodVolumeStats(podName string, pvcRef *stats.PVCReference, metric *volume.Metrics, volSpec v1.Volume) stats.VolumeStats {
|
func (s *volumeStatCalculator) parsePodVolumeStats(podName string, pvcRef *stats.PVCReference, metric *volume.Metrics, volSpec v1.Volume) stats.VolumeStats {
|
||||||
available := uint64(metric.Available.Value())
|
|
||||||
capacity := uint64(metric.Capacity.Value())
|
var available, capacity, used, inodes, inodesFree, inodesUsed uint64
|
||||||
used := uint64(metric.Used.Value())
|
if metric.Available != nil {
|
||||||
inodes := uint64(metric.Inodes.Value())
|
available = uint64(metric.Available.Value())
|
||||||
inodesFree := uint64(metric.InodesFree.Value())
|
}
|
||||||
inodesUsed := uint64(metric.InodesUsed.Value())
|
if metric.Capacity != nil {
|
||||||
|
capacity = uint64(metric.Capacity.Value())
|
||||||
|
}
|
||||||
|
if metric.Used != nil {
|
||||||
|
used = uint64(metric.Used.Value())
|
||||||
|
}
|
||||||
|
if metric.Inodes != nil {
|
||||||
|
inodes = uint64(metric.Inodes.Value())
|
||||||
|
}
|
||||||
|
if metric.InodesFree != nil {
|
||||||
|
inodesFree = uint64(metric.InodesFree.Value())
|
||||||
|
}
|
||||||
|
if metric.InodesUsed != nil {
|
||||||
|
inodesUsed = uint64(metric.InodesUsed.Value())
|
||||||
|
}
|
||||||
|
|
||||||
return stats.VolumeStats{
|
return stats.VolumeStats{
|
||||||
Name: podName,
|
Name: podName,
|
||||||
|
Loading…
Reference in New Issue
Block a user