mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
add a metric for retroactive sc errors
This commit is contained in:
parent
256ade5aa4
commit
42422a1d16
@ -65,6 +65,8 @@ func Register(pvLister PVLister, pvcLister PVCLister, pluginMgr *volume.VolumePl
|
|||||||
registerMetrics.Do(func() {
|
registerMetrics.Do(func() {
|
||||||
legacyregistry.CustomMustRegister(newPVAndPVCCountCollector(pvLister, pvcLister, pluginMgr))
|
legacyregistry.CustomMustRegister(newPVAndPVCCountCollector(pvLister, pvcLister, pluginMgr))
|
||||||
legacyregistry.MustRegister(volumeOperationErrorsMetric)
|
legacyregistry.MustRegister(volumeOperationErrorsMetric)
|
||||||
|
legacyregistry.MustRegister(retroactiveStorageClassMetric)
|
||||||
|
legacyregistry.MustRegister(retroactiveStorageClassErrorMetric)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +124,20 @@ var (
|
|||||||
StabilityLevel: metrics.ALPHA,
|
StabilityLevel: metrics.ALPHA,
|
||||||
},
|
},
|
||||||
[]string{"plugin_name", "operation_name"})
|
[]string{"plugin_name", "operation_name"})
|
||||||
|
|
||||||
|
retroactiveStorageClassMetric = metrics.NewCounter(
|
||||||
|
&metrics.CounterOpts{
|
||||||
|
Name: "retroactive_storageclass_total",
|
||||||
|
Help: "Total number of retroactive StorageClass assignments to persistent volume claim",
|
||||||
|
StabilityLevel: metrics.ALPHA,
|
||||||
|
})
|
||||||
|
|
||||||
|
retroactiveStorageClassErrorMetric = metrics.NewCounter(
|
||||||
|
&metrics.CounterOpts{
|
||||||
|
Name: "retroactive_storageclass_errors_total",
|
||||||
|
Help: "Total number of failed retroactive StorageClass assignments to persistent volume claim",
|
||||||
|
StabilityLevel: metrics.ALPHA,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
// volumeCount counts by PluginName and VolumeMode.
|
// volumeCount counts by PluginName and VolumeMode.
|
||||||
@ -231,6 +247,18 @@ func (collector *pvAndPVCCountCollector) pvcCollect(ch chan<- metrics.Metric) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RecordRetroactiveStorageClassMetric increments only retroactive_storageclass_total
|
||||||
|
// metric or both retroactive_storageclass_total and retroactive_storageclass_errors_total
|
||||||
|
// if success is false.
|
||||||
|
func RecordRetroactiveStorageClassMetric(success bool) {
|
||||||
|
if !success {
|
||||||
|
retroactiveStorageClassMetric.Inc()
|
||||||
|
retroactiveStorageClassErrorMetric.Inc()
|
||||||
|
} else {
|
||||||
|
retroactiveStorageClassMetric.Inc()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// RecordVolumeOperationErrorMetric records error count into metric
|
// RecordVolumeOperationErrorMetric records error count into metric
|
||||||
// volume_operation_total_errors for provisioning/deletion operations
|
// volume_operation_total_errors for provisioning/deletion operations
|
||||||
func RecordVolumeOperationErrorMetric(pluginName, opName string) {
|
func RecordVolumeOperationErrorMetric(pluginName, opName string) {
|
||||||
|
@ -355,10 +355,12 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(ctx context.Context, cl
|
|||||||
klog.V(4).Infof("FeatureGate[%s] is enabled, attempting to assign storage class to unbound PersistentVolumeClaim[%s]", features.RetroactiveDefaultStorageClass, claimToClaimKey(claim))
|
klog.V(4).Infof("FeatureGate[%s] is enabled, attempting to assign storage class to unbound PersistentVolumeClaim[%s]", features.RetroactiveDefaultStorageClass, claimToClaimKey(claim))
|
||||||
updated, err := ctrl.assignDefaultStorageClass(claim)
|
updated, err := ctrl.assignDefaultStorageClass(claim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
metrics.RecordRetroactiveStorageClassMetric(false)
|
||||||
return fmt.Errorf("can't update PersistentVolumeClaim[%q]: %w", claimToClaimKey(claim), err)
|
return fmt.Errorf("can't update PersistentVolumeClaim[%q]: %w", claimToClaimKey(claim), err)
|
||||||
}
|
}
|
||||||
if updated {
|
if updated {
|
||||||
klog.V(4).Infof("PersistentVolumeClaim[%q] update successful, restarting claim sync", claimToClaimKey(claim))
|
klog.V(4).Infof("PersistentVolumeClaim[%q] update successful, restarting claim sync", claimToClaimKey(claim))
|
||||||
|
metrics.RecordRetroactiveStorageClassMetric(true)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user