Skip to content

Commit 91e47be

Browse files
paweljwclaude
andcommitted
Opus: T-17092 Build cluster-agent from source, remove statement_timeout from DSN
coroot-cluster-agent hardcodes statement_timeout=<ms> as a PostgreSQL DSN parameter. lib/pq sends DSN parameters as startup parameters during the connection handshake. PgBouncer (since v1.20.0) rejects unrecognized startup parameters, breaking metrics collection for customers using PgBouncer as a connection pooler. The fix removes statement_timeout from the DSN. Query timeouts are still enforced client-side via Go's context.WithTimeout in the collector's Collect() method. To apply this patch, we now build cluster-agent from source (like we already do for node-agent) instead of pulling a pre-built image. Also upgrades cluster-agent from v1.2.4 to v1.6.1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8170f77 commit 91e47be

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

ebpf/Dockerfile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,21 @@ RUN CGO_ENABLED=1 go build -mod=readonly \
1717
-ldflags "-extldflags='-Wl,-z,lazy' -X 'github.com/coroot/coroot-node-agent/flags.Version=${NODE_AGENT_VERSION}-${CUSTOMIZATION_TAG}'" \
1818
-o /usr/bin/coroot-node-agent .
1919

20-
# Add Cluster Agent to the image
21-
FROM ghcr.io/coroot/coroot-cluster-agent:1.2.4 AS cluster-agent
20+
# Build Cluster Agent from source with patches
21+
FROM debian:bullseye AS cluster-agent-builder
22+
RUN apt-get update && apt-get install -y curl git
23+
ARG GO_VERSION=1.24.9
24+
RUN curl -fsSL https://go.dev/dl/go${GO_VERSION}.linux-$(dpkg --print-architecture).tar.gz -o go.tar.gz && \
25+
tar -C /usr/local -xzf go.tar.gz && rm go.tar.gz
26+
ENV PATH="/usr/local/go/bin:${PATH}"
27+
ARG CLUSTER_AGENT_VERSION=v1.6.1
28+
RUN git clone --depth 1 --branch ${CLUSTER_AGENT_VERSION} \
29+
https://github.com/coroot/coroot-cluster-agent.git /tmp/cluster-agent
30+
WORKDIR /tmp/cluster-agent
31+
COPY ebpf/patches/cluster-agent/*.patch ./
32+
RUN git apply *.patch
33+
RUN CGO_ENABLED=0 go build -mod=readonly \
34+
-o /usr/bin/coroot-cluster-agent .
2235

2336
# Add node exporter to the image
2437
FROM prom/node-exporter:v1.10.2 AS node-exporter-source
@@ -71,7 +84,7 @@ COPY --from=obi-source /tmp/LICENSE /tmp/NOTICE /usr/share/doc/ebpf-instrument/
7184
COPY --from=node-agent-builder --chmod=755 /usr/bin/coroot-node-agent /usr/local/bin/node-agent
7285

7386
# Copy Cluster Agent
74-
COPY --from=cluster-agent --chmod=755 /usr/bin/coroot-cluster-agent /usr/local/bin/cluster-agent
87+
COPY --from=cluster-agent-builder --chmod=755 /usr/bin/coroot-cluster-agent /usr/local/bin/cluster-agent
7588

7689
# Copy Node exporter
7790
COPY --from=node-exporter-source --chmod=755 /bin/node_exporter /usr/local/bin/node_exporter
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/metrics/target.go b/metrics/target.go
2+
--- a/metrics/target.go
3+
+++ b/metrics/target.go
4+
@@ -5,7 +5,6 @@
5+
"maps"
6+
"net"
7+
"net/url"
8+
- "strconv"
9+
"time"
10+
11+
"github.com/coroot/coroot-cluster-agent/config"
12+
@@ -101,7 +100,6 @@
13+
case TargetTypePostgres:
14+
userPass := url.UserPassword(credentials.Username, credentials.Password)
15+
query := url.Values{}
16+
query.Set("connect_timeout", "1")
17+
- query.Set("statement_timeout", strconv.Itoa(int(collectTimeout.Milliseconds())))
18+
sslmode := t.Params["sslmode"]
19+
if sslmode == "" {
20+
sslmode = "disable"

0 commit comments

Comments
 (0)