UPSTREAM: 75805: Expose nfs volume stat metrics
Fixes
@@ -124,6 +124,7 @@ func (plugin *nfsPlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod, moun
mounter: mounter,
pod: pod,
plugin: plugin,
+ MetricsProvider: volume.NewMetricsStatFS(getPath(pod.UID, spec.Name(), plugin.host)),
},
server: source.Server,
exportPath: source.Path,
@@ -142,6 +143,7 @@ func (plugin *nfsPlugin) newUnmounterInternal(volName string, podUID types.UID,
mounter: mounter,
pod: &v1.Pod{ObjectMeta: metav1.ObjectMeta{UID: podUID}},
plugin: plugin,
+ MetricsProvider: volume.NewMetricsStatFS(getPath(podUID, volName, plugin.host)),
}}, nil
}
@@ -184,7 +186,7 @@ type nfs struct {
pod *v1.Pod
mounter mount.Interface
plugin *nfsPlugin
- volume.MetricsNil
+ volume.MetricsProvider
}
func (nfsVolume *nfs) GetPath() string {
@@ -311,3 +313,7 @@ func getVolumeSource(spec *volume.Spec) (*v1.NFSVolumeSource, bool, error) {
return nil, false, fmt.Errorf("Spec does not reference a NFS volume type")
}
+
+func getPath(uid types.UID, volName string, host volume.VolumeHost) string {
+ return host.GetPodVolumeDir(uid, utilstrings.EscapeQualifiedName(nfsPluginName), volName)
+}
