mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #107490 from pacoxu/add-volume-stats-slow-log
add warning log if volume calculation took too long than 1 second
This commit is contained in:
commit
cc69f8f65d
@ -32,6 +32,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
"k8s.io/kubernetes/pkg/volume/util"
|
"k8s.io/kubernetes/pkg/volume/util"
|
||||||
|
utiltrace "k8s.io/utils/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
// volumeStatCalculator calculates volume metrics for a given pod periodically in the background and caches the result
|
// volumeStatCalculator calculates volume metrics for a given pod periodically in the background and caches the result
|
||||||
@ -133,7 +134,11 @@ func (s *volumeStatCalculator) calcAndStoreStats() {
|
|||||||
var ephemeralStats []stats.VolumeStats
|
var ephemeralStats []stats.VolumeStats
|
||||||
var persistentStats []stats.VolumeStats
|
var persistentStats []stats.VolumeStats
|
||||||
for name, v := range metricVolumes {
|
for name, v := range metricVolumes {
|
||||||
metric, err := v.GetMetrics()
|
metric, err := func() (*volume.Metrics, error) {
|
||||||
|
trace := utiltrace.New(fmt.Sprintf("Calculate volume metrics of %v for pod %v/%v", name, s.pod.Namespace, s.pod.Name))
|
||||||
|
defer trace.LogIfLong(1 * time.Second)
|
||||||
|
return v.GetMetrics()
|
||||||
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Expected for Volumes that don't support Metrics
|
// Expected for Volumes that don't support Metrics
|
||||||
if !volume.IsNotSupported(err) {
|
if !volume.IsNotSupported(err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user