mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Add volume reconstruction metrics
Count nr. of volumes that kubelet tried to reconstruct + reconstruction errors.
This commit is contained in:
parent
4dd887797f
commit
bd73aee9db
@ -30,7 +30,9 @@ const (
|
|||||||
pluginNameNotAvailable = "N/A"
|
pluginNameNotAvailable = "N/A"
|
||||||
|
|
||||||
// Metric keys for Volume Manager.
|
// Metric keys for Volume Manager.
|
||||||
volumeManagerTotalVolumes = "volume_manager_total_volumes"
|
volumeManagerTotalVolumes = "volume_manager_total_volumes"
|
||||||
|
reconstructedVolumesTotal = "reconstructed_volumes_total"
|
||||||
|
reconstructedVolumesErrorsTotal = "reconstructed_volumes_errors_total"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -43,6 +45,21 @@ var (
|
|||||||
nil,
|
nil,
|
||||||
metrics.ALPHA, "",
|
metrics.ALPHA, "",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ReconstructedVolumesTotal = metrics.NewCounter(
|
||||||
|
&metrics.CounterOpts{
|
||||||
|
Name: reconstructedVolumesTotal,
|
||||||
|
Help: "The number of volumes that were attempted to be reconstructed from the operating system during kubelet startup. This includes both successful and failed reconstruction.",
|
||||||
|
StabilityLevel: metrics.ALPHA,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
ReconstructedVolumesErrorsTotal = metrics.NewCounter(
|
||||||
|
&metrics.CounterOpts{
|
||||||
|
Name: reconstructedVolumesErrorsTotal,
|
||||||
|
Help: "The number of volumes that failed reconstruction from the operating system during kubelet startup.",
|
||||||
|
StabilityLevel: metrics.ALPHA,
|
||||||
|
},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// volumeCount is a map of maps used as a counter.
|
// volumeCount is a map of maps used as a counter.
|
||||||
@ -61,6 +78,8 @@ func (v volumeCount) add(state, plugin string) {
|
|||||||
func Register(asw cache.ActualStateOfWorld, dsw cache.DesiredStateOfWorld, pluginMgr *volume.VolumePluginMgr) {
|
func Register(asw cache.ActualStateOfWorld, dsw cache.DesiredStateOfWorld, pluginMgr *volume.VolumePluginMgr) {
|
||||||
registerMetrics.Do(func() {
|
registerMetrics.Do(func() {
|
||||||
legacyregistry.CustomMustRegister(&totalVolumesCollector{asw: asw, dsw: dsw, pluginMgr: pluginMgr})
|
legacyregistry.CustomMustRegister(&totalVolumesCollector{asw: asw, dsw: dsw, pluginMgr: pluginMgr})
|
||||||
|
legacyregistry.MustRegister(ReconstructedVolumesTotal)
|
||||||
|
legacyregistry.MustRegister(ReconstructedVolumesErrorsTotal)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/config"
|
"k8s.io/kubernetes/pkg/kubelet/config"
|
||||||
|
"k8s.io/kubernetes/pkg/kubelet/volumemanager/metrics"
|
||||||
volumepkg "k8s.io/kubernetes/pkg/volume"
|
volumepkg "k8s.io/kubernetes/pkg/volume"
|
||||||
"k8s.io/kubernetes/pkg/volume/util"
|
"k8s.io/kubernetes/pkg/volume/util"
|
||||||
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
|
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
|
||||||
@ -177,7 +178,14 @@ func getVolumesFromPodDir(podDir string) ([]podVolume, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reconstruct volume data structure by reading the pod's volume directories
|
// Reconstruct volume data structure by reading the pod's volume directories
|
||||||
func (rc *reconciler) reconstructVolume(volume podVolume) (*reconstructedVolume, error) {
|
func (rc *reconciler) reconstructVolume(volume podVolume) (rvolume *reconstructedVolume, rerr error) {
|
||||||
|
metrics.ReconstructedVolumesTotal.Inc()
|
||||||
|
defer func() {
|
||||||
|
if rerr != nil {
|
||||||
|
metrics.ReconstructedVolumesErrorsTotal.Inc()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// plugin initializations
|
// plugin initializations
|
||||||
plugin, err := rc.volumePluginMgr.FindPluginByName(volume.pluginName)
|
plugin, err := rc.volumePluginMgr.FindPluginByName(volume.pluginName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user