From e95e082e7d88c58186d8be0d5bae8941c3b8d11a Mon Sep 17 00:00:00 2001 From: Rodrigo Zhou Date: Fri, 3 Feb 2023 13:58:08 -0800 Subject: [PATCH] Fix namespace interceptor to allow search attributes operations (#3899) --- api/adminservice/v1/request_response.pb.go | 170 +++++++++--------- common/rpc/interceptor/namespace_validator.go | 14 ++ .../interceptor/namespace_validator_test.go | 87 +++++++++ .../adminservice/v1/request_response.proto | 4 +- 4 files changed, 188 insertions(+), 87 deletions(-) diff --git a/api/adminservice/v1/request_response.pb.go b/api/adminservice/v1/request_response.pb.go index 601caf254e2..2c71c5fbd94 100644 --- a/api/adminservice/v1/request_response.pb.go +++ b/api/adminservice/v1/request_response.pb.go @@ -1552,7 +1552,7 @@ var xxx_messageInfo_AddSearchAttributesResponse proto.InternalMessageInfo type RemoveSearchAttributesRequest struct { SearchAttributes []string `protobuf:"bytes,1,rep,name=search_attributes,json=searchAttributes,proto3" json:"search_attributes,omitempty"` IndexName string `protobuf:"bytes,2,opt,name=index_name,json=indexName,proto3" json:"index_name,omitempty"` - Namespace string `protobuf:"bytes,4,opt,name=namespace,proto3" json:"namespace,omitempty"` + Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` } func (m *RemoveSearchAttributesRequest) Reset() { *m = RemoveSearchAttributesRequest{} } @@ -1645,7 +1645,7 @@ var xxx_messageInfo_RemoveSearchAttributesResponse proto.InternalMessageInfo type GetSearchAttributesRequest struct { IndexName string `protobuf:"bytes,1,opt,name=index_name,json=indexName,proto3" json:"index_name,omitempty"` - Namespace string `protobuf:"bytes,4,opt,name=namespace,proto3" json:"namespace,omitempty"` + Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` } func (m *GetSearchAttributesRequest) Reset() { *m = GetSearchAttributesRequest{} } @@ -3243,7 +3243,7 @@ func init() { } var fileDescriptor_cc07c1a2abe7cb51 = []byte{ - // 2998 bytes of a gzipped FileDescriptorProto + // 3001 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x3a, 0x4d, 0x6c, 0x1b, 0xc7, 0xd5, 0x5e, 0xfe, 0x89, 0x7c, 0x92, 0x28, 0x69, 0x6d, 0x59, 0x34, 0x15, 0x51, 0x0a, 0xe3, 0x38, 0xb6, 0xbf, 0x84, 0xfa, 0xac, 0xb4, 0x8d, 0x93, 0xd4, 0x08, 0x64, 0xd9, 0x91, 0x95, 0x4a, 0xf9, @@ -3354,84 +3354,84 @@ var fileDescriptor_cc07c1a2abe7cb51 = []byte{ 0x5d, 0x98, 0x4f, 0x95, 0x2a, 0x9e, 0xc3, 0x4a, 0x22, 0x87, 0x5d, 0x89, 0xe7, 0xb0, 0xf2, 0xda, 0x33, 0x49, 0x8b, 0x44, 0x15, 0xd9, 0x16, 0x93, 0x13, 0xdb, 0xb7, 0x18, 0x2a, 0xaf, 0x33, 0x63, 0x39, 0x6b, 0x09, 0x16, 0x53, 0xd5, 0x23, 0x6d, 0xf3, 0x53, 0x0d, 0x96, 0x44, 0x49, 0x35, 0xcc, - 0x3c, 0xff, 0x37, 0xcc, 0x3a, 0xa5, 0xe3, 0xab, 0x71, 0xa4, 0x62, 0xea, 0x2b, 0x50, 0x1b, 0x26, - 0x8a, 0x94, 0xf6, 0x3b, 0x50, 0x65, 0xfd, 0xde, 0x10, 0x49, 0x93, 0x9b, 0x6b, 0xc7, 0xdb, 0xfc, - 0xe3, 0x02, 0x2c, 0xa6, 0xf2, 0x96, 0x59, 0xe1, 0x43, 0x0d, 0xe6, 0xac, 0x0e, 0xa1, 0x7e, 0x7b, - 0xd0, 0x4b, 0xc7, 0xbe, 0xf9, 0x86, 0x71, 0x6f, 0x6c, 0x70, 0xce, 0x03, 0x6e, 0x6a, 0xf5, 0x81, - 0xb9, 0x14, 0xe4, 0x80, 0x50, 0x9c, 0x90, 0x22, 0xf3, 0x88, 0xa4, 0xd8, 0xe5, 0x9c, 0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xb4, 0x80, 0xca, 0xf3, 0xe9, 0x2f, 0xb0, 0xec, 0xcc, 0x30, 0x98, 0x8e, 0x58, - 0x48, 0xc7, 0x46, 0x1b, 0x62, 0xe2, 0x39, 0x1f, 0xad, 0x5f, 0xf7, 0x62, 0x93, 0x8d, 0xd4, 0x39, - 0x65, 0x7e, 0xec, 0x39, 0x65, 0x21, 0x4d, 0x5f, 0xff, 0xd2, 0xe0, 0x74, 0xbf, 0xbe, 0xa4, 0x21, - 0x1f, 0x91, 0xc2, 0x52, 0x47, 0x09, 0x99, 0x47, 0x38, 0x4a, 0x48, 0x3b, 0x6b, 0x36, 0xed, 0xac, - 0x7f, 0xd3, 0x60, 0xe1, 0xcd, 0x4e, 0xd8, 0xc2, 0x5f, 0x45, 0xef, 0xa8, 0x57, 0xa1, 0x32, 0x78, - 0x38, 0x99, 0x48, 0x7f, 0x9f, 0x81, 0x85, 0x1d, 0xfc, 0x15, 0x3d, 0xf9, 0x63, 0x89, 0x8b, 0xab, - 0x50, 0x19, 0x54, 0xd8, 0xf1, 0x06, 0xf5, 0xac, 0xd8, 0x58, 0x34, 0xf0, 0x5e, 0x88, 0xc9, 0xbe, - 0x6a, 0xb5, 0x12, 0x6f, 0xa7, 0xfd, 0x93, 0xae, 0xec, 0xe3, 0x7b, 0x87, 0x91, 0xe3, 0xa9, 0x1a, - 0x3c, 0x91, 0x2e, 0x50, 0xcf, 0x4f, 0x96, 0x0c, 0x4c, 0xb0, 0x67, 0xf7, 0x45, 0xdd, 0x50, 0x99, - 0x1f, 0xe1, 0x63, 0xe3, 0xd3, 0x50, 0x4e, 0xd6, 0x2c, 0xb2, 0x15, 0x98, 0x0e, 0xe3, 0xc5, 0x41, - 0xca, 0x8b, 0x52, 0x3e, 0xe5, 0x45, 0xe9, 0x29, 0x98, 0x16, 0x58, 0xc9, 0xb7, 0x1f, 0x81, 0x34, - 0xec, 0x19, 0x69, 0x62, 0xe0, 0x19, 0x69, 0x19, 0x26, 0x19, 0x86, 0x62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2, + 0xa0, 0x76, 0xe2, 0xd3, 0x07, 0xb5, 0x13, 0xef, 0x7c, 0xa3, 0xe5, 0xf7, 0x84, 0x75, 0xfc, 0x11, + 0x7f, 0x4d, 0x7d, 0x39, 0xfe, 0xdd, 0x2c, 0xf0, 0xfa, 0xf4, 0xf9, 0xff, 0x04, 0x00, 0x00, 0xff, + 0xff, 0x83, 0x7d, 0xbf, 0xba, 0xd5, 0x2a, 0x00, 0x00, } func (this *RebuildMutableStateRequest) Equal(that interface{}) bool { @@ -7132,7 +7132,7 @@ func (m *RemoveSearchAttributesRequest) MarshalToSizedBuffer(dAtA []byte) (int, copy(dAtA[i:], m.Namespace) i = encodeVarintRequestResponse(dAtA, i, uint64(len(m.Namespace))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if len(m.IndexName) > 0 { i -= len(m.IndexName) @@ -7201,7 +7201,7 @@ func (m *GetSearchAttributesRequest) MarshalToSizedBuffer(dAtA []byte) (int, err copy(dAtA[i:], m.Namespace) i = encodeVarintRequestResponse(dAtA, i, uint64(len(m.Namespace))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x12 } if len(m.IndexName) > 0 { i -= len(m.IndexName) @@ -13887,7 +13887,7 @@ func (m *RemoveSearchAttributesRequest) Unmarshal(dAtA []byte) error { } m.IndexName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) } @@ -14057,7 +14057,7 @@ func (m *GetSearchAttributesRequest) Unmarshal(dAtA []byte) error { } m.IndexName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) } diff --git a/common/rpc/interceptor/namespace_validator.go b/common/rpc/interceptor/namespace_validator.go index dd30af1b70f..7f69fd8cb08 100644 --- a/common/rpc/interceptor/namespace_validator.go +++ b/common/rpc/interceptor/namespace_validator.go @@ -28,10 +28,12 @@ import ( "context" enumspb "go.temporal.io/api/enums/v1" + "go.temporal.io/api/operatorservice/v1" "go.temporal.io/api/serviceerror" "go.temporal.io/api/workflowservice/v1" "google.golang.org/grpc" + "go.temporal.io/server/api/adminservice/v1" "go.temporal.io/server/common" "go.temporal.io/server/common/dynamicconfig" "go.temporal.io/server/common/namespace" @@ -178,6 +180,18 @@ func (ni *NamespaceValidatorInterceptor) extractNamespaceFromRequest(req interfa return nil, errNamespaceNotSet } return nil, nil + case *adminservice.AddSearchAttributesRequest, + *adminservice.RemoveSearchAttributesRequest, + *adminservice.GetSearchAttributesRequest, + *operatorservice.AddSearchAttributesRequest, + *operatorservice.RemoveSearchAttributesRequest, + *operatorservice.ListSearchAttributesRequest: + // Namespace is optional for search attributes operations. + // It's required when using SQL DB for visibility, but not when using Elasticsearch. + if !namespaceName.IsEmpty() { + return ni.namespaceRegistry.GetNamespace(namespaceName) + } + return nil, nil default: // All other APIs. if namespaceName.IsEmpty() { diff --git a/common/rpc/interceptor/namespace_validator_test.go b/common/rpc/interceptor/namespace_validator_test.go index 6e976076702..820aac1c733 100644 --- a/common/rpc/interceptor/namespace_validator_test.go +++ b/common/rpc/interceptor/namespace_validator_test.go @@ -33,10 +33,12 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" enumspb "go.temporal.io/api/enums/v1" + "go.temporal.io/api/operatorservice/v1" "go.temporal.io/api/serviceerror" "go.temporal.io/api/workflowservice/v1" "google.golang.org/grpc" + "go.temporal.io/server/api/adminservice/v1" persistencespb "go.temporal.io/server/api/persistence/v1" tokenspb "go.temporal.io/server/api/token/v1" "go.temporal.io/server/common" @@ -597,6 +599,91 @@ func (s *namespaceValidatorSuite) Test_StateValidationIntercept_TokenNamespaceEn } } +func (s *namespaceValidatorSuite) Test_Intercept_SearchAttributeRequests() { + // it's just a list of requests + testCases := []struct { + req any + hasNamespace bool + }{ + { + req: &adminservice.AddSearchAttributesRequest{}, + hasNamespace: false, + }, + { + req: &adminservice.RemoveSearchAttributesRequest{}, + hasNamespace: false, + }, + { + req: &adminservice.GetSearchAttributesRequest{}, + hasNamespace: false, + }, + { + req: &operatorservice.AddSearchAttributesRequest{}, + hasNamespace: false, + }, + { + req: &operatorservice.RemoveSearchAttributesRequest{}, + hasNamespace: false, + }, + { + req: &operatorservice.ListSearchAttributesRequest{}, + hasNamespace: false, + }, + { + req: &adminservice.AddSearchAttributesRequest{Namespace: "test-namespace"}, + hasNamespace: true, + }, + { + req: &adminservice.RemoveSearchAttributesRequest{Namespace: "test-namespace"}, + hasNamespace: true, + }, + { + req: &adminservice.GetSearchAttributesRequest{Namespace: "test-namespace"}, + hasNamespace: true, + }, + { + req: &operatorservice.AddSearchAttributesRequest{Namespace: "test-namespace"}, + hasNamespace: true, + }, + { + req: &operatorservice.RemoveSearchAttributesRequest{Namespace: "test-namespace"}, + hasNamespace: true, + }, + { + req: &operatorservice.ListSearchAttributesRequest{Namespace: "test-namespace"}, + hasNamespace: true, + }, + } + + for _, testCase := range testCases { + if testCase.hasNamespace { + s.mockRegistry.EXPECT().GetNamespace(namespace.Name("test-namespace")).Return(nil, nil) + } + + nvi := NewNamespaceValidatorInterceptor( + s.mockRegistry, + dynamicconfig.GetBoolPropertyFn(false), + dynamicconfig.GetIntPropertyFn(100), + ) + serverInfo := &grpc.UnaryServerInfo{ + FullMethod: "/temporal/random", + } + + handlerCalled := false + _, err := nvi.StateValidationIntercept( + context.Background(), + testCase.req, + serverInfo, + func(ctx context.Context, req any) (any, error) { + handlerCalled = true + return nil, nil + }, + ) + s.NoError(err) + s.True(handlerCalled) + } +} + func (s *namespaceValidatorSuite) Test_LengthValidationIntercept() { nvi := NewNamespaceValidatorInterceptor( s.mockRegistry, diff --git a/proto/internal/temporal/server/api/adminservice/v1/request_response.proto b/proto/internal/temporal/server/api/adminservice/v1/request_response.proto index dd987dbd570..a8467750ca7 100644 --- a/proto/internal/temporal/server/api/adminservice/v1/request_response.proto +++ b/proto/internal/temporal/server/api/adminservice/v1/request_response.proto @@ -209,7 +209,7 @@ message AddSearchAttributesResponse { message RemoveSearchAttributesRequest { repeated string search_attributes = 1; string index_name = 2; - string namespace = 4; + string namespace = 3; } message RemoveSearchAttributesResponse { @@ -217,7 +217,7 @@ message RemoveSearchAttributesResponse { message GetSearchAttributesRequest { string index_name = 1; - string namespace = 4; + string namespace = 2; } message GetSearchAttributesResponse {