fix(collector): honor clustering.tls for leader→member API calls#892
Open
vuthinh0301 wants to merge 1 commit into
Open
fix(collector): honor clustering.tls for leader→member API calls#892vuthinh0301 wants to merge 1 commit into
vuthinh0301 wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
In collector mode the cluster leader dispatched targets to members using plain http.Client instances that never loaded the clustering.tls config (cluster_manager.go carried a `// TODO:` on the client). As a result a TLS-secured API (private-CA server cert, or mTLS via api-server.tls.client-auth=require-verify) broke target assignment with `x509: certificate signed by unknown authority` / `tls: bad certificate`, even for the leader calling itself. The clustering.tls config was already parsed and env-expanded (pkg/config/clustering.go, pkg/collector/env/env.go) but never consumed under pkg/collector/. Build the inter-member HTTP client from clustering.tls, mirroring (*App).createAPIClient in subscribe mode (pkg/app/clustering.go), and inject it into both the ClusterManager apiClient and the assigner. When clustering.tls is unset the behavior matches subscribe mode (skip-verify fallback), so plain-HTTP and public-CA setups are unaffected.
vuthinh0301
force-pushed
the
fix/collector-clustering-tls
branch
from
July 15, 2026 13:13
16c4542 to
a8e1165
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR title
fix(collector): honor clustering.tls for leader→member API calls
PR body
Problem
In collector mode (
gnmic collect), the cluster leader's HTTP clients that call other members' REST APIs (target assignment / unassignment / deletion) were plain&http.Client{}instances that never loaded theclustering.tlsconfiguration — the client inpkg/collector/managers/cluster/cluster_manager.goeven carried a literal// TODO:.As a result, a TLS-secured API broke target dispatch:
api-server.tls→x509: certificate signed by unknown authorityapi-server.tls.client-auth: require-verify) → the dispatch client presents no client cert, so the leader getsremote error: tls: bad certificatecalling members, including itself → no target ever assigned, no telemetry.This works in subscribe mode, where
clustering.tlswas wired up in #544 (v0.39.0, for #529). Collector mode (v0.43.0) has a separate cluster implementation that never got the same treatment. The config was already parsed and env-expanded (pkg/config/clustering.go,pkg/collector/env/env.go:18-21) but never consumed anywhere underpkg/collector/.Fix
Add
newClusteringHTTPClient(*config.Clustering)which builds the client fromclustering.tlsviautils.NewTLSConfig(...), mirroring(*App).createAPIClientinpkg/app/clustering.go. Inject it into both theClusterManager.apiClient(replacing the// TODO:client) and the assigner (NewAssignernow takes the client).When
clustering.tlsis unset the behavior matches subscribe mode (skip-verify fallback), so plain-HTTP and public-CA setups are unaffected.Testing
go build ./...— OK (go 1.25)go vet ./pkg/collector/managers/cluster/...— cleango test ./pkg/collector/managers/cluster/... ./pkg/app/...— passgnmic collectcluster + Consul + Nokia SR Linux target: before the fix, enablingapi-server.tlswith a private CA (mTLS) produced thex509/bad certificateerrors above and no target was assigned; after the fix, with matchingclustering.tls, the leader dispatches over HTTPS+mTLS, the lock is acquired, and telemetry flows. Subscribe mode with the same config already worked and still does.Files
pkg/collector/managers/cluster/cluster_manager.gopkg/collector/managers/cluster/assigner.gopkg/collector/managers/cluster/cluster_integration_test.go