Add SupportsMetrics() for Block-mode volumes

Volumes that are provisioned with `VolumeMode: Block` often have a
MetrucsProvider interface declared in their type. However, the
MetricsProvider should implement a GetMetrics() function. In the cases
where the storage drivers do not implement GetMetrics(), a panic can
occur.

Usual type-assertions are not sufficient in this case. All assertions
assume the interface is present. There is no straight forward way to
verify that a valid GetMetrics() function is provided.

By adding SupportsMetrics(), storage driver implementations require
careful reviewing for metrics support.
This commit is contained in:
Niels de Vos
2021-05-20 15:18:26 +02:00
parent fd3bbf6f9e
commit b997e0e4d6
15 changed files with 88 additions and 1 deletions

View File

@@ -49,6 +49,10 @@ type BlockVolume interface {
// ex. pods/{podUid}/{DefaultKubeletVolumeDevicesDirName}/{escapeQualifiedPluginName}/, {volumeName}
GetPodDeviceMapPath() (string, string)
// SupportsMetrics should return true if the MetricsProvider is
// initialized
SupportsMetrics() bool
// MetricsProvider embeds methods for exposing metrics (e.g.
// used, available space).
MetricsProvider