diff --git a/cmd/collectors/rest/rest.go b/cmd/collectors/rest/rest.go index 4407fe52e..6338a474a 100644 --- a/cmd/collectors/rest/rest.go +++ b/cmd/collectors/rest/rest.go @@ -583,12 +583,20 @@ func (r *Rest) GetRestData(href string) ([]gjson.Result, error) { result, err := rest.Fetch(r.Client, href) if err != nil { - return nil, fmt.Errorf("failed to fetch data: %w", err) + return r.handleError(err, href) } return result, nil } +func (r *Rest) handleError(err error, href string) ([]gjson.Result, error) { + if errs.IsRestErr(err, errs.MetroClusterNotConfigured) { + // MetroCluster is not configured in cluster, return ErrMetroClusterNotConfigured + return nil, fmt.Errorf("polling href=[%s] err: %w", href, errs.New(errs.ErrMetroClusterNotConfigured, err.Error())) + } + return nil, fmt.Errorf("failed to fetch data: %w", err) +} + func (r *Rest) CollectAutoSupport(p *collector.Payload) { var exporterTypes []string for _, exporter := range r.Exporters { diff --git a/cmd/poller/collector/collector.go b/cmd/poller/collector/collector.go index 3db3b734b..cabce9237 100644 --- a/cmd/poller/collector/collector.go +++ b/cmd/poller/collector/collector.go @@ -398,6 +398,8 @@ func (c *AbstractCollector) Start(wg *sync.WaitGroup) { c.Schedule.SetStandByModeMax(task, 1*time.Hour) // Log as info since some of these aren't errors c.Logger.Info().Err(err).Str("task", task.Name).Msg("Entering standby mode") + } else if errors.Is(err, errs.ErrMetroClusterNotConfigured) { + c.Logger.Trace().Err(err).Str("task", task.Name).Msg("MetroCluster is not configured in cluster") } else { c.Logger.Error().Err(err).Str("task", task.Name).Send() } diff --git a/pkg/errs/errors.go b/pkg/errs/errors.go index fe5888b9b..a2aa3c500 100644 --- a/pkg/errs/errors.go +++ b/pkg/errs/errors.go @@ -13,22 +13,23 @@ type harvestError string func (e harvestError) Error() string { return string(e) } const ( - ErrAPIRequestRejected = harvestError("API request rejected") - ErrAPIResponse = harvestError("error reading api response") - ErrAttributeNotFound = harvestError("attribute not found") - ErrAuthFailed = harvestError("auth failed") - ErrConfig = harvestError("configuration error") - ErrConnection = harvestError("connection error") - ErrImplement = harvestError("implementation error") - ErrInvalidItem = harvestError("invalid item") - ErrInvalidParam = harvestError("invalid parameter") - ErrMissingParam = harvestError("missing parameter") - ErrNoCollector = harvestError("no collectors") - ErrNoInstance = harvestError("no instances") - ErrNoMetric = harvestError("no metrics") - ErrPanic = harvestError("goroutine panic") - ErrPermissionDenied = harvestError("Permission denied") - ErrWrongTemplate = harvestError("wrong template") + ErrAPIRequestRejected = harvestError("API request rejected") + ErrAPIResponse = harvestError("error reading api response") + ErrAttributeNotFound = harvestError("attribute not found") + ErrAuthFailed = harvestError("auth failed") + ErrConfig = harvestError("configuration error") + ErrConnection = harvestError("connection error") + ErrImplement = harvestError("implementation error") + ErrInvalidItem = harvestError("invalid item") + ErrInvalidParam = harvestError("invalid parameter") + ErrMissingParam = harvestError("missing parameter") + ErrNoCollector = harvestError("no collectors") + ErrNoInstance = harvestError("no instances") + ErrNoMetric = harvestError("no metrics") + ErrPanic = harvestError("goroutine panic") + ErrPermissionDenied = harvestError("Permission denied") + ErrWrongTemplate = harvestError("wrong template") + ErrMetroClusterNotConfigured = harvestError("MetroCluster is not configured in cluster") ) const ( diff --git a/pkg/errs/ontap.go b/pkg/errs/ontap.go index f6b16469f..bfd646236 100644 --- a/pkg/errs/ontap.go +++ b/pkg/errs/ontap.go @@ -90,8 +90,9 @@ type OntapRestCode struct { } var ( - APINotFound = OntapRestCode{"API not found", 3} - TableNotFound = OntapRestCode{"Table is not found", 8585320} + APINotFound = OntapRestCode{"API not found", 3} + TableNotFound = OntapRestCode{"Table is not found", 8585320} + MetroClusterNotConfigured = OntapRestCode{"MetroCluster is not configured in cluster", 2426405} ) func IsRestErr(err error, sentinel OntapRestCode) bool {