mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #107006 from gnufied/add-total-mount-time-metrics
Add metric for reporting total end-to-end mount time
This commit is contained in:
commit
d1a5513cb0
@ -23,6 +23,7 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
@ -207,6 +208,8 @@ type podToMount struct {
|
|||||||
// volume claim, this contains the volume.Spec.Name() of the persistent
|
// volume claim, this contains the volume.Spec.Name() of the persistent
|
||||||
// volume claim
|
// volume claim
|
||||||
outerVolumeSpecName string
|
outerVolumeSpecName string
|
||||||
|
// mountRequestTime stores time at which mount was requested
|
||||||
|
mountRequestTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -281,6 +284,11 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
|
|||||||
desiredSizeLimit: sizeLimit,
|
desiredSizeLimit: sizeLimit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
oldPodMount, ok := dsw.volumesToMount[volumeName].podsToMount[podName]
|
||||||
|
mountRequestTime := time.Now()
|
||||||
|
if ok && !volumePlugin.RequiresRemount(volumeSpec) {
|
||||||
|
mountRequestTime = oldPodMount.mountRequestTime
|
||||||
|
}
|
||||||
|
|
||||||
// Create new podToMount object. If it already exists, it is refreshed with
|
// Create new podToMount object. If it already exists, it is refreshed with
|
||||||
// updated values (this is required for volumes that require remounting on
|
// updated values (this is required for volumes that require remounting on
|
||||||
@ -290,6 +298,7 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
|
|||||||
pod: pod,
|
pod: pod,
|
||||||
volumeSpec: volumeSpec,
|
volumeSpec: volumeSpec,
|
||||||
outerVolumeSpecName: outerVolumeSpecName,
|
outerVolumeSpecName: outerVolumeSpecName,
|
||||||
|
mountRequestTime: mountRequestTime,
|
||||||
}
|
}
|
||||||
return volumeName, nil
|
return volumeName, nil
|
||||||
}
|
}
|
||||||
@ -407,6 +416,7 @@ func (dsw *desiredStateOfWorld) GetVolumesToMount() []VolumeToMount {
|
|||||||
OuterVolumeSpecName: podObj.outerVolumeSpecName,
|
OuterVolumeSpecName: podObj.outerVolumeSpecName,
|
||||||
VolumeGidValue: volumeObj.volumeGidValue,
|
VolumeGidValue: volumeObj.volumeGidValue,
|
||||||
ReportedInUse: volumeObj.reportedInUse,
|
ReportedInUse: volumeObj.reportedInUse,
|
||||||
|
MountRequestTime: podObj.mountRequestTime,
|
||||||
DesiredSizeLimit: volumeObj.desiredSizeLimit}})
|
DesiredSizeLimit: volumeObj.desiredSizeLimit}})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,6 +388,9 @@ type VolumeToMount struct {
|
|||||||
// DesiredSizeLimit indicates the desired upper bound on the size of the volume
|
// DesiredSizeLimit indicates the desired upper bound on the size of the volume
|
||||||
// (if so implemented)
|
// (if so implemented)
|
||||||
DesiredSizeLimit *resource.Quantity
|
DesiredSizeLimit *resource.Quantity
|
||||||
|
|
||||||
|
// time at which volume was requested to be mounted
|
||||||
|
MountRequestTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeviceMountState represents device mount state in a global path.
|
// DeviceMountState represents device mount state in a global path.
|
||||||
|
@ -778,6 +778,12 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// record total time it takes to mount a volume. This is end to end time that includes waiting for volume to attach, node to be update
|
||||||
|
// plugin call to succeed
|
||||||
|
mountRequestTime := volumeToMount.MountRequestTime
|
||||||
|
totalTimeTaken := time.Since(mountRequestTime).Seconds()
|
||||||
|
util.RecordOperationLatencyMetric(util.GetFullQualifiedPluginNameForVolume(volumePluginName, volumeToMount.VolumeSpec), "overall_volume_mount", totalTimeTaken)
|
||||||
|
|
||||||
markVolMountedErr := actualStateOfWorld.MarkVolumeAsMounted(markOpts)
|
markVolMountedErr := actualStateOfWorld.MarkVolumeAsMounted(markOpts)
|
||||||
if markVolMountedErr != nil {
|
if markVolMountedErr != nil {
|
||||||
// On failure, return error. Caller will log and retry.
|
// On failure, return error. Caller will log and retry.
|
||||||
|
Loading…
Reference in New Issue
Block a user