Skip to content

Commit 45a240e

Browse files
authored
2 parents 60426ec + 95c70a4 commit 45a240e

33 files changed

Lines changed: 1143 additions & 394 deletions

.github/workflows/claude.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ jobs:
3636

3737
steps:
3838
- name: Checkout repository
39-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
39+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4040
with:
4141
fetch-depth: 1
4242

4343
- name: Run Claude Code
4444
id: claude
45-
uses: anthropics/claude-code-action@e90deca47693f9457b72f2b53c17d7c445a87342 # v1.0.171
45+
uses: anthropics/claude-code-action@1f291e1cfe0f5fc21db2aef19af844591600ade7 # v1.0.206
4646
with:
4747
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
4848
# The job's `actions: read` permission only takes effect once the

.golangci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,13 @@ linters:
131131
formatters:
132132
enable:
133133
- gci
134-
- gofmt
135134
- gofumpt
136-
- goimports
137135
settings:
138136
gci:
139137
sections:
140138
- standard
141139
- default
142140
- prefix(github.com/percona/pmm)
143-
goimports:
144-
local-prefixes:
145-
- github.com/percona/pmm
146141
exclusions:
147142
generated: lax
148143
paths:

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ All long-running daemons expose on `127.0.0.1`:
441441
| `make doc-build` | Build user docs (used in CI); `make doc-build-pdf` for the PDF |
442442
| `make gen` | Generate all code (protobuf, reform, mocks, format) |
443443
| `make check` | Run Go/API linters (buf, golangci-lint, go-sumtype) |
444-
| `make format` | Format code (gofumpt, goimports, gci) |
444+
| `make format` | Format code (gofumpt, gci) |
445445
| `make release` | Build all binaries (agent, admin, managed, qan-api2) |
446446
| `make test-common` | Run common unit tests |
447447
| `make api-test` | Run API integration tests |

Makefile.include

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,8 @@ FILES = $(shell find . -type f -name '*.go')
6464
format: ## Format source code
6565
make -C api format
6666
go tool gofumpt -l -w $(FILES)
67-
go tool goimports -local github.com/percona/pmm -l -w $(FILES)
6867
go tool gci write --section Standard --section Default --section "Prefix(github.com/percona/pmm)" $(FILES)
6968

70-
format-fast: ## Format only (without running goimports and gci)
71-
@go tool gofumpt -l -w $(FILES)
72-
7369
serve: ## Serve API documentation with nginx
7470
nginx -p . -c api/nginx/nginx.conf
7571

agent/main_test.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
package main
1616

1717
import (
18+
"flag"
1819
"fmt"
1920
"os"
21+
"slices"
2022
"sort"
2123
"strings"
2224
"testing"
@@ -26,6 +28,10 @@ import (
2628
"golang.org/x/tools/go/packages"
2729
)
2830

31+
const dotFile = "packages.dot"
32+
33+
var updateF = flag.Bool("update", false, "update "+dotFile)
34+
2935
/*
3036
Commenting out these tests because not always we have a proper executable in the path.
3137
These tests should be moved to QA testing framework.
@@ -105,7 +111,8 @@ func TestImports(t *testing.T) {
105111

106112
// agents code should be independent
107113
for _, a := range []string{
108-
"github.com/percona/pmm/agent/agents/mongodb",
114+
// mongodb has no package of its own, only subpackages
115+
"github.com/percona/pmm/agent/agents/mongodb/...",
109116
"github.com/percona/pmm/agent/agents/mysql/perfschema",
110117
"github.com/percona/pmm/agent/agents/mysql/slowlog",
111118
"github.com/percona/pmm/agent/agents/noop",
@@ -178,13 +185,16 @@ func TestImports(t *testing.T) {
178185
for path, c := range constraints {
179186
pkgs, err := packages.Load(config, path)
180187
require.NoError(t, err)
188+
require.NotEmpty(t, pkgs, "pattern %s matched no packages", path)
189+
require.Zero(t, packages.PrintErrors(pkgs), "failed to load %s", path)
181190
allPkgs = append(allPkgs, pkgs...)
182191

192+
own := strings.TrimSuffix(path, "/...")
183193
for _, p := range pkgs {
184194
for _, d := range c.denyPrefixes {
185195
for i := range p.Imports {
186196
// allow own subpackages
187-
if strings.HasPrefix(i, path) {
197+
if strings.HasPrefix(i, own) {
188198
continue
189199
}
190200

@@ -209,12 +219,6 @@ func TestImports(t *testing.T) {
209219
}
210220
}
211221

212-
f, err := os.Create("packages.dot")
213-
require.NoError(t, err)
214-
t.Cleanup(func() {
215-
assert.NoError(t, f.Close())
216-
})
217-
218222
var lines []string
219223
for _, p := range allPkgs {
220224
pName := formatPkgName(t, p.PkgPath)
@@ -232,19 +236,25 @@ func TestImports(t *testing.T) {
232236
}
233237
}
234238
sort.Strings(lines)
239+
lines = slices.Compact(lines)
235240

236-
_, err = fmt.Fprintf(f, "digraph packages {\n")
237-
require.NoError(t, err)
238-
duplicate := make(map[string]struct{})
241+
var graph strings.Builder
242+
graph.WriteString("digraph packages {\n")
239243
for _, line := range lines {
240-
if _, ok := duplicate[line]; !ok {
241-
duplicate[line] = struct{}{}
242-
_, err = fmt.Fprint(f, line)
243-
require.NoError(t, err)
244-
}
244+
graph.WriteString(line)
245+
}
246+
graph.WriteString("}\n")
247+
248+
if *updateF {
249+
require.NoError(t, os.WriteFile(dotFile, []byte(graph.String()), 0o644))
250+
t.Logf("%s updated.", dotFile)
251+
return
245252
}
246-
_, err = fmt.Fprintf(f, "}\n")
253+
254+
expected, err := os.ReadFile(dotFile)
247255
require.NoError(t, err)
256+
assert.Equal(t, string(expected), graph.String(),
257+
"%s is stale; regenerate it with 'go test ./agent -run TestImports -update'.", dotFile)
248258
}
249259

250260
func formatPkgName(t *testing.T, name string) string {

agent/packages.dot

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,37 @@ digraph packages {
33
"/agentlocal" -> "/tailog";
44
"/agentlocal.test" -> "/agentlocal";
55
"/agents/cache.test" -> "/agents/cache";
6+
"/agents/mongodb/mongolog" -> "/agents";
7+
"/agents/mongodb/mongolog" -> "/agents/mongodb/mongolog/internal";
8+
"/agents/mongodb/mongolog" -> "/agents/mongodb/shared/report";
9+
"/agents/mongodb/mongolog.test" -> "/agents/mongodb/mongolog";
10+
"/agents/mongodb/mongolog/internal" -> "/agents/mongodb/shared/aggregator";
11+
"/agents/mongodb/mongolog/internal" -> "/agents/mongodb/shared/sender";
12+
"/agents/mongodb/mongolog/internal.test" -> "/agents/mongodb/mongolog/internal";
13+
"/agents/mongodb/profiler" -> "/agents";
14+
"/agents/mongodb/profiler" -> "/agents/mongodb/profiler/internal";
15+
"/agents/mongodb/profiler" -> "/agents/mongodb/shared/report";
16+
"/agents/mongodb/profiler.test" -> "/agents/mongodb/profiler";
17+
"/agents/mongodb/profiler/internal" -> "/agents/mongodb/profiler/internal/collector";
18+
"/agents/mongodb/profiler/internal" -> "/agents/mongodb/profiler/internal/parser";
19+
"/agents/mongodb/profiler/internal" -> "/agents/mongodb/shared/aggregator";
20+
"/agents/mongodb/profiler/internal" -> "/agents/mongodb/shared/report";
21+
"/agents/mongodb/profiler/internal" -> "/agents/mongodb/shared/sender";
22+
"/agents/mongodb/profiler/internal.test" -> "/agents/mongodb/profiler/internal";
23+
"/agents/mongodb/profiler/internal/collector.test" -> "/agents/mongodb/profiler/internal/collector";
24+
"/agents/mongodb/profiler/internal/parser" -> "/agents/mongodb/shared/aggregator";
25+
"/agents/mongodb/profiler/internal/parser" -> "/agents/mongodb/shared/report";
26+
"/agents/mongodb/profiler/internal/parser.test" -> "/agents/mongodb/profiler/internal/parser";
27+
"/agents/mongodb/realtimeanalytics" -> "/agents";
28+
"/agents/mongodb/realtimeanalytics" -> "/agents/mongodb/realtimeanalytics/parser";
29+
"/agents/mongodb/realtimeanalytics/parser.test" -> "/agents/mongodb/realtimeanalytics/parser";
30+
"/agents/mongodb/shared/aggregator" -> "/agents/mongodb/shared/fingerprinter";
31+
"/agents/mongodb/shared/aggregator" -> "/agents/mongodb/shared/report";
32+
"/agents/mongodb/shared/aggregator.test" -> "/agents/mongodb/shared/aggregator";
33+
"/agents/mongodb/shared/fingerprinter.test" -> "/agents/mongodb/shared/fingerprinter";
34+
"/agents/mongodb/shared/report.test" -> "/agents/mongodb/shared/report";
35+
"/agents/mongodb/shared/sender" -> "/agents/mongodb/shared/report";
36+
"/agents/mongodb/shared/sender.test" -> "/agents/mongodb/shared/sender";
637
"/agents/mysql/perfschema" -> "/agents";
738
"/agents/mysql/perfschema" -> "/agents/cache";
839
"/agents/mysql/perfschema" -> "/queryparser";

build/ansible/roles/nginx/files/conf.d/pmm.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
keepalive_timeout 75s;
3030
}
3131

32+
upstream victoriametrics {
33+
server 127.0.0.1:9090;
34+
keepalive 32;
35+
keepalive_requests 100;
36+
keepalive_timeout 75s;
37+
}
38+
3239
upstream nomad-server-json {
3340
server 127.0.0.1:4646;
3441
keepalive 32;
@@ -188,6 +195,21 @@
188195
}
189196

190197
# VictoriaMetrics
198+
# Remote-write ingestion bypasses vmproxy and goes straight to VictoriaMetrics.
199+
# vmproxy's only work is substituting the X-Proxy-Filter RBAC header into
200+
# extra_filters[] query params, which VictoriaMetrics honours on read paths
201+
# only, so on the write path it is pure passthrough plus a log line per
202+
# request. Authentication is unaffected: it is enforced by the server-level
203+
# auth_request above, not by vmproxy. Exact-match location, so it takes
204+
# precedence over the /victoriametrics/ prefix below.
205+
location = /victoriametrics/api/v1/write {
206+
proxy_pass http://victoriametrics/prometheus/api/v1/write;
207+
proxy_read_timeout 600;
208+
proxy_http_version 1.1;
209+
proxy_set_header Connection "";
210+
client_body_buffer_size 10m;
211+
}
212+
191213
location /victoriametrics/ {
192214
proxy_pass http://vmproxy/;
193215
proxy_read_timeout 600;

build/ansible/roles/supervisord/files/grafana.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ autostart = false
1313
startretries = 10
1414
startsecs = 1
1515
stopsignal = TERM
16-
stopwaitsecs = 300
16+
stopwaitsecs = 10
1717
stdout_logfile = /srv/logs/grafana.log
1818
stdout_logfile_maxbytes = 50MB
1919
stdout_logfile_backups = 2

build/ansible/roles/supervisord/files/pmm.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ autostart = false
1818
startretries = 3
1919
startsecs = 1
2020
stopsignal = TERM
21-
stopwaitsecs = 300
21+
stopwaitsecs = 10
2222
stdout_logfile = /srv/logs/pmm-init.log
2323
stdout_logfile_maxbytes = 20MB
2424
stdout_logfile_backups = 3
@@ -41,7 +41,7 @@ autostart = true
4141
startretries = 10
4242
startsecs = 1
4343
stopsignal = INT ; Fast Shutdown mode
44-
stopwaitsecs = 300
44+
stopwaitsecs = 30
4545
; postgresql.conf contains settings to log to stdout,
4646
; so we delegate logfile management to supervisord
4747
stdout_logfile = /srv/logs/postgresql14.log
@@ -57,7 +57,7 @@ autostart = true
5757
startretries = 10
5858
startsecs = 1
5959
stopsignal = TERM
60-
stopwaitsecs = 300
60+
stopwaitsecs = 30
6161
; config.xml contains settings to log to stdout (console),
6262
; so we delegate logfile managemenet to supervisord
6363
stdout_logfile = /srv/logs/clickhouse-server.log
@@ -94,7 +94,7 @@ autostart = true
9494
startretries = 1000
9595
startsecs = 1
9696
stopsignal = TERM
97-
stopwaitsecs = 300
97+
stopwaitsecs = 10
9898
stdout_logfile = /srv/logs/pmm-managed.log
9999
stdout_logfile_maxbytes = 50MB
100100
stdout_logfile_backups = 2

0 commit comments

Comments
 (0)