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:
@@ -23,6 +23,11 @@ var _ MetricsProvider = &MetricsNil{}
|
||||
// metrics.
|
||||
type MetricsNil struct{}
|
||||
|
||||
// SupportsMetrics returns false for the MetricsNil type.
|
||||
func (*MetricsNil) SupportsMetrics() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// GetMetrics returns an empty Metrics and an error.
|
||||
// See MetricsProvider.GetMetrics
|
||||
func (*MetricsNil) GetMetrics() (*Metrics, error) {
|
||||
|
||||
Reference in New Issue
Block a user