feat(platform-connectors): one handler and connector set for both roles, on-change node updates and keyed inserts #1845
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1845"
general
weight: 0.35
KaivalyaMDabhadkar
Summary
Part of ADR 052, the deployment platform connector. #1796 added the client library and #1814 the datastore side. This PR prepares the platform-connectors binary for its second role without adding it yet: the request handler and the connectors become one code path that both roles can use, and the connectors and pipeline stages are sized and hardened for a fleet. The deployment role itself (
PC_MODE=deployment, thepkg/centralpackage) comes in the next PR, which builds only on what is here. The wire contract is unchanged: the samePlatformConnectorgRPC service, the same protobuf.Most of this is internal, but a few changes are visible on the DaemonSet that runs today. They are listed under "What the DaemonSet sees differently" so they can be judged on their own.
What changes
pkg/connectors):Connector.ProcessBatchreceives one batch.Sethands a batch to several connectors at the same time and fails with the first error, which cancels the others.BestEffortwraps a connector whose failure or timeout must not fail the batch; it is logged and counted inplatform_connector_best_effort_failures_total. A ring buffer implements the interface by queueing the batch and answering at once, so the DaemonSet's handler hands each batch to aSetof its ring buffers, as before in effect.pkg/server): validate the batch, run the pipeline, hand it to the connector, answer with its result. Outcomes are counted inplatform_connector_request_duration_seconds{outcome}. The handler joins the trace context a caller sends in the request metadata, and stamps an event withoutgeneratedTimestampwith the arrival time (the analyzer cannot process an event without one). The payload log level is a field, so the deployment role can log at Debug.pkg/pipeline):ProcessBatchruns a whole batch, with an optional batch budget under which transformers that implementPrewarmprepare for the batch first (the metadata augmentor reads every node the batch names concurrently) and report what the budget cut short, so the caller can defer the batch before anything is marked. What the preparation read is kept in a per-batch scope, so the transformers use it even if the shared cache dropped it. Without a budget, the DaemonSet's case, the events are processed as they are. The pipeline construction fromconfig.jsonmoves into the package.InsertBatchwrites one batch inside the caller's request and reportsstoredorduplicate;VerifyIdempotencyIndexchecks the idempotency index of #1814 with its full definition. Both roles now insert with the idempotent insert: the deployment stamps keys per caller before the pipeline runs (next PR), the DaemonSet's store loop keys each queued batch itself on its first attempt and keeps the key across requeues. A duplicate on another unique index is answered with a terminal status; an empty batch is a success without a datastore call.ProcessBatchlets the deployment role call it inside a request.NodeEventMemorySizesizes the memory for a fleet.maxEntries, default 100000) and indexed per node and check, so a recovery visits only its own bucket, and it keys on the idempotency key so a resend of the same batch is never mistaken for a repeat of another.lookupTimeout(3 s) and detached from the caller,Prewarmfor batches, fleet-sized client rate limit and cache throughpipeline.Options, and a node label named like the reserved idempotency key field is ignored.ProcessBatch, so the deployment role can call them per batch.go.modgainsgo-grpc-middleware/v2(indirect, through the client library) and makeslogra direct requirement.What the DaemonSet sees differently
Deliberate, each small, none changes the wire contract.
k8s_platform_connector_node_condition_update_total{status="skipped"}), and a repeat of a non-fatal fault whose Event was written less than 10 minutes ago costs no Event write. A same-fault repeat with other diagnostic text does not rewrite the message; a recovery makes the fault's next occurrence a change again. The condition's heartbeat time therefore moves only with a change (nothing in the repository reads it), and Event counts grow at most every 10 minutes instead of on every poll. On a fleet this is the largest steady-state API server load the connector produces.metadata.idempotencyKey(instanceID#sequence#index), a batch retried after a partial write stores only the missing documents instead of the first ones twice,platform_connector_store_batches_totalexists on its pods, and on PostgreSQL the insert is one row at a time. A key that arrives in an event (a derived event copied from a stored document) is overwritten instead of stored.<node>.<16 hex>of node, check, reason and message) instead of the write time, so a connector that lost its memory finds the Event it or an earlier life of the same pod wrote, and refreshes it instead of writing a second one. A batch is processed in timestamp order on both the condition and the Event path.node_nameonk8s_platform_connector_node_event_operations_totalandnodeon the dedup counter, because one deployment replica would carry a series per node of the fleet.generatedTimestampis stamped with the arrival time; an empty batch is a success without a datastore call; trace context sent in the request metadata joins the trace instead of starting a new one; the per-event "Metadata augmented" line is at Debug.What is not in this PR
The deployment role itself (
pkg/central: configuration, TLS listener, token validation, the idempotency-key and readiness interceptors, the no-local-node branch ofpkg/auth) is the next PR. The Helm chart, the monitors' switch to publishing directly, the Tilt environment and e2e tests, and the operator documentation come after it. Reviewing this PR does not require them.Tests
Unit tests, all passing, lint clean,
go mod tidyclean:pkg/connectors/connector_test.go: every member gets the batch, members run at the same time, the first error cancels the rest, a best-effort member's failure or timeout is counted and does not fail the batch, the caller's cancellation reaches the members.pkg/server/platform_connector_server_test.go: acknowledged only when the connector accepts; a connector failure is not acknowledged; rejection happens before any side effect; a cancelled caller is reported as such; the caller's trace is joined; a retry after a failed write keeps the processing strategy; one budget covers the whole batch and a spent metadata budget defers it; queues acknowledge at once and hold the batch; a status the connector chose is passed through; defaults and timestamp stamping.pkg/connectors/kubernetes(envtest): a repeat costs no status write, also when the message is saturated and compacted; a new fault joining or a partial recovery is a change; Events are written on change and refreshed after the interval; Event names are derived from the fault; a connector without memory refreshes the existing Event; the Event memory is bounded; an update racing a deletion recreates the Event.pkg/connectors/store: a duplicate-only replay is success, a partial replay stores the missing events, an empty batch is terminal success, a duplicate on another index stays an error and is answered with a terminal status; the ring buffer loop keys the stored copies and keeps the key across requeues; a batch keyed by the caller keeps its keys.pkg/transformers/dedupandpkg/transformers/metadata: key-aware and bounded dedup with an index that stays in step; one read per node under concurrent batches, a slow node does not block others, a spent budget starts no reads and is reported, what the preparation read outlives the shared cache for the batch.pkg/pipeline,pkg/ringbuffer,pkg/connectors/prom: batch processing with and without a budget, the batch scope, queueing with the caller's trace, counting without a ring buffer.Manual testing on kind with the DaemonSet role (every publisher on the socket), on Mongo and on PostgreSQL with certificate auth:
With the deployment role PR applied on top, the same code ran the deployment scenarios (contract, fan-out, dedup, Event names across replicas, rolling restarts, Mongo outages under keyed traffic, the deployment e2e tests) on kind, and an earlier version on four dev clusters.
Type of Change
Component(s) Affected
Testing
Checklist
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
- Added configurable limits for deduplication memory, Kubernetes metadata caching, lookup timeouts, and client request capacity.
- Added support for loading connector pipelines directly from raw configuration.
- Added batch processing across connectors, Prometheus, storage, and gRPC sinks.
- Prevented duplicate Kubernetes Events and unchanged condition updates from creating unnecessary writes.
- Preserved batch identity across retries and handled duplicate datastore submissions safely.
- Connector processing now waits for all connectors and reports every failure.
- Expanded metrics documentation for connector outcomes, skipped operations, and datastore batches.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->