change plugin name in fsgroupapplymetrics of csi and flexvolume to
distinguish different driver
This commit is contained in:
@@ -20,8 +20,10 @@ import (
|
||||
"fmt"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -110,8 +112,8 @@ func OperationCompleteHook(plugin, operationName string) func(*error) {
|
||||
}
|
||||
|
||||
// FSGroupCompleteHook returns a hook to call when volume recursive permission is changed
|
||||
func FSGroupCompleteHook(pluginName string) func(*error) {
|
||||
return OperationCompleteHook(pluginName, "volume_fsgroup_recursive_apply")
|
||||
func FSGroupCompleteHook(plugin volume.VolumePlugin, spec *volume.Spec) func(*error) {
|
||||
return OperationCompleteHook(GetFullQualifiedPluginNameForVolume(plugin.GetPluginName(), spec), "volume_fsgroup_recursive_apply")
|
||||
}
|
||||
|
||||
// GetFullQualifiedPluginNameForVolume returns full qualified plugin name for
|
||||
@@ -120,8 +122,13 @@ func FSGroupCompleteHook(pluginName string) func(*error) {
|
||||
// between metrics emitted for CSI volumes which may be handled by different
|
||||
// CSI plugin drivers.
|
||||
func GetFullQualifiedPluginNameForVolume(pluginName string, spec *volume.Spec) string {
|
||||
if spec != nil && spec.PersistentVolume != nil && spec.PersistentVolume.Spec.CSI != nil {
|
||||
return fmt.Sprintf("%s:%s", pluginName, spec.PersistentVolume.Spec.CSI.Driver)
|
||||
if spec != nil {
|
||||
if spec.Volume != nil && spec.Volume.CSI != nil && utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) {
|
||||
return fmt.Sprintf("%s:%s", pluginName, spec.Volume.CSI.Driver)
|
||||
}
|
||||
if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.CSI != nil {
|
||||
return fmt.Sprintf("%s:%s", pluginName, spec.PersistentVolume.Spec.CSI.Driver)
|
||||
}
|
||||
}
|
||||
return pluginName
|
||||
}
|
||||
|
Reference in New Issue
Block a user