Skip to content

Commit

Permalink
Remove search attributes errors logs (#1886)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin committed Sep 2, 2021
1 parent 42bf6ef commit 24a081a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 26 deletions.
15 changes: 0 additions & 15 deletions common/searchattribute/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ import (
"go.temporal.io/api/serviceerror"

"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/payload"
)

type (
// Validator is used to validate search attributes
Validator struct {
logger log.Logger

searchAttributesProvider Provider
searchAttributesNumberOfKeysLimit dynamicconfig.IntPropertyFnWithNamespaceFilter
searchAttributesSizeOfValueLimit dynamicconfig.IntPropertyFnWithNamespaceFilter
Expand All @@ -55,30 +51,19 @@ var (

// NewValidator create Validator
func NewValidator(
logger log.Logger,
searchAttributesProvider Provider,
searchAttributesNumberOfKeysLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
searchAttributesSizeOfValueLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
searchAttributesTotalSizeLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
) *Validator {
return &Validator{
logger: logger,
searchAttributesProvider: searchAttributesProvider,
searchAttributesNumberOfKeysLimit: searchAttributesNumberOfKeysLimit,
searchAttributesSizeOfValueLimit: searchAttributesSizeOfValueLimit,
searchAttributesTotalSizeLimit: searchAttributesTotalSizeLimit,
}
}

// ValidateAndLog validate search attributes are valid for writing and not exceed limits
func (v *Validator) ValidateAndLog(searchAttributes *commonpb.SearchAttributes, namespace string, indexName string) error {
err := v.Validate(searchAttributes, namespace, indexName)
if err != nil {
v.logger.Warn("Search attributes are invalid.", tag.Error(err), tag.WorkflowNamespace(namespace), tag.ESIndex(indexName))
}
return err
}

// Validate validate search attributes are valid for writing.
func (v *Validator) Validate(searchAttributes *commonpb.SearchAttributes, namespace string, indexName string) error {
if searchAttributes == nil {
Expand Down
5 changes: 2 additions & 3 deletions common/searchattribute/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
commonpb "go.temporal.io/api/common/v1"

"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/payload"
)

Expand All @@ -49,7 +48,7 @@ func (s *searchAttributesValidatorSuite) TestSearchAttributesValidate() {
sizeOfValueLimit := 5
sizeOfTotalLimit := 20

saValidator := NewValidator(log.NewNoopLogger(),
saValidator := NewValidator(
NewTestProvider(),
dynamicconfig.GetIntPropertyFilteredByNamespace(numOfKeysLimit),
dynamicconfig.GetIntPropertyFilteredByNamespace(sizeOfValueLimit),
Expand Down Expand Up @@ -122,7 +121,7 @@ func (s *searchAttributesValidatorSuite) TestSearchAttributesValidateSize() {
sizeOfValueLimit := 5
sizeOfTotalLimit := 20

saValidator := NewValidator(log.NewNoopLogger(),
saValidator := NewValidator(
NewTestProvider(),
dynamicconfig.GetIntPropertyFilteredByNamespace(numOfKeysLimit),
dynamicconfig.GetIntPropertyFilteredByNamespace(sizeOfValueLimit),
Expand Down
6 changes: 3 additions & 3 deletions service/history/commandChecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func (v *commandAttrValidator) validateUpsertWorkflowSearchAttributes(
return serviceerror.NewInvalidArgument("IndexedFields is empty on command.")
}

return v.searchAttributesValidator.ValidateAndLog(attributes.GetSearchAttributes(), namespace, visibilityIndexName)
return v.searchAttributesValidator.Validate(attributes.GetSearchAttributes(), namespace, visibilityIndexName)
}

func (v *commandAttrValidator) validateContinueAsNewWorkflowExecutionAttributes(
Expand Down Expand Up @@ -574,7 +574,7 @@ func (v *commandAttrValidator) validateContinueAsNewWorkflowExecutionAttributes(
attributes.WorkflowTaskTimeout = timestamp.DurationPtr(timestamp.DurationValue(executionInfo.DefaultWorkflowTaskTimeout))
}

return v.searchAttributesValidator.ValidateAndLog(attributes.GetSearchAttributes(), namespace, visibilityIndexName)
return v.searchAttributesValidator.Validate(attributes.GetSearchAttributes(), namespace, visibilityIndexName)
}

func (v *commandAttrValidator) validateStartChildExecutionAttributes(
Expand Down Expand Up @@ -638,7 +638,7 @@ func (v *commandAttrValidator) validateStartChildExecutionAttributes(
return err
}

if err := v.searchAttributesValidator.ValidateAndLog(attributes.GetSearchAttributes(), targetNamespace, visibilityIndexName); err != nil {
if err := v.searchAttributesValidator.Validate(attributes.GetSearchAttributes(), targetNamespace, visibilityIndexName); err != nil {
return err
}

Expand Down
2 changes: 0 additions & 2 deletions service/history/commandChecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"go.temporal.io/server/common/cache"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/payloads"
"go.temporal.io/server/common/primitives/timestamp"
"go.temporal.io/server/common/searchattribute"
Expand Down Expand Up @@ -97,7 +96,6 @@ func (s *commandAttrValidatorSuite) SetupTest() {
s.mockNamespaceCache,
config,
searchattribute.NewValidator(
log.NewNoopLogger(),
searchattribute.NewTestProvider(),
config.SearchAttributesNumberOfKeysLimit,
config.SearchAttributesSizeOfValueLimit,
Expand Down
3 changes: 0 additions & 3 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func NewEngineWithShardContext(
)

historyEngImpl.searchAttributesValidator = searchattribute.NewValidator(
logger,
shard.GetService().GetSearchAttributesProvider(),
config.SearchAttributesNumberOfKeysLimit,
config.SearchAttributesSizeOfValueLimit,
Expand Down Expand Up @@ -2613,11 +2612,9 @@ func (e *historyEngineImpl) validateStartWorkflowExecutionRequest(
return err
}
if err := e.searchAttributesValidator.Validate(request.SearchAttributes, namespace, e.config.DefaultVisibilityIndexName); err != nil {
e.logger.Warn("Search attributes are invalid.", tag.Error(err), tag.WorkflowNamespace(namespace))
return err
}
if err := e.searchAttributesValidator.ValidateSize(request.SearchAttributes, namespace); err != nil {
e.logger.Warn("Search attributes are invalid.", tag.Error(err), tag.WorkflowNamespace(namespace))
return err
}

Expand Down

0 comments on commit 24a081a

Please sign in to comment.