mirror of https://github.com/k3s-io/k3s
Merge pull request #67508 from brahmaroutu/flex_metrics
Provide Flex volume metrics if the plugin supports.pull/58/head
commit
b875ad8c08
|
@ -220,14 +220,16 @@ type DriverStatus struct {
|
|||
}
|
||||
|
||||
type DriverCapabilities struct {
|
||||
Attach bool `json:"attach"`
|
||||
SELinuxRelabel bool `json:"selinuxRelabel"`
|
||||
Attach bool `json:"attach"`
|
||||
SELinuxRelabel bool `json:"selinuxRelabel"`
|
||||
SupportsMetrics bool `json:"supportsMetrics"`
|
||||
}
|
||||
|
||||
func defaultCapabilities() *DriverCapabilities {
|
||||
return &DriverCapabilities{
|
||||
Attach: true,
|
||||
SELinuxRelabel: true,
|
||||
Attach: true,
|
||||
SELinuxRelabel: true,
|
||||
SupportsMetrics: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ type flexVolumeMounter struct {
|
|||
// the considered volume spec
|
||||
spec *volume.Spec
|
||||
readOnly bool
|
||||
volume.MetricsNil
|
||||
}
|
||||
|
||||
var _ volume.Mounter = &flexVolumeMounter{}
|
||||
|
|
|
@ -177,6 +177,14 @@ func (plugin *flexVolumePlugin) newMounterInternal(spec *volume.Spec, pod *api.P
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var metricsProvider volume.MetricsProvider
|
||||
if plugin.capabilities.SupportsMetrics {
|
||||
metricsProvider = volume.NewMetricsStatFS(plugin.host.GetPodVolumeDir(
|
||||
pod.UID, utilstrings.EscapeQualifiedNameForDisk(sourceDriver), spec.Name()))
|
||||
} else {
|
||||
metricsProvider = &volume.MetricsNil{}
|
||||
}
|
||||
|
||||
return &flexVolumeMounter{
|
||||
flexVolume: &flexVolume{
|
||||
driverName: sourceDriver,
|
||||
|
@ -188,6 +196,7 @@ func (plugin *flexVolumePlugin) newMounterInternal(spec *volume.Spec, pod *api.P
|
|||
podNamespace: pod.Namespace,
|
||||
podServiceAccountName: pod.Spec.ServiceAccountName,
|
||||
volName: spec.Name(),
|
||||
MetricsProvider: metricsProvider,
|
||||
},
|
||||
runner: runner,
|
||||
spec: spec,
|
||||
|
@ -202,14 +211,23 @@ func (plugin *flexVolumePlugin) NewUnmounter(volName string, podUID types.UID) (
|
|||
|
||||
// newUnmounterInternal is the internal unmounter routine to clean the volume.
|
||||
func (plugin *flexVolumePlugin) newUnmounterInternal(volName string, podUID types.UID, mounter mount.Interface, runner exec.Interface) (volume.Unmounter, error) {
|
||||
var metricsProvider volume.MetricsProvider
|
||||
if plugin.capabilities.SupportsMetrics {
|
||||
metricsProvider = volume.NewMetricsStatFS(plugin.host.GetPodVolumeDir(
|
||||
podUID, utilstrings.EscapeQualifiedNameForDisk(plugin.driverName), volName))
|
||||
} else {
|
||||
metricsProvider = &volume.MetricsNil{}
|
||||
}
|
||||
|
||||
return &flexVolumeUnmounter{
|
||||
flexVolume: &flexVolume{
|
||||
driverName: plugin.driverName,
|
||||
execPath: plugin.getExecutable(),
|
||||
mounter: mounter,
|
||||
plugin: plugin,
|
||||
podUID: podUID,
|
||||
volName: volName,
|
||||
driverName: plugin.driverName,
|
||||
execPath: plugin.getExecutable(),
|
||||
mounter: mounter,
|
||||
plugin: plugin,
|
||||
podUID: podUID,
|
||||
volName: volName,
|
||||
MetricsProvider: metricsProvider,
|
||||
},
|
||||
runner: runner,
|
||||
}, nil
|
||||
|
|
|
@ -31,7 +31,6 @@ type flexVolumeUnmounter struct {
|
|||
*flexVolume
|
||||
// Runner used to teardown the volume.
|
||||
runner exec.Interface
|
||||
volume.MetricsNil
|
||||
}
|
||||
|
||||
var _ volume.Unmounter = &flexVolumeUnmounter{}
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
utilstrings "k8s.io/kubernetes/pkg/util/strings"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
)
|
||||
|
||||
type flexVolume struct {
|
||||
|
@ -42,6 +43,8 @@ type flexVolume struct {
|
|||
volName string
|
||||
// the underlying plugin
|
||||
plugin *flexVolumePlugin
|
||||
// the metric plugin
|
||||
volume.MetricsProvider
|
||||
}
|
||||
|
||||
// volume.Volume interface
|
||||
|
|
Loading…
Reference in New Issue