mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 07:39:22 +00:00
Support Capacity metric for block PVCs for in-tree drivers
PR #97972 added support for gathering metrics for Block PVCs provided by CSI drivers. The in-tree drivers can support at leas the most basic metric; Capacity.
This commit is contained in:
parent
2b9c81b87d
commit
e7dedc5cd1
@ -98,7 +98,7 @@ func (plugin *awsElasticBlockStorePlugin) newBlockVolumeMapperInternal(spec *vol
|
|||||||
partition = strconv.Itoa(int(ebs.Partition))
|
partition = strconv.Itoa(int(ebs.Partition))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &awsElasticBlockStoreMapper{
|
mapper := &awsElasticBlockStoreMapper{
|
||||||
awsElasticBlockStore: &awsElasticBlockStore{
|
awsElasticBlockStore: &awsElasticBlockStore{
|
||||||
podUID: podUID,
|
podUID: podUID,
|
||||||
volName: spec.Name(),
|
volName: spec.Name(),
|
||||||
@ -108,7 +108,16 @@ func (plugin *awsElasticBlockStorePlugin) newBlockVolumeMapperInternal(spec *vol
|
|||||||
mounter: mounter,
|
mounter: mounter,
|
||||||
plugin: plugin,
|
plugin: plugin,
|
||||||
},
|
},
|
||||||
readOnly: readOnly}, nil
|
readOnly: readOnly,
|
||||||
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(podUID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *awsElasticBlockStorePlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
func (plugin *awsElasticBlockStorePlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
||||||
|
@ -104,10 +104,18 @@ func (plugin *azureDataDiskPlugin) newBlockVolumeMapperInternal(spec *volume.Spe
|
|||||||
|
|
||||||
disk := makeDataDisk(spec.Name(), podUID, volumeSource.DiskName, plugin.host, plugin)
|
disk := makeDataDisk(spec.Name(), podUID, volumeSource.DiskName, plugin.host, plugin)
|
||||||
|
|
||||||
return &azureDataDiskMapper{
|
mapper := &azureDataDiskMapper{
|
||||||
dataDisk: disk,
|
dataDisk: disk,
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(podUID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *azureDataDiskPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
func (plugin *azureDataDiskPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
||||||
|
@ -101,7 +101,7 @@ func (plugin *cinderPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podU
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &cinderVolumeMapper{
|
mapper := &cinderVolumeMapper{
|
||||||
cinderVolume: &cinderVolume{
|
cinderVolume: &cinderVolume{
|
||||||
podUID: podUID,
|
podUID: podUID,
|
||||||
volName: spec.Name(),
|
volName: spec.Name(),
|
||||||
@ -111,7 +111,16 @@ func (plugin *cinderPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podU
|
|||||||
mounter: mounter,
|
mounter: mounter,
|
||||||
plugin: plugin,
|
plugin: plugin,
|
||||||
},
|
},
|
||||||
readOnly: readOnly}, nil
|
readOnly: readOnly,
|
||||||
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(podUID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *cinderPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
func (plugin *cinderPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
||||||
|
@ -171,7 +171,7 @@ func (plugin *fcPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUID t
|
|||||||
return nil, fmt.Errorf("fc: no fc disk information found. failed to make a new mapper")
|
return nil, fmt.Errorf("fc: no fc disk information found. failed to make a new mapper")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &fcDiskMapper{
|
mapper := &fcDiskMapper{
|
||||||
fcDisk: &fcDisk{
|
fcDisk: &fcDisk{
|
||||||
podUID: podUID,
|
podUID: podUID,
|
||||||
volName: spec.Name(),
|
volName: spec.Name(),
|
||||||
@ -184,7 +184,15 @@ func (plugin *fcPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUID t
|
|||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
mounter: &mount.SafeFormatAndMount{Interface: mounter, Exec: exec},
|
mounter: &mount.SafeFormatAndMount{Interface: mounter, Exec: exec},
|
||||||
deviceUtil: util.NewDeviceHandler(util.NewIOHandler()),
|
deviceUtil: util.NewDeviceHandler(util.NewIOHandler()),
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(podUID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *fcPlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {
|
func (plugin *fcPlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {
|
||||||
@ -393,6 +401,7 @@ func (c *fcDiskUnmounter) TearDownAt(dir string) error {
|
|||||||
// Block Volumes Support
|
// Block Volumes Support
|
||||||
type fcDiskMapper struct {
|
type fcDiskMapper struct {
|
||||||
*fcDisk
|
*fcDisk
|
||||||
|
volume.MetricsProvider
|
||||||
readOnly bool
|
readOnly bool
|
||||||
mounter mount.Interface
|
mounter mount.Interface
|
||||||
deviceUtil util.DeviceUtil
|
deviceUtil util.DeviceUtil
|
||||||
|
@ -108,7 +108,7 @@ func (plugin *gcePersistentDiskPlugin) newBlockVolumeMapperInternal(spec *volume
|
|||||||
partition = strconv.Itoa(int(volumeSource.Partition))
|
partition = strconv.Itoa(int(volumeSource.Partition))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &gcePersistentDiskMapper{
|
mapper := &gcePersistentDiskMapper{
|
||||||
gcePersistentDisk: &gcePersistentDisk{
|
gcePersistentDisk: &gcePersistentDisk{
|
||||||
volName: spec.Name(),
|
volName: spec.Name(),
|
||||||
podUID: podUID,
|
podUID: podUID,
|
||||||
@ -118,7 +118,16 @@ func (plugin *gcePersistentDiskPlugin) newBlockVolumeMapperInternal(spec *volume
|
|||||||
mounter: mounter,
|
mounter: mounter,
|
||||||
plugin: plugin,
|
plugin: plugin,
|
||||||
},
|
},
|
||||||
readOnly: readOnly}, nil
|
readOnly: readOnly,
|
||||||
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(podUID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *gcePersistentDiskPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
func (plugin *gcePersistentDiskPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
||||||
|
@ -161,12 +161,20 @@ func (plugin *iscsiPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &iscsiDiskMapper{
|
mapper := &iscsiDiskMapper{
|
||||||
iscsiDisk: iscsiDisk,
|
iscsiDisk: iscsiDisk,
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
exec: exec,
|
exec: exec,
|
||||||
deviceUtil: ioutil.NewDeviceHandler(ioutil.NewIOHandler()),
|
deviceUtil: ioutil.NewDeviceHandler(ioutil.NewIOHandler()),
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(podUID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *iscsiPlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {
|
func (plugin *iscsiPlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {
|
||||||
|
@ -161,7 +161,7 @@ func (plugin *localVolumePlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &localVolumeMapper{
|
mapper := &localVolumeMapper{
|
||||||
localVolume: &localVolume{
|
localVolume: &localVolume{
|
||||||
podUID: pod.UID,
|
podUID: pod.UID,
|
||||||
volName: spec.Name(),
|
volName: spec.Name(),
|
||||||
@ -169,8 +169,15 @@ func (plugin *localVolumePlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1
|
|||||||
plugin: plugin,
|
plugin: plugin,
|
||||||
},
|
},
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(pod.UID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *localVolumePlugin) NewBlockVolumeUnmapper(volName string,
|
func (plugin *localVolumePlugin) NewBlockVolumeUnmapper(volName string,
|
||||||
|
@ -524,13 +524,21 @@ func (plugin *rbdPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUID
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &rbdDiskMapper{
|
mapper := &rbdDiskMapper{
|
||||||
rbd: newRBD(podUID, spec.Name(), img, pool, ro, plugin, manager),
|
rbd: newRBD(podUID, spec.Name(), img, pool, ro, plugin, manager),
|
||||||
mon: mon,
|
mon: mon,
|
||||||
id: id,
|
id: id,
|
||||||
keyring: keyring,
|
keyring: keyring,
|
||||||
secret: secret,
|
secret: secret,
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(podUID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *rbdPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
func (plugin *rbdPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
||||||
|
@ -97,7 +97,7 @@ func (plugin *vsphereVolumePlugin) newBlockVolumeMapperInternal(spec *volume.Spe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
volPath := volumeSource.VolumePath
|
volPath := volumeSource.VolumePath
|
||||||
return &vsphereBlockVolumeMapper{
|
mapper := &vsphereBlockVolumeMapper{
|
||||||
vsphereVolume: &vsphereVolume{
|
vsphereVolume: &vsphereVolume{
|
||||||
volName: spec.Name(),
|
volName: spec.Name(),
|
||||||
podUID: podUID,
|
podUID: podUID,
|
||||||
@ -107,8 +107,15 @@ func (plugin *vsphereVolumePlugin) newBlockVolumeMapperInternal(spec *volume.Spe
|
|||||||
plugin: plugin,
|
plugin: plugin,
|
||||||
MetricsProvider: volume.NewMetricsStatFS(getPath(podUID, spec.Name(), plugin.host)),
|
MetricsProvider: volume.NewMetricsStatFS(getPath(podUID, spec.Name(), plugin.host)),
|
||||||
},
|
},
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
blockPath, err := mapper.GetGlobalMapPath(spec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get device path: %v", err)
|
||||||
|
}
|
||||||
|
mapper.MetricsProvider = volume.NewMetricsBlock(filepath.Join(blockPath, string(podUID)))
|
||||||
|
|
||||||
|
return mapper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *vsphereVolumePlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
func (plugin *vsphereVolumePlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user