Skip to content

Conversation

@pglass
Copy link
Contributor

@pglass pglass commented Jun 19, 2025

What was changed

Implement search attribute translation for multiple namespaces.

Why?

Checklist

  1. Closes

  2. How was this tested:

Similar to steps in #93, but:

  • Create 2 replicated namespaces

  • In proxy-a, add namespace translation (optional)

    namespaceNameTranslation:
      mappings:
        - localName: "myns"
          remoteName: "myns.cloud"
        - localName: "myns2"
          remoteName: "myns2.cloud"
  • In proxy-b configure the search attributes. To discover the search attribute mapping, ~/code/cli/temporal --address localhost:8233 operator namespace describe -n $NS --grpc-meta xdc-redirection=false -o json

    searchAttributeTranslation:
      namespaceMappings:
      - name: "myns.cloud"
        namespaceId: "d3054098-3edb-4242-93e1-dbc15f097cb5"
        mappings:
        - localFieldName: "Keyword06"
          remoteFieldName: "CustomKeywordField"
        - localFieldName: "Text01"
          remoteFieldName: "CustomStringField"
    
      - name: "myns2.cloud"
        namespaceId: "f935a879-2b28-4ea8-9e64-c25f020962fe"
        mappings:
        - localFieldName: "Keyword03"
          remoteFieldName: "CustomKeywordField"
        - localFieldName: "Text01"
          remoteFieldName: "CustomStringField"
    
      - name: "bogus"
        namespaceId: "00001111-0000-1111-0000-111100001111"
        mappings:
        - localFieldName: "Keyword99"
          remoteFieldName: "CustomKeywordField"
        - localFieldName: "Text99"
          remoteFieldName: "CustomStringField"
  • Start workers for both namespaces

  • Run workflows in both namespaces simultaneously

  • Run force replication in both namespaces

  • Test handover

  • Check that queries with search attributes work on the target cluster, and return same results as source

NS=myns
temporal workflow count -n $NS -q 'CustomKeywordField IS NOT NULL' --grpc-meta xdc-redirection=false
temporal --address localhost:8233 workflow count -n myns2.cloud -q 'CustomKeywordField IS NOT NULL' --grpc-meta xdc-redirection=false
  1. Any docs updates needed?

@pglass pglass requested a review from a team as a code owner June 19, 2025 01:53
type visitor func(obj any, match stringMatcher) (bool, error)
// currentNamespaceId is internal-state to remember the namespace id set in some parent
// field as the visitor descends recursively into child fields.
currentNamespaceId string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switch to a Visitor struct so that we can track currentNamespaceId as we recursively descend into struct.

Comment on lines +151 to +153
nsId := discoverNamespaceId(vwp)
if nsId != "" {
v.currentNamespaceId = nsId
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check for and remember namespace id on each type as we descend.

v := MakeSearchAttributeVisitor(s.getNamespaceRespMatcher)
switch val := req.(type) {
case *adminservice.GetWorkflowExecutionRawHistoryV2Request:
v.currentNamespaceId = val.NamespaceId
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Special handling for GetWorkflowExecutionRawHistoryV2Response. Carry over the namespace id found in the corresponding request.

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.

2 participants