Skip to content

Commit

Permalink
PMM-11717: backward compatibility with older pmm-client (#1860)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritbl authored Mar 13, 2023
1 parent 9486707 commit d551ba7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ api-test: ## Run API tests on dev env. Use `PMM_KUBECONFIG=/path/to/
go test -count=1 -race -p 1 -v ./api-tests/... -pmm.server-insecure-tls

check: ## Run required checkers and linters
LOG_LEVEL=error bin/golangci-lint run
bin/go-sumtype ./...
LOG_LEVEL=error bin/golangci-lint run ; \
bin/go-sumtype ./... ; \
bin/go-consistent -pedantic ./...

check-license: ## Run license header checks against source files
Expand Down
8 changes: 7 additions & 1 deletion managed/services/agents/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"github.com/percona/pmm/version"
)

var mysqlExporterVersionWithPluginCollector = version.MustParse("2.36.0-0")

// mysqldExporterConfig returns desired configuration of mysqld_exporter process.
func mysqldExporterConfig(service *models.Service, exporter *models.Agent, redactMode redactMode, pmmAgentVersion *version.Parsed) *agentpb.SetStateRequest_AgentProcess {
tdp := exporter.TemplateDelimiters(service)
Expand Down Expand Up @@ -65,7 +67,6 @@ func mysqldExporterConfig(service *models.Service, exporter *models.Agent, redac
"--collect.custom_query.lr.directory=" + pathsBase(pmmAgentVersion, tdp.Left, tdp.Right) + "/collectors/custom-queries/mysql/low-resolution",
"--collect.custom_query.mr.directory=" + pathsBase(pmmAgentVersion, tdp.Left, tdp.Right) + "/collectors/custom-queries/mysql/medium-resolution",
"--collect.custom_query.hr.directory=" + pathsBase(pmmAgentVersion, tdp.Left, tdp.Right) + "/collectors/custom-queries/mysql/high-resolution",
"--collect.plugins",

"--exporter.max-idle-conns=3",
"--exporter.max-open-conns=3",
Expand All @@ -74,6 +75,11 @@ func mysqldExporterConfig(service *models.Service, exporter *models.Agent, redac
"--web.listen-address=:" + tdp.Left + " .listen_port " + tdp.Right,
}

if !pmmAgentVersion.Less(mysqlExporterVersionWithPluginCollector) {
args = append(args,
"--collect.plugins")
}

if exporter.IsMySQLTablestatsGroupEnabled() {
// keep in sync with Prometheus scrape configs generator
tablestatsGroup := []string{
Expand Down
15 changes: 12 additions & 3 deletions managed/services/agents/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func TestMySQLdExporterConfig(t *testing.T) {
"--collect.perf_schema.indexiowaits",
"--collect.perf_schema.tableiowaits",
"--collect.perf_schema.tablelocks",
"--collect.plugins",
"--collect.slave_status",
"--collect.standard.go",
"--collect.standard.process",
Expand Down Expand Up @@ -178,7 +177,6 @@ func TestMySQLdExporterConfigTablestatsGroupDisabled(t *testing.T) {
"--collect.perf_schema.eventsstatements",
"--collect.perf_schema.eventswaits",
"--collect.perf_schema.file_events",
"--collect.plugins",
"--collect.slave_status",
"--collect.standard.go",
"--collect.standard.process",
Expand Down Expand Up @@ -218,6 +216,18 @@ func TestMySQLdExporterConfigTablestatsGroupDisabled(t *testing.T) {
actual := mysqldExporterConfig(mysql, exporter, exposeSecrets, pmmAgentVersion)
assert.Equal(t, "DATA_SOURCE_NAME=tcp(1.2.3.4:3306)/?timeout=1s&tls=custom", actual.Env[0])
})

t.Run("V236_EnablesPluginCollector", func(t *testing.T) {
pmmAgentVersion := version.MustParse("2.36.0")
actual := mysqldExporterConfig(mysql, exporter, exposeSecrets, pmmAgentVersion)
assert.Contains(t, actual.Args, "--collect.plugins")
})

t.Run("beforeV236_NoPluginCollector", func(t *testing.T) {
pmmAgentVersion := version.MustParse("2.35.0")
actual := mysqldExporterConfig(mysql, exporter, exposeSecrets, pmmAgentVersion)
assert.NotContains(t, actual.Args, "--collect.plugins")
})
}

func TestMySQLdExporterConfigDisabledCollectors(t *testing.T) {
Expand Down Expand Up @@ -266,7 +276,6 @@ func TestMySQLdExporterConfigDisabledCollectors(t *testing.T) {
"--collect.perf_schema.indexiowaits",
"--collect.perf_schema.tableiowaits",
"--collect.perf_schema.tablelocks",
"--collect.plugins",
"--collect.slave_status",
"--collect.standard.go",
"--collect.standard.process",
Expand Down

0 comments on commit d551ba7

Please sign in to comment.