Skip to content

Commit

Permalink
PMM-12712 Simplify check.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Jan 10, 2024
1 parent 3b64632 commit 6121ff2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 42 deletions.
4 changes: 2 additions & 2 deletions managed/services/agents/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
39 changes: 0 additions & 39 deletions managed/services/agents/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion managed/services/victoriametrics/scrape_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 6121ff2

Please sign in to comment.