Repository navigation
feat: per-workspace PyT routing + cold-start handling - #6978
Conversation
🔒 Scanned for secrets using gitleaks 8.28.0
…art error handling 🔒 Scanned for secrets using gitleaks 8.28.0
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
🔒 Scanned for secrets using gitleaks 8.28.0
…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 != "" { |
There was a problem hiding this comment.
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 && |
There was a problem hiding this comment.
We are not checking IsVersionAllowed here. We shoud centralize these checks and think about removing IsVersionAllowed now that is not needed anymore.
There was a problem hiding this comment.
We do not need to check IsVersionAllowed here as this will be for all the pyt. can pick up removal of IsVersionAllowed separately;
There was a problem hiding this comment.
Yes, please create a task for this 🙏
There was a problem hiding this comment.
| retryOptions = append(retryOptions, backoff.WithMaxTries(uint(u.config.maxRetry.Load()+1))) | ||
| } | ||
| _ = backoffvoid.Retry( | ||
| context.Background(), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Any reason why this isn't reloadable but the endless retries is?
| 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") |
There was a problem hiding this comment.
perWorkspacePyTEndlessRetries=false doesn't seem to be covered by tests
| }, nil | ||
| } | ||
|
|
||
| func TestColdStartCounter(t *testing.T) { |
There was a problem hiding this comment.
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.
…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
fracasula
left a comment
There was a problem hiding this comment.
@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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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
🤖 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>
🤖 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>
Description
Summary
Adds support for routing the Python branch of user-transformations to a workspace-scoped PyT service (
pyt-<workspaceID>:9090) instead of the staticPYTHON_TRANSFORM_URL, plus the cold-startobservability 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
Processor.UserTransformer.perWorkspacePyTEnabled(defaultfalse). When on, non-mirror Python transformations route to a per-workspace URL templated fromProcessor.UserTransformer.perWorkspacePyTURLTemplate(defaulthttp://pyt-{workspaceID}:9090). Falls back to the global Python URL when the version-allowlist gates the version out, when mirroring,or when
workspaceIDis empty.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
languageis hard-coded to"python"to keep cardinality bounded. HPA readsrate(...[1m])againstactivationThreshold: 0.01to decide 0→1scaling.
ColdStartError. ThedoPosttail converts that sentinel to a dedicated status codeStatusColdStartWindowFailure = 819.sendBatch's outer retry treats819likeStatusCPDown— keeps retrying the whole call so the request eventually lands once HPA scales the pod up. Gated byProcessor.UserTransformer.perWorkspacePyTEndlessRetries(defaulttrue); when disabled,backoff.Permanentbails immediately so the batch surfaces a single FailedEvent with status 819 instead ofpanicking 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 noneof the new code paths are reachable until we explicitly enable the flag.
Linear Ticket
pipe-3009, pipe-3010
Security