Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-13001 Fix for PGSM switch in case of older versions. #2899

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

// 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 Expand Up @@ -441,7 +441,7 @@

if s.MongoDBOptions != nil {
if s.MongoDBOptions.TLSCertificateKey != "" {
q.Add("tlsCertificateKeyFile", tdp.Left+".TextFiles."+certificateKeyFilePlaceholder+tdp.Right)

Check failure on line 444 in managed/models/agent_model.go

View workflow job for this annotation

GitHub Actions / Checks

string `.TextFiles.` has 5 occurrences, make it a constant (goconst)
}
if s.MongoDBOptions.TLSCertificateKeyFilePassword != "" {
q.Add("tlsCertificateKeyFilePassword", s.MongoDBOptions.TLSCertificateKeyFilePassword)
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
Loading