Chnaged error type check from errors.Is() to errors.As() because errors.Is() always returns False

Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
This commit is contained in:
Anatolii Dutchak
2021-04-08 12:55:17 +03:00
parent ebcf99ad27
commit cc9279b283

View File

@ -161,8 +161,10 @@ func (p *HPAProvider) updateHPAs() error {
c, err := p.collectorFactory.NewCollector(&hpa, config, interval)
if err != nil {
// Only log when it's not a PluginNotFoundError AND flag disregardIncompatibleHPAs is true
if !(errors.Is(err, &collector.PluginNotFoundError{}) && p.disregardIncompatibleHPAs) {
// Only log when it's not a PluginNotFoundError AND flag disregardIncompatibleHPAs is true
var pluginNotFoundError *collector.PluginNotFoundError
if !(errors.As(err, &pluginNotFoundError) && p.disregardIncompatibleHPAs) {
p.recorder.Eventf(&hpa, apiv1.EventTypeWarning, "CreateNewMetricsCollector", "Failed to create new metrics collector: %v", err)
}