diff --git a/managed/services/agents/mongodb.go b/managed/services/agents/mongodb.go index 1a0e193a46..37cac807af 100644 --- a/managed/services/agents/mongodb.go +++ b/managed/services/agents/mongodb.go @@ -40,7 +40,7 @@ var ( newMongoExporterPMMVersion = version.MustParse("2.9.99") v2_24_99 = version.MustParse("2.24.99") v2_25_99 = version.MustParse("2.25.99") - v2_41_2 = version.MustParse("2.41.2") + v2_41_1 = version.MustParse("2.41.1-0") ) // mongodbExporterConfig returns desired configuration of mongodb_exporter process. @@ -57,7 +57,7 @@ func mongodbExporterConfig(node *models.Node, service *models.Service, exporter // was specified in the command line. // Starting with PMM 2.41.1 we added shards collector. switch { - case strings.Contains(pmmAgentVersion.String(), "2.41.1") || !pmmAgentVersion.Less(v2_41_2): // >= 2.41.1 + case !pmmAgentVersion.Less(v2_41_1): // >= 2.41.1 args = v226Args(exporter, tdp, listenAddress) if exporter.MongoDBOptions != nil && exporter.MongoDBOptions.EnableAllCollectors { diff --git a/managed/services/agents/mongodb_test.go b/managed/services/agents/mongodb_test.go index 0d9c0dd534..8accc04e9e 100644 --- a/managed/services/agents/mongodb_test.go +++ b/managed/services/agents/mongodb_test.go @@ -231,45 +231,6 @@ func TestMongodbExporterConfig226(t *testing.T) { }) } -func Test241PatchVersion(t *testing.T) { - shardsCompatibility := map[string]bool{ - "2.43.0": true, - "2.42.2": true, - "2.41.1": true, - "2.41.1-HEAD-xyz": true, - "2.41.0-HEAD-abc": false, - "2.41.0": false, - "2.26.1": false, - } - for pmmVersion, shardsSupported := range shardsCompatibility { - pmmAgentVersion := version.MustParse(pmmVersion) - node := &models.Node{ - Address: "1.2.3.4", - } - mongodb := &models.Service{ - Address: pointer.ToString("1.2.3.4"), - Port: pointer.ToUint16(27017), - } - exporter := &models.Agent{ - AgentID: "agent-id", - AgentType: models.MongoDBExporterType, - Username: pointer.ToString("username"), - Password: pointer.ToString("s3cur3 p@$$w0r4."), - AgentPassword: pointer.ToString("agent-password"), - } - exporter.MongoDBOptions = &models.MongoDBOptions{ - EnableAllCollectors: true, - } - actual, err := mongodbExporterConfig(node, mongodb, exporter, exposeSecrets, pmmAgentVersion) - require.NoError(t, err) - if shardsSupported { - require.Contains(t, actual.Args, "--collector.shards") - } else { - require.NotContains(t, actual.Args, "--collector.shards") - } - } -} - func TestMongodbExporterConfig2411(t *testing.T) { pmmAgentVersion := version.MustParse("2.41.1") node := &models.Node{ diff --git a/managed/services/victoriametrics/scrape_configs.go b/managed/services/victoriametrics/scrape_configs.go index 3da84f7f00..6c05e6c716 100644 --- a/managed/services/victoriametrics/scrape_configs.go +++ b/managed/services/victoriametrics/scrape_configs.go @@ -403,7 +403,7 @@ func scrapeConfigsForMongoDBExporter(s *models.MetricsResolutions, params *scrap "indexstats", "collstats", } - if params.pmmAgentVersion != nil && (strings.Contains(params.pmmAgentVersion.String(), "2.41.1") || !params.pmmAgentVersion.Less(version.MustParse("2.41.2"))) { + if params.pmmAgentVersion != nil && !params.pmmAgentVersion.Less(version.MustParse("2.41.1-0")) { defaultCollectors = append(defaultCollectors, "shards") }