mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
add volume kubelet_volume_stats_health_abnormal to kubelet
This commit is contained in:
parent
f86ee5649b
commit
d71e21e01e
@ -61,6 +61,12 @@ var (
|
|||||||
[]string{"namespace", "persistentvolumeclaim"}, nil,
|
[]string{"namespace", "persistentvolumeclaim"}, nil,
|
||||||
metrics.ALPHA, "",
|
metrics.ALPHA, "",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
volumeStatsHealthAbnormalDesc = metrics.NewDesc(
|
||||||
|
metrics.BuildFQName("", kubeletmetrics.KubeletSubsystem, kubeletmetrics.VolumeStatsHealthAbnormalKey),
|
||||||
|
"Volume health status. The count is either 1 or 0",
|
||||||
|
[]string{"namespace", "persistentvolumeclaim"}, nil,
|
||||||
|
metrics.ALPHA, "")
|
||||||
)
|
)
|
||||||
|
|
||||||
type volumeStatsCollector struct {
|
type volumeStatsCollector struct {
|
||||||
@ -85,6 +91,7 @@ func (collector *volumeStatsCollector) DescribeWithStability(ch chan<- *metrics.
|
|||||||
ch <- volumeStatsInodesDesc
|
ch <- volumeStatsInodesDesc
|
||||||
ch <- volumeStatsInodesFreeDesc
|
ch <- volumeStatsInodesFreeDesc
|
||||||
ch <- volumeStatsInodesUsedDesc
|
ch <- volumeStatsInodesUsedDesc
|
||||||
|
ch <- volumeStatsHealthAbnormalDesc
|
||||||
}
|
}
|
||||||
|
|
||||||
// CollectWithStability implements the metrics.StableCollector interface.
|
// CollectWithStability implements the metrics.StableCollector interface.
|
||||||
@ -120,7 +127,16 @@ func (collector *volumeStatsCollector) CollectWithStability(ch chan<- metrics.Me
|
|||||||
addGauge(volumeStatsInodesDesc, pvcRef, float64(*volumeStat.Inodes))
|
addGauge(volumeStatsInodesDesc, pvcRef, float64(*volumeStat.Inodes))
|
||||||
addGauge(volumeStatsInodesFreeDesc, pvcRef, float64(*volumeStat.InodesFree))
|
addGauge(volumeStatsInodesFreeDesc, pvcRef, float64(*volumeStat.InodesFree))
|
||||||
addGauge(volumeStatsInodesUsedDesc, pvcRef, float64(*volumeStat.InodesUsed))
|
addGauge(volumeStatsInodesUsedDesc, pvcRef, float64(*volumeStat.InodesUsed))
|
||||||
|
addGauge(volumeStatsHealthAbnormalDesc, pvcRef, float64(convertBoolToFloat64(volumeStat.Abnormal)))
|
||||||
allPVCs.Insert(pvcUniqStr)
|
allPVCs.Insert(pvcUniqStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertBoolToFloat64(boolVal bool) float64 {
|
||||||
|
if boolVal {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
@ -47,6 +47,8 @@ func TestVolumeStatsCollector(t *testing.T) {
|
|||||||
# TYPE kubelet_volume_stats_inodes_used gauge
|
# TYPE kubelet_volume_stats_inodes_used gauge
|
||||||
# HELP kubelet_volume_stats_used_bytes [ALPHA] Number of used bytes in the volume
|
# HELP kubelet_volume_stats_used_bytes [ALPHA] Number of used bytes in the volume
|
||||||
# TYPE kubelet_volume_stats_used_bytes gauge
|
# TYPE kubelet_volume_stats_used_bytes gauge
|
||||||
|
# HELP kubelet_volume_stats_health_abnormal [ALPHA] Volume health status. The count is either 1 or 0
|
||||||
|
# TYPE kubelet_volume_stats_health_abnormal gauge
|
||||||
`
|
`
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -83,6 +85,9 @@ func TestVolumeStatsCollector(t *testing.T) {
|
|||||||
Name: "testpvc",
|
Name: "testpvc",
|
||||||
Namespace: "testns",
|
Namespace: "testns",
|
||||||
},
|
},
|
||||||
|
VolumeHealthStats: statsapi.VolumeHealthStats{
|
||||||
|
Abnormal: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -106,6 +111,9 @@ func TestVolumeStatsCollector(t *testing.T) {
|
|||||||
Name: "testpvc",
|
Name: "testpvc",
|
||||||
Namespace: "testns",
|
Namespace: "testns",
|
||||||
},
|
},
|
||||||
|
VolumeHealthStats: statsapi.VolumeHealthStats{
|
||||||
|
Abnormal: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -118,6 +126,7 @@ func TestVolumeStatsCollector(t *testing.T) {
|
|||||||
kubelet_volume_stats_inodes_free{namespace="testns",persistentvolumeclaim="testpvc"} 655344
|
kubelet_volume_stats_inodes_free{namespace="testns",persistentvolumeclaim="testpvc"} 655344
|
||||||
kubelet_volume_stats_inodes_used{namespace="testns",persistentvolumeclaim="testpvc"} 16
|
kubelet_volume_stats_inodes_used{namespace="testns",persistentvolumeclaim="testpvc"} 16
|
||||||
kubelet_volume_stats_used_bytes{namespace="testns",persistentvolumeclaim="testpvc"} 4.21789696e+09
|
kubelet_volume_stats_used_bytes{namespace="testns",persistentvolumeclaim="testpvc"} 4.21789696e+09
|
||||||
|
kubelet_volume_stats_health_abnormal{namespace="testns",persistentvolumeclaim="testpvc"} 1
|
||||||
`
|
`
|
||||||
|
|
||||||
metrics = []string{
|
metrics = []string{
|
||||||
@ -127,6 +136,7 @@ func TestVolumeStatsCollector(t *testing.T) {
|
|||||||
"kubelet_volume_stats_inodes_free",
|
"kubelet_volume_stats_inodes_free",
|
||||||
"kubelet_volume_stats_inodes_used",
|
"kubelet_volume_stats_inodes_used",
|
||||||
"kubelet_volume_stats_used_bytes",
|
"kubelet_volume_stats_used_bytes",
|
||||||
|
"kubelet_volume_stats_health_abnormal",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ const (
|
|||||||
VolumeStatsInodesKey = "volume_stats_inodes"
|
VolumeStatsInodesKey = "volume_stats_inodes"
|
||||||
VolumeStatsInodesFreeKey = "volume_stats_inodes_free"
|
VolumeStatsInodesFreeKey = "volume_stats_inodes_free"
|
||||||
VolumeStatsInodesUsedKey = "volume_stats_inodes_used"
|
VolumeStatsInodesUsedKey = "volume_stats_inodes_used"
|
||||||
|
VolumeStatsHealthAbnormalKey = "volume_stats_health_abnormal"
|
||||||
RunningPodsKey = "running_pods"
|
RunningPodsKey = "running_pods"
|
||||||
RunningContainersKey = "running_containers"
|
RunningContainersKey = "running_containers"
|
||||||
// Metrics keys of remote runtime operations
|
// Metrics keys of remote runtime operations
|
||||||
|
@ -200,6 +200,9 @@ func (s *volumeStatCalculator) parsePodVolumeStats(podName string, pvcRef *stats
|
|||||||
return stats.VolumeStats{
|
return stats.VolumeStats{
|
||||||
Name: podName,
|
Name: podName,
|
||||||
PVCRef: pvcRef,
|
PVCRef: pvcRef,
|
||||||
|
VolumeHealthStats: stats.VolumeHealthStats{
|
||||||
|
Abnormal: *metric.Abnormal,
|
||||||
|
},
|
||||||
FsStats: stats.FsStats{Time: metric.Time, AvailableBytes: &available, CapacityBytes: &capacity,
|
FsStats: stats.FsStats{Time: metric.Time, AvailableBytes: &available, CapacityBytes: &capacity,
|
||||||
UsedBytes: &used, Inodes: &inodes, InodesFree: &inodesFree, InodesUsed: &inodesUsed},
|
UsedBytes: &used, Inodes: &inodes, InodesFree: &inodesFree, InodesUsed: &inodesUsed},
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,7 @@ func expectedBlockMetrics() *volume.Metrics {
|
|||||||
Available: resource.NewQuantity(available, resource.BinarySI),
|
Available: resource.NewQuantity(available, resource.BinarySI),
|
||||||
Capacity: resource.NewQuantity(capacity, resource.BinarySI),
|
Capacity: resource.NewQuantity(capacity, resource.BinarySI),
|
||||||
Used: resource.NewQuantity(available-capacity, resource.BinarySI),
|
Used: resource.NewQuantity(available-capacity, resource.BinarySI),
|
||||||
|
Abnormal: &volumeCondition.Abnormal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +269,17 @@ type VolumeStats struct {
|
|||||||
// Reference to the PVC, if one exists
|
// Reference to the PVC, if one exists
|
||||||
// +optional
|
// +optional
|
||||||
PVCRef *PVCReference `json:"pvcRef,omitempty"`
|
PVCRef *PVCReference `json:"pvcRef,omitempty"`
|
||||||
|
|
||||||
|
// VolumeHealthStats contains data about volume health
|
||||||
|
// +optional
|
||||||
|
VolumeHealthStats `json:"volumeHealthStats,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// VolumeHealthStats contains data about volume health.
|
||||||
|
type VolumeHealthStats struct {
|
||||||
|
// Normal volumes are available for use and operating optimally.
|
||||||
|
// An abnormal volume does not meet these criteria.
|
||||||
|
Abnormal bool `json:"abnormal,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PVCReference contains enough information to describe the referenced PVC.
|
// PVCReference contains enough information to describe the referenced PVC.
|
||||||
|
Loading…
Reference in New Issue
Block a user