feat: Add custom search attributes support to TemporalNamespace#984
Open
ido-trumer wants to merge 6 commits intoalexandrevilain:mainfrom
Open
feat: Add custom search attributes support to TemporalNamespace#984ido-trumer wants to merge 6 commits intoalexandrevilain:mainfrom
ido-trumer wants to merge 6 commits intoalexandrevilain:mainfrom
Conversation
Adds the ability to configure custom search attributes on TemporalNamespace resources, enabling workflow search by custom attributes. Attributes are reconciled via the Temporal OperatorService API during namespace reconciliation. Closes alexandrevilain#567
Reduce cognitive complexity of ReconcileSearchAttributes by extracting helper functions. Replace duplicated test namespace literal with constant and fix gofmt/unparam lint issues.
Log key lifecycle events: existing attribute count, when attributes are up to date, additions with count, and removals with count and names.
Only log at INFO when actually adding or removing attributes. Listing and up-to-date checks are debug (V(1)) to reduce noise.
Match namespace.go's import style (unaliased enums instead of enumsv1). Replace init() with a static map literal for the reverse type mapping.
Remove TestSearchAttributeTypeFromString, TestSearchAttributeTypeToString (just mirror the map data), and error propagation tests (just verify fmt.Errorf wrapping). Keep tests that exercise actual reconciliation logic.
|
Author
|
@alexandrevilain Thank you for triggering the CI, looks like everything works. Let me know if you have any comments or other thoughts :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #567
Supersedes #776
Summary
Adds the ability to declare custom search attributes on
TemporalNamespaceresources. Attributes are reconciled against the Temporal server via the OperatorService API during each namespace reconciliation cycle.New spec fields
customSearchAttributes— map of attribute name → type. Supported types:Text,Keyword,Int,Double,Bool,DateTime,KeywordList.allowSearchAttributeDeletion— safety flag. Whenfalse(default), attributes removed from the spec are left on the server. Whentrue, stale attributes are deleted.Reconciliation behavior
allowSearchAttributeDeletion: trueFiles changed
api/v1beta1/temporalnamespace_types.go— two new fields onTemporalNamespaceSpecapi/v1beta1/zz_generated.deepcopy.go— generatedconfig/crd/bases/temporal.io_temporalnamespaces.yaml— generated CRDcontrollers/temporalnamespace_controller.go— +15 lines to callReconcileSearchAttributesafter namespace register/updatepkg/temporal/search_attributes.go— core reconciliation logic withOperatorServiceClientinterface for testabilitypkg/temporal/search_attributes_test.go— 11 unit test casesDifference from #776
This is a fresh implementation, not a continuation of #776. Key differences:
pkg/temporal)allowSearchAttributeDeletion)OperatorServiceClient)Note on test location
Unit tests are co-located at
pkg/temporal/search_attributes_test.go. While the other files inpkg/temporal/(e.g.,namespace.go,client.go) don't have co-located unit tests, this file uses a mockOperatorServiceClientinterface and doesn't require a live cluster, so it doesn't fit intests/e2e/. The co-located pattern is consistent with other packages in the repo (pkg/version/,pkg/kubernetes/,internal/resource/persistence/). Happy to move it if you prefer a different location.Test plan
go test ./pkg/temporal/...— 11 search attribute test cases)go vetcleangolangci-lintclean (v1.64.8, matching CI)make check-license)go build ./...)ListSearchAttributesAPI and Temporal UIallowSearchAttributeDeletion: true→ 2 remainallowSearchAttributeDeletion: false→ preserved on server