Reverted error check to errors.Is(), implemented Is() method for PluginNotFoundError
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
This commit is contained in:
@ -61,6 +61,12 @@ func (p *PluginNotFoundError) Error() string {
|
||||
return fmt.Sprintf("no plugin found for %s", p.metricTypeName)
|
||||
}
|
||||
|
||||
func (p *PluginNotFoundError) Is(target error) bool {
|
||||
t, ok := target.(*PluginNotFoundError)
|
||||
_ = t
|
||||
return ok
|
||||
}
|
||||
|
||||
func (c *CollectorFactory) RegisterPodsCollector(metricCollector string, plugin CollectorPlugin) error {
|
||||
if metricCollector == "" {
|
||||
c.podsPlugins.Any = plugin
|
||||
|
@ -161,10 +161,8 @@ 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
|
||||
var pluginNotFoundError *collector.PluginNotFoundError
|
||||
|
||||
if !(errors.As(err, &pluginNotFoundError) && p.disregardIncompatibleHPAs) {
|
||||
// Only log when it's not a PluginNotFoundError AND flag disregardIncompatibleHPAs is true
|
||||
if !(errors.Is(err, &collector.PluginNotFoundError{}) && p.disregardIncompatibleHPAs) {
|
||||
p.recorder.Eventf(&hpa, apiv1.EventTypeWarning, "CreateNewMetricsCollector", "Failed to create new metrics collector: %v", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user