Skip to content

Commit

Permalink
PMM-12712 Fix version check for QA versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Jan 10, 2024
1 parent 4d52e5c commit 5885134
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
6 changes: 3 additions & 3 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_1 = version.MustParse("2.41.1")
v2_41_2 = version.MustParse("2.41.2")
)

// mongodbExporterConfig returns desired configuration of mongodb_exporter process.
Expand All @@ -53,11 +53,11 @@ func mongodbExporterConfig(node *models.Node, service *models.Service, exporter
var args []string
// Starting with PMM 2.10.0, we are shipping the new mongodb_exporter
// Starting with PMM 2.25.0, we change the discovering-mode making it to discover all databases.
// Starting with PMM 2.41.1 we added shards collector.
// Until now, discovering mode was not working properly and was enabled only if mongodb.collstats-colls=
// was specified in the command line.
// Starting with PMM 2.41.1 we added shards collector.
switch {
case !pmmAgentVersion.Less(v2_41_1): // >= 2.41.1
case strings.Contains(pmmAgentVersion.String(), "2.41.1") || !pmmAgentVersion.Less(v2_41_2): // >= 2.41.1
args = v226Args(exporter, tdp, listenAddress)

if exporter.MongoDBOptions != nil && exporter.MongoDBOptions.EnableAllCollectors {
Expand Down
38 changes: 38 additions & 0 deletions managed/services/agents/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,44 @@ func TestMongodbExporterConfig226(t *testing.T) {
})
}

func Test241PatchVersion(t *testing.T) {
versions := map[string]bool{
"2.43.0": true,
"2.42.2": true,
"2.41.1": true,
"2.41.1-HEAD-xyz": true,
"2.41.0": false,
}
for pmmVersion, shardsCompatibility := range versions {
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 shardsCompatibility {
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 && !params.pmmAgentVersion.Less(version.MustParse("2.41.1")) {
if params.pmmAgentVersion != nil && (strings.Contains(params.pmmAgentVersion.String(), "2.41.1") || !params.pmmAgentVersion.Less(version.MustParse("2.41.2"))) {
defaultCollectors = append(defaultCollectors, "shards")
}

Expand Down

0 comments on commit 5885134

Please sign in to comment.