Skip to content

feat: per-workspace PyT routing + cold-start handling - #6978

Merged
mihir20 merged 13 commits into
masterfrom
mihir/pipe-3009-pipe-3010
May 22, 2026
Merged

mihir20 merged 13 commits into
masterfrom
mihir/pipe-3009-pipe-3010

Conversation

@mihir20

@mihir20 mihir20 commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Summary

Adds support for routing the Python branch of user-transformations to a workspace-scoped PyT service (pyt-<workspaceID>:9090) instead of the static PYTHON_TRANSFORM_URL, plus the cold-start
observability and retry behavior the HPA scale-from-zero flow needs. JS, mirror, and existing Python paths are identical when the new flag is off.

Behavior

  • URL resolution. New flag Processor.UserTransformer.perWorkspacePyTEnabled (default false). When on, non-mirror Python transformations route to a per-workspace URL templated from
    Processor.UserTransformer.perWorkspacePyTURLTemplate (default http://pyt-{workspaceID}:9090). Falls back to the global Python URL when the version-allowlist gates the version out, when mirroring,
    or when workspaceID is empty.
  • Cold-start counter. New processor_user_transformer_cold_start_errors_total{workspaceID, language} increments per HTTP attempt classified as cold-start (ECONNREFUSED, DNS not-found, 502, 503)
    only on the per-workspace Python non-mirror path. Tag language is hard-coded to "python" to keep cardinality bounded. HPA reads rate(...[1m]) against activationThreshold: 0.01 to decide 0→1
    scaling.
  • Cold-start retry. On cold-start detection the inner closure short-circuits with a sentinel ColdStartError. The doPost tail converts that sentinel to a dedicated status code
    StatusColdStartWindowFailure = 819. sendBatch's outer retry treats 819 like StatusCPDown — keeps retrying the whole call so the request eventually lands once HPA scales the pod up. Gated by
    Processor.UserTransformer.perWorkspacePyTEndlessRetries (default true); when disabled, backoff.Permanent bails immediately so the batch surfaces a single FailedEvent with status 819 instead of
    panicking the processor.

Behavior when the flag is off

Identical to current master. New config fields default off / endless-retries-on, but the gating predicate means none
of the new code paths are reachable until we explicitly enable the flag.

Linear Ticket

pipe-3009, pipe-3010

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 3 commits May 19, 2026 13:04
🔒 Scanned for secrets using gitleaks 8.28.0
…art error handling

🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
@codecov

codecov Bot commented May 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.01%. Comparing base (d788760) to head (49e8bf6).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6978      +/-   ##
==========================================
+ Coverage   79.66%   80.01%   +0.35%     
==========================================
  Files         565      565              
  Lines       63712    63798      +86     
==========================================
+ Hits        50757    51051     +294     
+ Misses       9942     9712     -230     
- Partials     3013     3035      +22     

☔ View full report in Codecov by Sentry.
📢 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.

@ktgowtham
ktgowtham requested review from fracasula and itsmihir May 19, 2026 11:03
@mihir20
mihir20 requested a review from itsmihir May 20, 2026 07:59
…ration

🔒 Scanned for secrets using gitleaks 8.28.0
if isPython && u.config.pythonTransformConfig.IsVersionAllowed(versionID) && u.config.pythonTransformationURL != "" {
return u.config.pythonTransformationURL + "/customTransform"
if isPython && u.config.pythonTransformConfig.IsVersionAllowed(versionID) {
if u.config.perWorkspacePyTEnabled && !u.config.forMirroring && workspaceID != "" {

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.

Shouldn't we complain if perWorkspacePyTEnabled is true but the workspaceID is empty?


func (u *Client) userTransformURL(language, versionID string) string {
func (u *Client) shouldThrowPythonColdStartErr(labels types.TransformerMetricLabels, err error, resp *http.Response) bool {
return u.config.perWorkspacePyTEnabled &&

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.

We are not checking IsVersionAllowed here. We shoud centralize these checks and think about removing IsVersionAllowed now that is not needed anymore.

@mihir20 mihir20 May 22, 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.

We do not need to check IsVersionAllowed here as this will be for all the pyt. can pick up removal of IsVersionAllowed separately;

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.

Yes, please create a task for 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.

retryOptions = append(retryOptions, backoff.WithMaxTries(uint(u.config.maxRetry.Load()+1)))
}
_ = backoffvoid.Retry(
context.Background(),

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.

Endless cold-start retry ignores the caller ctx. This can outlive Transform / drain. Graceful shutdown / drain semantics break for the new default, we should plumb the outer ctx into backoffvoid.Retry.

@mihir20 mihir20 May 22, 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.

As the processor code currently is, we cannot use caller context; else, we might end up dropping the current jobs. We will have to refactor the processor code for this. will create a separate task for this as well.

timeoutDuration time.Duration
collectInstanceLevelStats bool
batchSize config.ValueLoader[int]
perWorkspacePyTEnabled bool

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.

Any reason why this isn't reloadable but the endless retries is?

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.

making reloadable

handle.config.pythonTransformationURL = handle.conf.GetStringVar("", "PYTHON_TRANSFORM_URL")
handle.config.perWorkspacePyTEnabled = handle.conf.GetBoolVar(false, "Processor.UserTransformer.perWorkspacePyTEnabled")
handle.config.perWorkspacePyTURLTemplate = handle.conf.GetStringVar("http://pyt-{workspaceID}:9090", "Processor.UserTransformer.perWorkspacePyTURLTemplate")
handle.config.perWorkspacePyTEndlessRetries = handle.conf.GetReloadableBoolVar(true, "Processor.UserTransformer.perWorkspacePyTEndlessRetries")

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.

perWorkspacePyTEndlessRetries=false doesn't seem to be covered by tests

}, nil
}

func TestColdStartCounter(t *testing.T) {

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.

We don't verify that the counter stays 0 when each guard is
individually false, even with a cold-start-looking transport error.
Every TestColdStartCounter case has perWorkspacePyTEnabled=true, language=pythonfaas, workspaceID="ws-A1", forMirroring=false. None of the four guard negatives is asserted: flag off, mirroring on, JS
language, empty workspaceID.

mihir20 added 5 commits May 22, 2026 13:12
…ition

🔒 Scanned for secrets using gitleaks 8.28.0
…ty workspaceID

🔒 Scanned for secrets using gitleaks 8.28.0
…rror logic

🔒 Scanned for secrets using gitleaks 8.28.0
…iguration

🔒 Scanned for secrets using gitleaks 8.28.0
…for cold-start predicates

🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20
mihir20 requested a review from fracasula May 22, 2026 12:33

@fracasula fracasula left a comment

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.

@mihir20 I'm approving this to unblock you so that you can proceed with the release on Monday but I think this is incomplete.

We have an existing feature (mirroring) and a new one introduced here (python transformations for multi-tenant setups). With your implementation the two features simply won't work together given that you're explicitly skipping when !forMirroring.

Mirroring is here to stay though and we should retain the ability to mirror also for multi-tenant setups.

A couple considerations about this:

  • mirroring will be needed to test different python transformation versions to check sanity diffs (for example v1.14.0 was never put live but it's handling the metadata the same as the JS transformer. eventually we'll want to do the same here but before enabling we'll need mirroring to evaluate customer impact)
  • mirroring should be as close as possible to the production setup. so if we're using one set of pods to transformer per workspace, the same should be done for mirroring.

cc @ktgowtham

// HPA, EndpointSlice lag, kube-proxy 5xx). Surface a dedicated status
// code so sendBatch retries the whole call until the pod is up instead of treating it as a failed transformation.
if errors.Is(err, transformerutils.ErrColdStart) {
return fmt.Appendf(nil, "workspace transformer not reachable: %s", err), transformerutils.StatusColdStartWindowFailure, nil

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 the error surface to the user in any way? 🤔
If yes we could remove it from here and just log it, to avoid potentially leaking internal DNSs, IPs and other information.

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.

this will not go to the user; it will be just logged and retried

}

func (u *Client) userTransformURL(language, versionID, workspaceID string) string {
if !strings.HasPrefix(language, "python") {

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.

There are 3 occurrences already of strings.HasPrefix(language, "python"). Sounds like we need a function.

…adability

🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20
mihir20 enabled auto-merge (squash) May 22, 2026 13:49
@mihir20
mihir20 merged commit d81e175 into master May 22, 2026
71 checks passed
@mihir20
mihir20 deleted the mihir/pipe-3009-pipe-3010 branch May 22, 2026 14:22
This was referenced May 25, 2026
mihir20 pushed a commit that referenced this pull request May 25, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.76.0-rc.1](v1.75.0...v1.76.0-rc.1)
(2026-05-25)


### Features

* per-workspace PyT routing + cold-start handling
([#6978](#6978))
([d81e175](d81e175))
* periodic cleanup of rsources shared db tables
([#6945](#6945))
([ed0dfe7](ed0dfe7))


### Bug Fixes

* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([af31e62](af31e62))
* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([193f797](193f797))
* clickhouse quarter partition type
([#6965](#6965))
([af31e62](af31e62))
* continuous backend config cache cause postgres disk bloat
([#6983](#6983))
([f45aa06](f45aa06))
* ignore failed messages when source job run id exists
([#6981](#6981))
([045fdc0](045fdc0))
* server getting stuck during startup while initializing rsources
([#6943](#6943))
([62791fa](62791fa))
* snowpipe streaming bulk status offset
([#6966](#6966))
([af31e62](af31e62))


### Miscellaneous

* **ci:** workflow cleanup (SEC-284)
([#6949](#6949))
([516ba5b](516ba5b))
* **deps:** bump actions/upload-artifact from 7.0.0 to 7.0.1
([#6892](#6892))
([866f04d](866f04d))
* **deps:** bump aws-actions/amazon-ecr-login from 2.0.1 to 2.1.4
([#6956](#6956))
([89f1168](89f1168))
* **deps:** bump docker/login-action from 4.0.0 to 4.1.0
([#6881](#6881))
([5bca875](5bca875))
* **deps:** bump rudderlabs/build-scan-push-action from 1.8.2 to 2.2.0
([#6955](#6955))
([78cc895](78cc895))
* **deps:** bump step-security/harden-runner from 2.16.0 to 2.19.1
([#6957](#6957))
([cc5b578](cc5b578))
* **jobsdb:** disable no results cache state filter optimization
([#6964](#6964))
([c20dad2](c20dad2))
* **jobsdb:** release dsList read lock early during store
([#6963](#6963))
([a172404](a172404))
* pyt contracts for ipc and multi threading
([#6942](#6942))
([d570865](d570865))
* remove unused sed deletion method from GZIPLocalFileHandler
([#6974](#6974))
([d788760](d788760))
* replace deprecated WithCredentialsJSON with WithAuthCredentialsJSON
([#6986](#6986))
([8395174](8395174))
* sync release v1.75.0 to main branch
([#6954](#6954))
([f16fe93](f16fe93))

---
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>
mihir20 pushed a commit that referenced this pull request May 26, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.76.0](v1.75.0...v1.76.0)
(2026-05-25)


### Features

* per-workspace PyT routing + cold-start handling
([#6978](#6978))
([d81e175](d81e175))
* periodic cleanup of rsources shared db tables
([#6945](#6945))
([ed0dfe7](ed0dfe7))


### Bug Fixes

* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([af31e62](af31e62))
* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([193f797](193f797))
* clickhouse quarter partition type
([#6965](#6965))
([af31e62](af31e62))
* continuous backend config cache cause postgres disk bloat
([#6983](#6983))
([f45aa06](f45aa06))
* ignore failed messages when source job run id exists
([#6981](#6981))
([045fdc0](045fdc0))
* server getting stuck during startup while initializing rsources
([#6943](#6943))
([62791fa](62791fa))
* snowpipe streaming bulk status offset
([#6966](#6966))
([af31e62](af31e62))


### Miscellaneous

* **ci:** workflow cleanup (SEC-284)
([#6949](#6949))
([516ba5b](516ba5b))
* **deps:** bump actions/upload-artifact from 7.0.0 to 7.0.1
([#6892](#6892))
([866f04d](866f04d))
* **deps:** bump aws-actions/amazon-ecr-login from 2.0.1 to 2.1.4
([#6956](#6956))
([89f1168](89f1168))
* **deps:** bump docker/login-action from 4.0.0 to 4.1.0
([#6881](#6881))
([5bca875](5bca875))
* **deps:** bump rudderlabs/build-scan-push-action from 1.8.2 to 2.2.0
([#6955](#6955))
([78cc895](78cc895))
* **deps:** bump step-security/harden-runner from 2.16.0 to 2.19.1
([#6957](#6957))
([cc5b578](cc5b578))
* **jobsdb:** disable no results cache state filter optimization
([#6964](#6964))
([c20dad2](c20dad2))
* **jobsdb:** release dsList read lock early during store
([#6963](#6963))
([a172404](a172404))
* pyt contracts for ipc and multi threading
([#6942](#6942))
([d570865](d570865))
* remove unused sed deletion method from GZIPLocalFileHandler
([#6974](#6974))
([d788760](d788760))
* replace deprecated WithCredentialsJSON with WithAuthCredentialsJSON
([#6986](#6986))
([8395174](8395174))
* sync release v1.75.0 to main branch
([#6954](#6954))
([f16fe93](f16fe93))

---
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