Sitelet https://github.com/prometheus/prometheus/pull/19501
Skip to content

discovery/rds: skip DB clusters whose ARN is unset - #19501

Open
r0h1tb wants to merge 1 commit into
prometheus:mainfrom
r0h1tb:fix/rds-nil-cluster-arn
Open

discovery/rds: skip DB clusters whose ARN is unset#19501
r0h1tb wants to merge 1 commit into
prometheus:mainfrom
r0h1tb:fix/rds-nil-cluster-arn

Conversation

@r0h1tb

@r0h1tb r0h1tb commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Fixes a panic in the RDS service discovery refresh; no tracking issue, found by code reading in the same class as #19324/#19396.

Problem

refresh() dereferences *cluster.DBClusterArn to look up the cluster's instances (rds.go:540 on main). DBClusterArn is optional in the DescribeDBClusters response — the SDK marks no member of DBCluster as required — so a cluster response missing it panics the refresh goroutine and takes the whole process down.

The explicit-cluster path (clusters: config) reaches this most easily: describeDBClusters stores whatever the API returns keyed by the configured ARN without checking the ARN came back. describeAllDBClusters already skips ARN-less clusters (rds.go:421), which is why the all-clusters path never trips this.

Fix

Skip the cluster with a warning, mirroring the existing describeAllDBClusters behaviour and the "Skipping invalid ElastiCache ARN" precedent in elasticache.go.

Tests

TestRDSRefreshSkipsClusterWithoutArn drives the real refresh() — the existing table test rebuilds the target list inline and never calls it, which is how this survived review. Against unfixed code:

panic: runtime error: invalid memory address or nil pointer dereference
\tdiscovery/aws/rds.go:540 +0x294

With the fix the ARN-less cluster is skipped, the healthy cluster in the same config still produces its target, and the package suite is green (ok github.com/prometheus/prometheus/discovery/aws, matching main).

[BUGFIX] Discovery: RDS SD no longer panics when a described DB cluster has no ARN.

DBClusterArn is optional in the DescribeDBClusters response. The
explicit-cluster path (config: clusters) stores the returned cluster
keyed by the configured ARN without checking the ARN came back, so a
cluster response missing it panicked the refresh goroutine at the
describeDBInstances call.

Skip the cluster like describeAllDBClusters already does for the same
field, and say so in the log.

Signed-off-by: Rohit Behera <126186063+r0h1tb@users.noreply.github.com>
@r0h1tb
r0h1tb requested review from a team, matt-gp and sysadmind as code owners August 21, 2026 21:58
@matt-gp

matt-gp commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

In what situation would you have a cluster without an ARN???

Or is this just to be more defensive, in which case I'm all for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants