Skip to content

Commit

Permalink
PMM-13001 Fix for PGSM switch in case of older versions. (#2899) (#2902)
Browse files Browse the repository at this point in the history
* PMM-13001 Fix.

* PMM-13001 Fix test.

* PMM-13001 Change descriptor.
  • Loading branch information
JiriCtvrtka authored Mar 18, 2024
1 parent 9a87836 commit 39e2b52
Show file tree
Hide file tree
Showing 8 changed files with 437 additions and 433 deletions.
2 changes: 1 addition & 1 deletion agent/serviceinfobroker/service_info_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (sib *ServiceInfoBroker) getPostgreSQLInfo(ctx context.Context, dsn string,
if err != nil && !errors.Is(err, sql.ErrNoRows) {
res.Error = err.Error()
}
res.PgsmVersion = pgsmVersion
res.PgsmVersion = &pgsmVersion

return &res
}
Expand Down
2 changes: 1 addition & 1 deletion agent/serviceinfobroker/service_info_broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func TestServiceInfoBroker(t *testing.T) {
}, 0)
require.NotNil(t, resp)
assert.Equal(t, []string{"postgres", "pmm-agent"}, resp.DatabaseList)
assert.Equal(t, "", resp.PgsmVersion)
assert.Equal(t, "", *resp.PgsmVersion)
})

t.Run("MongoDBWithSSL", func(t *testing.T) {
Expand Down
844 changes: 423 additions & 421 deletions api/agentpb/agent.pb.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion api/agentpb/agent.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/agentpb/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ message ServiceInfoResponse {
// A list of PostgreSQL databases.
repeated string database_list = 4;
// A version of pg_stat_monitor, empty if unavailable.
string pgsm_version = 5;
optional string pgsm_version = 5;
}

// JobStatusRequest is a ServerMessage asking pmm-agent for job status.
Expand Down
Binary file modified descriptor.bin
Binary file not shown.
14 changes: 7 additions & 7 deletions managed/models/agent_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ func (c *AzureOptions) Scan(src interface{}) error { return jsonScan(c, src) }

// PostgreSQLOptions represents structure for special PostgreSQL options.
type PostgreSQLOptions struct {
SSLCa string `json:"ssl_ca"`
SSLCert string `json:"ssl_cert"`
SSLKey string `json:"ssl_key"`
AutoDiscoveryLimit int32 `json:"auto_discovery_limit"`
DatabaseCount int32 `json:"database_count"`
PGSMVersion string `json:"pgsm_version"`
MaxExporterConnections int32 `json:"max_exporter_connections"`
SSLCa string `json:"ssl_ca"`
SSLCert string `json:"ssl_cert"`
SSLKey string `json:"ssl_key"`
AutoDiscoveryLimit int32 `json:"auto_discovery_limit"`
DatabaseCount int32 `json:"database_count"`
PGSMVersion *string `json:"pgsm_version"`
MaxExporterConnections int32 `json:"max_exporter_connections"`
}

// Value implements database/sql/driver.Valuer interface. Should be defined on the value.
Expand Down
2 changes: 1 addition & 1 deletion managed/services/management/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (s *PostgreSQLService) Add(ctx context.Context, req *managementpb.AddPostgr
}

// In case of not available PGSM extension it is switch to PGSS.
if req.QanPostgresqlPgstatmonitorAgent && row.PostgreSQLOptions.PGSMVersion == "" {
if req.QanPostgresqlPgstatmonitorAgent && row.PostgreSQLOptions.PGSMVersion != nil && *row.PostgreSQLOptions.PGSMVersion == "" {
res.Warning = "Could not to detect the pg_stat_monitor extension on your system. Falling back to the pg_stat_statements."
req.QanPostgresqlPgstatementsAgent = true
req.QanPostgresqlPgstatmonitorAgent = false
Expand Down

0 comments on commit 39e2b52

Please sign in to comment.