New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add migrated field to storage_operation_duration_seconds metric #99050
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -18,13 +18,15 @@ package util | |||
|
||||
import ( | ||||
"fmt" | ||||
"strconv" | ||||
"time" | ||||
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature" | ||||
"k8s.io/component-base/metrics" | ||||
"k8s.io/component-base/metrics/legacyregistry" | ||||
"k8s.io/kubernetes/pkg/features" | ||||
"k8s.io/kubernetes/pkg/volume" | ||||
"k8s.io/kubernetes/pkg/volume/util/types" | ||||
) | ||||
|
||||
const ( | ||||
|
@@ -47,7 +49,7 @@ var storageOperationMetric = metrics.NewHistogramVec( | |||
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600}, | ||||
StabilityLevel: metrics.ALPHA, | ||||
}, | ||||
[]string{"volume_plugin", "operation_name", "status"}, | ||||
[]string{"volume_plugin", "operation_name", "status", "migrated"}, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you enhance
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked the implementation of this here, some observation:
And it seems that my change of adding a migrated status does not fit in the picture as we are not checking the csi metrics at all. And even if we want to check it will be hard because the observation 2 I mentioned above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, maybe we need a todo to try to test this via unit tests. |
||||
) | ||||
|
||||
var storageOperationStatusMetric = metrics.NewCounterVec( | ||||
|
@@ -82,25 +84,29 @@ func registerMetrics() { | |||
} | ||||
|
||||
// OperationCompleteHook returns a hook to call when an operation is completed | ||||
func OperationCompleteHook(plugin, operationName string) func(*error) { | ||||
func OperationCompleteHook(plugin, operationName string) func(types.CompleteFuncParam) { | ||||
requestTime := time.Now() | ||||
opComplete := func(err *error) { | ||||
opComplete := func(c types.CompleteFuncParam) { | ||||
timeTaken := time.Since(requestTime).Seconds() | ||||
// Create metric with operation name and plugin name | ||||
status := statusSuccess | ||||
if *err != nil { | ||||
if *c.Err != nil { | ||||
// TODO: Establish well-known error codes to be able to distinguish | ||||
// user configuration errors from system errors. | ||||
status = statusFailUnknown | ||||
} | ||||
storageOperationMetric.WithLabelValues(plugin, operationName, status).Observe(timeTaken) | ||||
migrated := false | ||||
if c.Migrated != nil { | ||||
migrated = *c.Migrated | ||||
} | ||||
storageOperationMetric.WithLabelValues(plugin, operationName, status, strconv.FormatBool(migrated)).Observe(timeTaken) | ||||
storageOperationStatusMetric.WithLabelValues(plugin, operationName, status).Inc() | ||||
} | ||||
return opComplete | ||||
} | ||||
|
||||
// FSGroupCompleteHook returns a hook to call when volume recursive permission is changed | ||||
func FSGroupCompleteHook(plugin volume.VolumePlugin, spec *volume.Spec) func(*error) { | ||||
func FSGroupCompleteHook(plugin volume.VolumePlugin, spec *volume.Spec) func(types.CompleteFuncParam) { | ||||
return OperationCompleteHook(GetFullQualifiedPluginNameForVolume(plugin.GetPluginName(), spec), "volume_fsgroup_recursive_apply") | ||||
} | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the migrated field be part of provision and delete calls as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For CSI Migration, if a plugin has been migrated, then provision and delete will be handle by csi-provisioner. So any call happens here is a non-csi migration call