mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Revert "add volume kubelet_volume_stats_health_abnormal to kubelet"
This commit is contained in:
parent
7152825c06
commit
aa95513982
@ -61,12 +61,6 @@ var (
|
|||||||
[]string{"namespace", "persistentvolumeclaim"}, nil,
|
[]string{"namespace", "persistentvolumeclaim"}, nil,
|
||||||
metrics.ALPHA, "",
|
metrics.ALPHA, "",
|
||||||
)
|
)
|
||||||
|
|
||||||
volumeStatsHealthAbnormalDesc = metrics.NewDesc(
|
|
||||||
metrics.BuildFQName("", kubeletmetrics.KubeletSubsystem, kubeletmetrics.VolumeStatsHealthStatusAbnormalKey),
|
|
||||||
"Abnormal volume health status. The count is either 1 or 0. 1 indicates the volume is unhealthy, 0 indicates volume is healthy",
|
|
||||||
[]string{"namespace", "persistentvolumeclaim"}, nil,
|
|
||||||
metrics.ALPHA, "")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type volumeStatsCollector struct {
|
type volumeStatsCollector struct {
|
||||||
@ -91,7 +85,6 @@ 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.
|
||||||
@ -102,6 +95,7 @@ func (collector *volumeStatsCollector) CollectWithStability(ch chan<- metrics.Me
|
|||||||
}
|
}
|
||||||
addGauge := func(desc *metrics.Desc, pvcRef *stats.PVCReference, v float64, lv ...string) {
|
addGauge := func(desc *metrics.Desc, pvcRef *stats.PVCReference, v float64, lv ...string) {
|
||||||
lv = append([]string{pvcRef.Namespace, pvcRef.Name}, lv...)
|
lv = append([]string{pvcRef.Namespace, pvcRef.Name}, lv...)
|
||||||
|
|
||||||
ch <- metrics.NewLazyConstMetric(desc, metrics.GaugeValue, v, lv...)
|
ch <- metrics.NewLazyConstMetric(desc, metrics.GaugeValue, v, lv...)
|
||||||
}
|
}
|
||||||
allPVCs := sets.String{}
|
allPVCs := sets.String{}
|
||||||
@ -126,16 +120,7 @@ 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, convertBoolToFloat64(volumeStat.VolumeHealthStats.Abnormal))
|
|
||||||
allPVCs.Insert(pvcUniqStr)
|
allPVCs.Insert(pvcUniqStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertBoolToFloat64(boolVal bool) float64 {
|
|
||||||
if boolVal {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
@ -47,8 +47,6 @@ 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_status_abnormal [ALPHA] Abnormal volume health status. The count is either 1 or 0. 1 indicates the volume is unhealthy, 0 indicates volume is healthy
|
|
||||||
# TYPE kubelet_volume_stats_health_status_abnormal gauge
|
|
||||||
`
|
`
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -85,9 +83,6 @@ func TestVolumeStatsCollector(t *testing.T) {
|
|||||||
Name: "testpvc",
|
Name: "testpvc",
|
||||||
Namespace: "testns",
|
Namespace: "testns",
|
||||||
},
|
},
|
||||||
VolumeHealthStats: &statsapi.VolumeHealthStats{
|
|
||||||
Abnormal: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -111,9 +106,6 @@ func TestVolumeStatsCollector(t *testing.T) {
|
|||||||
Name: "testpvc",
|
Name: "testpvc",
|
||||||
Namespace: "testns",
|
Namespace: "testns",
|
||||||
},
|
},
|
||||||
VolumeHealthStats: &statsapi.VolumeHealthStats{
|
|
||||||
Abnormal: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -126,7 +118,6 @@ 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_status_abnormal{namespace="testns",persistentvolumeclaim="testpvc"} 1
|
|
||||||
`
|
`
|
||||||
|
|
||||||
metrics = []string{
|
metrics = []string{
|
||||||
@ -136,7 +127,6 @@ 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_status_abnormal",
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,29 +30,28 @@ import (
|
|||||||
|
|
||||||
// This const block defines the metric names for the kubelet metrics.
|
// This const block defines the metric names for the kubelet metrics.
|
||||||
const (
|
const (
|
||||||
KubeletSubsystem = "kubelet"
|
KubeletSubsystem = "kubelet"
|
||||||
NodeNameKey = "node_name"
|
NodeNameKey = "node_name"
|
||||||
NodeLabelKey = "node"
|
NodeLabelKey = "node"
|
||||||
PodWorkerDurationKey = "pod_worker_duration_seconds"
|
PodWorkerDurationKey = "pod_worker_duration_seconds"
|
||||||
PodStartDurationKey = "pod_start_duration_seconds"
|
PodStartDurationKey = "pod_start_duration_seconds"
|
||||||
CgroupManagerOperationsKey = "cgroup_manager_duration_seconds"
|
CgroupManagerOperationsKey = "cgroup_manager_duration_seconds"
|
||||||
PodWorkerStartDurationKey = "pod_worker_start_duration_seconds"
|
PodWorkerStartDurationKey = "pod_worker_start_duration_seconds"
|
||||||
PLEGRelistDurationKey = "pleg_relist_duration_seconds"
|
PLEGRelistDurationKey = "pleg_relist_duration_seconds"
|
||||||
PLEGDiscardEventsKey = "pleg_discard_events"
|
PLEGDiscardEventsKey = "pleg_discard_events"
|
||||||
PLEGRelistIntervalKey = "pleg_relist_interval_seconds"
|
PLEGRelistIntervalKey = "pleg_relist_interval_seconds"
|
||||||
PLEGLastSeenKey = "pleg_last_seen_seconds"
|
PLEGLastSeenKey = "pleg_last_seen_seconds"
|
||||||
EvictionsKey = "evictions"
|
EvictionsKey = "evictions"
|
||||||
EvictionStatsAgeKey = "eviction_stats_age_seconds"
|
EvictionStatsAgeKey = "eviction_stats_age_seconds"
|
||||||
PreemptionsKey = "preemptions"
|
PreemptionsKey = "preemptions"
|
||||||
VolumeStatsCapacityBytesKey = "volume_stats_capacity_bytes"
|
VolumeStatsCapacityBytesKey = "volume_stats_capacity_bytes"
|
||||||
VolumeStatsAvailableBytesKey = "volume_stats_available_bytes"
|
VolumeStatsAvailableBytesKey = "volume_stats_available_bytes"
|
||||||
VolumeStatsUsedBytesKey = "volume_stats_used_bytes"
|
VolumeStatsUsedBytesKey = "volume_stats_used_bytes"
|
||||||
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"
|
||||||
VolumeStatsHealthStatusAbnormalKey = "volume_stats_health_status_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
|
||||||
RuntimeOperationsKey = "runtime_operations_total"
|
RuntimeOperationsKey = "runtime_operations_total"
|
||||||
RuntimeOperationsDurationKey = "runtime_operations_duration_seconds"
|
RuntimeOperationsDurationKey = "runtime_operations_duration_seconds"
|
||||||
|
@ -177,10 +177,7 @@ 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 {
|
||||||
|
|
||||||
var (
|
var available, capacity, used, inodes, inodesFree, inodesUsed uint64
|
||||||
available, capacity, used, inodes, inodesFree, inodesUsed uint64
|
|
||||||
)
|
|
||||||
|
|
||||||
if metric.Available != nil {
|
if metric.Available != nil {
|
||||||
available = uint64(metric.Available.Value())
|
available = uint64(metric.Available.Value())
|
||||||
}
|
}
|
||||||
@ -200,18 +197,10 @@ func (s *volumeStatCalculator) parsePodVolumeStats(podName string, pvcRef *stats
|
|||||||
inodesUsed = uint64(metric.InodesUsed.Value())
|
inodesUsed = uint64(metric.InodesUsed.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeStats := stats.VolumeStats{
|
return stats.VolumeStats{
|
||||||
Name: podName,
|
Name: podName,
|
||||||
PVCRef: pvcRef,
|
PVCRef: pvcRef,
|
||||||
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},
|
||||||
}
|
}
|
||||||
|
|
||||||
if metric.Abnormal != nil {
|
|
||||||
volumeStats.VolumeHealthStats = &stats.VolumeHealthStats{
|
|
||||||
Abnormal: *metric.Abnormal,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return volumeStats
|
|
||||||
}
|
}
|
||||||
|
@ -128,9 +128,8 @@ func TestPVCRef(t *testing.T) {
|
|||||||
assert.Len(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), 4)
|
assert.Len(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), 4)
|
||||||
// Verify 'vol0' doesn't have a PVC reference
|
// Verify 'vol0' doesn't have a PVC reference
|
||||||
assert.Contains(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), kubestats.VolumeStats{
|
assert.Contains(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), kubestats.VolumeStats{
|
||||||
Name: vol0,
|
Name: vol0,
|
||||||
FsStats: expectedFSStats(),
|
FsStats: expectedFSStats(),
|
||||||
VolumeHealthStats: expectedVolumeHealthStats(),
|
|
||||||
})
|
})
|
||||||
// Verify 'vol1' has a PVC reference
|
// Verify 'vol1' has a PVC reference
|
||||||
assert.Contains(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), kubestats.VolumeStats{
|
assert.Contains(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), kubestats.VolumeStats{
|
||||||
@ -139,18 +138,16 @@ func TestPVCRef(t *testing.T) {
|
|||||||
Name: pvcClaimName0,
|
Name: pvcClaimName0,
|
||||||
Namespace: namespace0,
|
Namespace: namespace0,
|
||||||
},
|
},
|
||||||
FsStats: expectedFSStats(),
|
FsStats: expectedFSStats(),
|
||||||
VolumeHealthStats: expectedVolumeHealthStats(),
|
|
||||||
})
|
})
|
||||||
// // Verify 'vol2' has a PVC reference
|
// Verify 'vol2' has a PVC reference
|
||||||
assert.Contains(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), kubestats.VolumeStats{
|
assert.Contains(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), kubestats.VolumeStats{
|
||||||
Name: vol2,
|
Name: vol2,
|
||||||
PVCRef: &kubestats.PVCReference{
|
PVCRef: &kubestats.PVCReference{
|
||||||
Name: pvcClaimName1,
|
Name: pvcClaimName1,
|
||||||
Namespace: namespace0,
|
Namespace: namespace0,
|
||||||
},
|
},
|
||||||
FsStats: expectedBlockStats(),
|
FsStats: expectedBlockStats(),
|
||||||
VolumeHealthStats: expectedVolumeHealthStats(),
|
|
||||||
})
|
})
|
||||||
// Verify 'vol3' has a PVC reference
|
// Verify 'vol3' has a PVC reference
|
||||||
assert.Contains(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), kubestats.VolumeStats{
|
assert.Contains(t, append(vs.EphemeralVolumes, vs.PersistentVolumes...), kubestats.VolumeStats{
|
||||||
@ -159,8 +156,7 @@ func TestPVCRef(t *testing.T) {
|
|||||||
Name: pName0 + "-" + vol3,
|
Name: pName0 + "-" + vol3,
|
||||||
Namespace: namespace0,
|
Namespace: namespace0,
|
||||||
},
|
},
|
||||||
FsStats: expectedFSStats(),
|
FsStats: expectedFSStats(),
|
||||||
VolumeHealthStats: expectedVolumeHealthStats(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,13 +263,6 @@ func expectedFSStats() kubestats.FsStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func expectedVolumeHealthStats() *kubestats.VolumeHealthStats {
|
|
||||||
metric := expectedMetrics()
|
|
||||||
return &kubestats.VolumeHealthStats{
|
|
||||||
Abnormal: *metric.Abnormal,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fake block-volume/metrics provider, block-devices have no inodes
|
// Fake block-volume/metrics provider, block-devices have no inodes
|
||||||
var _ volume.BlockVolume = &fakeBlockVolume{}
|
var _ volume.BlockVolume = &fakeBlockVolume{}
|
||||||
|
|
||||||
@ -294,7 +283,6 @@ 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,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,17 +271,6 @@ 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 *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"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PVCReference contains enough information to describe the referenced PVC.
|
// PVCReference contains enough information to describe the referenced PVC.
|
||||||
|
@ -228,9 +228,8 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
|
|||||||
}),
|
}),
|
||||||
"VolumeStats": gstruct.MatchAllElements(summaryObjectID, gstruct.Elements{
|
"VolumeStats": gstruct.MatchAllElements(summaryObjectID, gstruct.Elements{
|
||||||
"test-empty-dir": gstruct.MatchAllFields(gstruct.Fields{
|
"test-empty-dir": gstruct.MatchAllFields(gstruct.Fields{
|
||||||
"Name": gomega.Equal("test-empty-dir"),
|
"Name": gomega.Equal("test-empty-dir"),
|
||||||
"PVCRef": gomega.BeNil(),
|
"PVCRef": gomega.BeNil(),
|
||||||
"VolumeHealthStats": gomega.BeNil(),
|
|
||||||
"FsStats": gstruct.MatchAllFields(gstruct.Fields{
|
"FsStats": gstruct.MatchAllFields(gstruct.Fields{
|
||||||
"Time": recent(maxStatsAge),
|
"Time": recent(maxStatsAge),
|
||||||
"AvailableBytes": fsCapacityBounds,
|
"AvailableBytes": fsCapacityBounds,
|
||||||
|
Loading…
Reference in New Issue
Block a user