Skip to content

Commit 63d68a2

Browse files
authored
feat(frontend): support autoforwarding through headers (#7681)
<!-- 1-2 line summary of WHAT changed technically: - Always link the relevant projects GitHub issue, unless it is a minor bugfix - Good: "Modified FailoverDomain mapper to allow null ActiveClusterName #320" - Bad: "added nil check" --> **What changed?** add client feature flag support on server to enable autoforwarding ref #7707 For ordering, Payload > Header > default Eventual consistency level * IDL update to support serialization in proto * modified cluster redirection wrapper to honor consistency level from feature flags <!-- Your goal is to provide all the required context for a future maintainer to understand the reasons for making this change (see https://cbea.ms/git-commit/#why-not-how). How did this work previously (and what was wrong with it)? What has changed, and why did you solve it this way? - Good: "Active-active domains have independent cluster attributes per region. Previously, modifying cluster attributes required spedifying the default ActiveClusterName which updates the global domain default. This prevents operators from updating regional configurations without affecting the primary cluster designation. This change allows attribute updates to be independent of active cluster selection." - Bad: "Improves domain handling" --> **Why?** Allows client workers to poll and process tasks from all regions. This is particularly useful when a test infra started a test container that's trying to process tasks during the test. Before: you'll need to ensure the test container is started in region that's connected to domain's active cluster Now: all test containers can be auto forwarded to active cluster if they provide the `client-feature-flag` header with auto forwarding enabled <!-- Include specific test commands and setup. Please include the exact commands such that another maintainer or contributor can reproduce the test steps taken. - e.g Unit test commands with exact invocation `go test -v ./common/types/mapper/proto -run TestFailoverDomainRequest` - For integration tests include setup steps and test commands Example: "Started local server with `./cadence start`, then ran `make test_e2e`" - For local simulation testing include setup steps for the server and how you ran the tests - Good: Full commands that reviewers can copy-paste to verify - Bad: "Tested locally" or "Added tests" --> **How did you test it?** Unit Test (WIP) Testing xdc clusters with cadence-samples to do xdc processing <!-- If there are risks that the release engineer should know about document them here. For example: - Has an API/IDL been modified? Is it backwards/forwards compatible? If not, what are the repecussions? - Has a schema change been introduced? Is it possible to roll back? - Has a feature flag been re-used for a new purpose? - Is there a potential performance concern? Is the change modifying core task processing logic? - If truly N/A, you can mark it as such --> **Potential risks** The header is passed by clients. If they pass it wrong, inactive workers will start processing workflows unexpectedly. <!-- If this PR completes a user facing feature or changes functionality add release notes here. Your release notes should allow a user and the release engineer to understand the changes with little context. Always ensure that the description contains a link to the relevant GitHub issue. --> **Release notes** added new field in structured `client-feature-flag` header to allow users to set autoforwarding <!-- Consider whether this change requires documentation updates in the Cadence-Docs repo - If yes: mention what needs updating (or link to docs PR in cadence-docs repo) - If in doubt, add a note about potential doc needs - Only mark N/A if you're certain no docs are affected --> **Documentation Changes** N/A --- ## Reviewer Validation **PR Description Quality** (check these before reviewing code): - [ ] **"What changed"** provides a clear 1-2 line summary - [ ] Project Issue is linked - [ ] **"Why"** explains the full motivation with sufficient context - [ ] **Testing is documented:** - [ ] Unit test commands are included (with exact `go test` invocation) - [ ] Integration test setup/commands included (if integration tests were run) - [ ] Canary testing details included (if canary was mentioned) - [ ] **Potential risks** section is thoughtfully filled out (or legitimately N/A) - [ ] **Release notes** included if this completes a user-facing feature - [ ] **Documentation** needs are addressed (or noted if uncertain) --------- Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
1 parent d52ae40 commit 63d68a2

File tree

4 files changed

+135
-37
lines changed

4 files changed

+135
-37
lines changed

service/frontend/templates/clusterredirection.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (handler *clusterRedirectionHandler) {{$method.Declaration}} {
7070
var (
7171
apiName = "{{$method.Name}}"
7272
cluster string
73-
requestedConsistencyLevel types.QueryConsistencyLevel = types.QueryConsistencyLevelEventual
73+
requestedConsistencyLevel types.QueryConsistencyLevel = getRequestedConsistencyLevelFromContext(ctx)
7474
)
7575

7676
{{- if has $method.Name $readAPIsWithStrongConsistency}}

service/frontend/wrappers/clusterredirection/api_generated.go

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package clusterredirection
2+
3+
import (
4+
"context"
5+
6+
"go.uber.org/yarpc"
7+
8+
"github.com/uber/cadence/common/client"
9+
"github.com/uber/cadence/common/types"
10+
)
11+
12+
func getRequestedConsistencyLevelFromContext(ctx context.Context) types.QueryConsistencyLevel {
13+
call := yarpc.CallFromContext(ctx)
14+
if call == nil {
15+
return types.QueryConsistencyLevelEventual
16+
}
17+
featureFlags := client.GetFeatureFlagsFromHeader(call)
18+
if featureFlags.AutoforwardingEnabled {
19+
return types.QueryConsistencyLevelStrong
20+
}
21+
return types.QueryConsistencyLevelEventual
22+
}

0 commit comments

Comments
 (0)