diff --git a/managed/services/agents/connection_checker.go b/managed/services/agents/connection_checker.go index a97224530c9..8336603011b 100644 --- a/managed/services/agents/connection_checker.go +++ b/managed/services/agents/connection_checker.go @@ -101,7 +101,7 @@ func (c *ConnectionChecker) CheckConnectionToService(ctx context.Context, q *ref switch service.ServiceType { case models.MySQLServiceType: // TODO: remove the whole block after v3 release. - isSibSupported, err := isServiceInfoBrokerSupported(q, pmmAgentID) + isSibSupported, err := isServiceInfoBrokerSupported(agent) if err != nil { l.Warnf("Failed to check if SIB is supported: %s.", err) } diff --git a/managed/services/agents/service_info_broker.go b/managed/services/agents/service_info_broker.go index e62fd688539..029c4d95d90 100644 --- a/managed/services/agents/service_info_broker.go +++ b/managed/services/agents/service_info_broker.go @@ -133,8 +133,13 @@ func (c *ServiceInfoBroker) GetInfoFromService(ctx context.Context, q *reform.Qu } }() + // External exporters and haproxy do not support this functionality. + if service.ServiceType == models.ExternalServiceType || service.ServiceType == models.HAProxyServiceType { + return nil + } + pmmAgentID := pointer.GetString(agent.PMMAgentID) - isSibSupported, err := isServiceInfoBrokerSupported(q, pmmAgentID) + isSibSupported, err := isServiceInfoBrokerSupported(agent) if err != nil { return err } @@ -143,11 +148,6 @@ func (c *ServiceInfoBroker) GetInfoFromService(ctx context.Context, q *reform.Qu return nil } - // External exporters and haproxy do not support this functionality. - if service.ServiceType == models.ExternalServiceType || service.ServiceType == models.HAProxyServiceType { - return nil - } - pmmAgent, err := c.r.get(pmmAgentID) if err != nil { return err @@ -218,11 +218,7 @@ func updateServiceVersion(ctx context.Context, q *reform.Querier, resp agentpb.A return nil } -func isServiceInfoBrokerSupported(q *reform.Querier, pmmAgentID string) (bool, error) { - pmmAgent, err := models.FindAgentByID(q, pmmAgentID) - if err != nil { - return false, fmt.Errorf("failed to get PMM Agent: %w", err) - } +func isServiceInfoBrokerSupported(pmmAgent *models.Agent) (bool, error) { pmmAgentVersion, err := version.Parse(*pmmAgent.Version) if err != nil { return false, fmt.Errorf("failed to parse PMM agent version %q: %w", *pmmAgent.Version, err)