Skip to content

feat: add control-plane connection management for processor - #7126

Merged
mihir20 merged 8 commits into
masterfrom
mihir/pipe-3143
Jul 3, 2026
Merged

mihir20 merged 8 commits into
masterfrom
mihir/pipe-3143

Conversation

@mihir20

@mihir20 mihir20 commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Opens the processor's dataplane-initiated gRPC connection to cp-router, reusing the shared controlplane.ConnectionManager (the same mechanism rudder-sources and warehouse use). This makes the processor reachable from cp-router so that, test-flow requests can be forwarded to the per-workspace rudder-pytransformer.

Only the node-0 pod opens the connection, so cp-router holds a single inbound connection per dataplane (not one per replica) and node-0 becomes the sole owner of any privileged work served over it.
The whole bootstrap is gated behind a config flag and defaults off — this PR is inert until enabled.

The Forward RPC itself is intentionally left unimplemented in this PR (a follow-up PR adds op-routing + the HTTP forward to pyt). Until then cp-router receives codes.Unimplemented.

What's in here

  • proto/processor/processor.proto (+ generated .pb.go / _grpc.pb.go): a generic ProcessorService with a single RPC — Forward(op, workspace_id, payload) → (status_code, body). The op is an
    opaque string and payload/body are JSON bytes, so cp-router stays transformation-agnostic and never grows per-op code. Generated with the repo's pinned plugin versions (protoc-gen-go v1.33.0,
    protoc-gen-go-grpc v1.3.0).
  • processor/cpservice/cpservice.go — Service, the ProcessorService gRPC handler. Embeds UnimplementedProcessorServiceServer so it registers and serves safely while Forward is pending.
  • processor/cpservice/connection.go — Connector, which wraps controlplane.ConnectionManager, registers the handler on the dataplane-side gRPC server, and drives the connection from the workspace
    connection flags published by the control plane (the warehouse pattern). ShouldConnect = feature-enabled && node-0.
  • app/apphandlers/{processor,embedded}AppHandler.go — gated bootstrap wired into both modes that run the processor pipeline. GATEWAY mode is intentionally excluded (no processor pipeline; the LLD
    keeps this off the horizontally-scaled gateway).

Node-0 detection

Reuses misc.GetInstanceID() — the same instance-ID ordinal signal app/cluster/state uses. It returns the trailing ordinal of INSTANCE_ID ("0", "1", …); an unset INSTANCE_ID yields "", so local runs never connect.

Config

Key Default Purpose
Processor.cpRouterConnection.enabled false Master switch for opening the cp-router connection
Processor.cpRouterConnection.retryInterval 0 (→ 1s) Reconnect backoff for the connection manager
CP_ROUTER_USE_TLS (reused) true TLS for the cp-router dial
INSTANCE_ID (reused) — Node-0 detection + AuthInfo.InstanceID

Linear Ticket

pipe-3143

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

mihir20 added 2 commits June 25, 2026 12:22
… replica management

🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20
mihir20 requested review from fracasula and ktgowtham June 26, 2026 12:58
@codecov

codecov Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.73%. Comparing base (84fc747) to head (cd73448).

Files with missing lines Patch % Lines
app/apphandlers/embeddedAppHandler.go 0.00% 6 Missing and 1 partial ⚠️
app/apphandlers/processorAppHandler.go 0.00% 7 Missing ⚠️
processor/cpservice/connection.go 91.83% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7126      +/-   ##
==========================================
- Coverage   80.00%   79.73%   -0.27%     
==========================================
  Files         587      589       +2     
  Lines       65615    65680      +65     
==========================================
- Hits        52498    52373     -125     
- Misses      10026    10243     +217     
+ Partials     3091     3064      -27     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

// multi-workspace deployment, so the first one carrying the flag is enough.
func (c *Connector) apply(configData map[string]backendconfig.ConfigT) {
for _, wConfig := range configData {
flags := wConfig.ConnectionFlags

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if CP is setting these flags today. for MT type deployments(which is the case for all our deployments), connections are made

for warehouse MT type deployments, this flag is set.

// always set connection flags to true for hosted and multi-tenant warehouse service

can we double check?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might have to add processor too here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CP router is setting this flag whenever the CP router's HTTP API is called from the config backend.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that might be needed for open source data planes. but for transformation testing, we can proactively initiate a connection like we do for warehouse if it's a namespace deployment. So the ask is to add rudderstack-processor too, like warehouse is explicitly added

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for the warehouse we are doing this so that connections can be initiated whenever the warehouse master is restarted. CP router also closes the unused connections after some TTL. I don't think our flow is this much critical to initiate connection on every processor restart.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, shouldn't be hard to add a metric for wait time for a connection

@mihir20 mihir20 Jul 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fracasula good point, will add the metrics in the grpc server which we will be implementing in the next pr.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All I asked is to just add rudderstack-processor to the flags, like how warehouse is done :D

Mihir, aren't we going to add this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed pushing the changes. I thought I already pushed 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done now

@mihir20
mihir20 requested a review from ktgowtham June 30, 2026 09:01
Comment thread processor/cpservice/connection.go Outdated
AuthInfo: controlplane.AuthInfo{
Service: ServiceName,
ConnectionToken: connectionToken,
InstanceID: conf.GetStringVar("1", "INSTANCE_ID"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we supposed to connect from node-0 only? I'm asking because I saw that isNode0 does this:

func isNode0() bool {
	return misc.GetInstanceID() == "0"
}

So "0" != "1".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will only be connecting from node 0. InstanceId is set for all the processor pods via operator; we will not be picking the default value. But I got your point will use misc.InstanceID() here.

if !ok {
return nil
}
if configData, ok := data.Data.(map[string]backendconfig.ConfigT); ok {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be !ok? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be will remove the check

// Run subscribes to backend config and keeps the cp-router connection in sync
// with the workspace connection flags until ctx is cancelled, at which point it
// closes the connection. It blocks, so run it in the app errgroup.
func (c *Connector) Run(ctx context.Context) error {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests cover ShouldConnect, service registration, and an end-to-end Forward. But the actual subscribe→decode→apply→stop loop in Run, including the data.Data.(map[string]backendconfig.ConfigT) type assertion all the way till close-on-shutdown, has no direct coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added more tests

}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("INSTANCE_ID", tc.instanceID)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we able to use the config just below this line for this? In connection.go you're doing:

InstanceID:      conf.GetStringVar("1", "INSTANCE_ID"),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no in misc.GetInstanceID() we are using global config

…ction

🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20
mihir20 requested a review from fracasula July 1, 2026 10:22
mihir20 added 4 commits July 1, 2026 19:21
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
Base automatically changed from mihir/pipe-3145 to master July 3, 2026 07:03
🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20
mihir20 marked this pull request as ready for review July 3, 2026 07:05
@mihir20
mihir20 merged commit ea6ca00 into master Jul 3, 2026
75 checks passed
@mihir20
mihir20 deleted the mihir/pipe-3143 branch July 3, 2026 07:58
This was referenced Jul 6, 2026
itsmihir pushed a commit that referenced this pull request Jul 6, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.80.0-rc.1](v1.79.0...v1.80.0-rc.1)
(2026-07-06)


### Features

* add control-plane connection management for processor
([#7126](#7126))
([ea6ca00](ea6ca00))
* carry integration version on DestinationT to the transformer
([#7125](#7125))
([421c613](421c613))
* implement Forward RPC for control-plane requests to workspace pyt
transformers
([#7143](#7143))
([8a704cf](8a704cf))
* implement Kubernetes deployment scaler for workspace replica
management
([#7123](#7123))
([84fc747](84fc747))
* monthly active records (MAR) metering pipeline
([#7119](#7119))
([d1df486](d1df486))


### Bug Fixes

* **router:** transformer returning response with empty metadata array
causes server to panic
([#7144](#7144))
([d6a4dbc](d6a4dbc))


### Miscellaneous

* enable compression for google pubsub
([#7137](#7137))
([11c9ab8](11c9ab8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
itsmihir pushed a commit that referenced this pull request Jul 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.80.0](v1.79.0...v1.80.0)
(2026-07-06)


### Features

* add control-plane connection management for processor
([#7126](#7126))
([ea6ca00](ea6ca00))
* carry integration version on DestinationT to the transformer
([#7125](#7125))
([421c613](421c613))
* implement Forward RPC for control-plane requests to workspace pyt
transformers
([#7143](#7143))
([8a704cf](8a704cf))
* implement Kubernetes deployment scaler for workspace replica
management
([#7123](#7123))
([84fc747](84fc747))
* monthly active records (MAR) metering pipeline
([#7119](#7119))
([d1df486](d1df486))


### Bug Fixes

* **router:** transformer returning response with empty metadata array
causes server to panic
([#7144](#7144))
([d6a4dbc](d6a4dbc))


### Miscellaneous

* enable compression for google pubsub
([#7137](#7137))
([11c9ab8](11c9ab8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
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.

3 participants