Return MetricsError with ErrCodeNotSupported code

GetMetrics function expects MetricsError error
with ErrCodeNotSupported code when driver for the volume
does not support metrics
Updated csi_metrics to return error when underlying csi
driver does not have GET_VOLUME_STATS capability
This commit is contained in:
Ji-Young Park
2019-07-06 10:32:40 -04:00
parent 886c5d261f
commit 528521cfae
3 changed files with 57 additions and 2 deletions

View File

@@ -35,7 +35,16 @@ func NewNotSupportedError() *MetricsError {
}
}
// NewNoPathDefined creates a new MetricsError with code NoPathDefined.
// NewNotSupportedErrorWithDriverName creates a new MetricsError with code NotSupported.
// driver name is added to the error message.
func NewNotSupportedErrorWithDriverName(name string) *MetricsError {
return &MetricsError{
Code: ErrCodeNotSupported,
Msg: fmt.Sprintf("metrics are not supported for %s volumes", name),
}
}
// NewNoPathDefinedError creates a new MetricsError with code NoPathDefined.
func NewNoPathDefinedError() *MetricsError {
return &MetricsError{
Code: ErrCodeNoPathDefined,