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 2.41.2 #2921

Merged
merged 4 commits into from
Mar 21, 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
6 changes: 3 additions & 3 deletions agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package config
import (
"fmt"
"io/fs"
"log"
"net"
"net/url"
"os"
Expand Down Expand Up @@ -414,10 +413,11 @@ func Application(cfg *Config) (*kingpin.Application, *string) {
}).Bool()

app.Flag("version", "Show application version").Short('v').Action(func(*kingpin.ParseContext) error {
// We use fmt instead of log package to provide proper output for --json flag.
if *jsonF {
log.Println(version.FullInfoJSON())
fmt.Println(version.FullInfoJSON()) //nolint:forbidigo
} else {
log.Println(version.FullInfo())
fmt.Println(version.FullInfo()) //nolint:forbidigo
}
os.Exit(0)

Expand Down
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.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ templates:
version: 1
summary: PostgreSQL connections in use
expr: |-
sum by(agent_id, agent_type, instance, node_id, node_name)
sum by(agent_id, agent_type, instance, node_id, node_name, service_name)
(pg_stat_activity_count{datname!~"template.*|postgres"})
/
on(agent_id, agent_type, instance, node_id, node_name)
on(agent_id, agent_type, instance, node_id, node_name, service_name)
pg_settings_max_connections * 100
> [[ .threshold ]]
params:
Expand Down
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)

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)

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: 2 additions & 0 deletions managed/services/grafana/auth_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ func cleanPath(p string) (string, error) {

cleanedPath := path.Clean(unescaped)

cleanedPath = strings.ReplaceAll(cleanedPath, "\n", " ")

u, err := url.Parse(cleanedPath)
if err != nil {
return "", err
Expand Down
3 changes: 3 additions & 0 deletions managed/services/grafana/auth_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ func Test_cleanPath(t *testing.T) {
}, {
"/v1/AWSInstanceCheck/..%2f..%2f/logs.zip",
"/logs.zip",
}, {
"/graph/api/datasources/proxy/8/?query=WITH%20(%0A%20%20%20%20CASE%20%0A%20%20%20%20%20%20%20%20WHEN%20(3000%20%25%2060)%20%3D%200%20THEN%203000%0A%20%20%20%20ELSE%2060%20END%0A)%20AS%20scale%0ASELECT%0A%20%20%20%20(intDiv(toUInt32(timestamp)%2C%203000)%20*%203000)%20*%201000%20as%20t%2C%0A%20%20%20%20hostname%20h%2C%0A%20%20%20%20status%20s%2C%0A%20%20%20%20SUM(req_count)%20as%20req_count%0AFROM%20pinba.report_by_all%0AWHERE%0A%20%20%20%20timestamp%20%3E%3D%20toDateTime(1707139680)%20AND%20timestamp%20%3C%3D%20toDateTime(1707312480)%0A%20%20%20%20AND%20status%20%3E%3D%20400%0A%20%20%20%20AND%20CASE%20WHEN%20%27all%27%20%3C%3E%20%27all%27%20THEN%20schema%20%3D%20%27all%27%20ELSE%201%20END%0A%20%20%20%20AND%20CASE%20WHEN%20%27all%27%20%3C%3E%20%27all%27%20THEN%20hostname%20%3D%20%27all%27%20ELSE%201%20END%0A%20%20%20%20AND%20CASE%20WHEN%20%27all%27%20%3C%3E%20%27all%27%20THEN%20server_name%20%3D%20%27all%27%20ELSE%201%20END%0AGROUP%20BY%20t%2C%20h%2C%20s%0AORDER%20BY%20t%20FORMAT%20JSON",
"/graph/api/datasources/proxy/8/",
},
}
for _, tt := range tests {
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
16 changes: 7 additions & 9 deletions update/ansible/playbook/tasks/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@
path: /etc/supervisord.d/supervisord.ini
when: not is_docker

- name: Stop systemd pmm-agent service, if running
systemd:
name: pmm-agent
state: stopped
enabled: no
when: not is_docker

- name: Create grafana config
include_role:
name: grafana
Expand Down Expand Up @@ -304,15 +311,6 @@
include_role:
name: clickhouse

# Fix things that should be fixed before restarts.

- name: Stop systemd pmm-agent service, if running
systemd:
name: pmm-agent
state: stopped
enabled: no
when: not is_docker

# https://jira.percona.com/browse/PMM-9298
- name: Copy rezise-xfs file for lvm
copy:
Expand Down
Loading