Skip to content

Commit

Permalink
Add missing retention days check on update namespace API (#1407)
Browse files Browse the repository at this point in the history
* Add missing check on upper limit of retention days to UpdateNamespaceAPI
  • Loading branch information
wxing1292 committed Mar 26, 2021
1 parent 9fcf5e4 commit 5ab080a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 5 additions & 1 deletion common/namespace/attrValidator.go
Expand Up @@ -32,7 +32,9 @@ import (
"go.temporal.io/api/serviceerror"

persistencespb "go.temporal.io/server/api/persistence/v1"
"go.temporal.io/server/common"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/primitives/timestamp"
)

type (
Expand All @@ -56,7 +58,9 @@ func newAttrValidator(
}

func (d *AttrValidatorImpl) validateNamespaceConfig(config *persistencespb.NamespaceConfig) error {
if config.Retention != nil && *config.Retention < time.Hour*24*time.Duration(d.minRetentionDays) {
if timestamp.DurationValue(config.Retention) < time.Hour*24*time.Duration(d.minRetentionDays) {
return errInvalidRetentionPeriod
} else if timestamp.DurationValue(config.Retention) > common.MaxWorkflowRetentionPeriod {
return errInvalidRetentionPeriod
}
if config.HistoryArchivalState == enumspb.ARCHIVAL_STATE_ENABLED && len(config.HistoryArchivalUri) == 0 {
Expand Down
1 change: 0 additions & 1 deletion service/frontend/errors.go
Expand Up @@ -43,7 +43,6 @@ var (
errRequestNotSet = serviceerror.NewInvalidArgument("Request is nil.")
errRequestIDNotSet = serviceerror.NewInvalidArgument("RequestId is not set on request.")
errWorkflowTypeNotSet = serviceerror.NewInvalidArgument("WorkflowType is not set on request.")
errInvalidRetention = serviceerror.NewInvalidArgument("RetentionDays is invalid.")
errInvalidWorkflowExecutionTimeoutSeconds = serviceerror.NewInvalidArgument("An invalid WorkflowExecutionTimeoutSeconds is set on request.")
errInvalidWorkflowRunTimeoutSeconds = serviceerror.NewInvalidArgument("An invalid WorkflowRunTimeoutSeconds is set on request.")
errInvalidWorkflowTaskTimeoutSeconds = serviceerror.NewInvalidArgument("An invalid WorkflowTaskTimeoutSeconds is set on request.")
Expand Down
4 changes: 0 additions & 4 deletions service/frontend/workflowHandler.go
Expand Up @@ -222,10 +222,6 @@ func (wh *WorkflowHandler) RegisterNamespace(ctx context.Context, request *workf
return nil, errRequestNotSet
}

if timestamp.DurationValue(request.GetWorkflowExecutionRetentionPeriod()) > common.MaxWorkflowRetentionPeriod {
return nil, errInvalidRetention
}

if request.GetNamespace() == "" {
return nil, errNamespaceNotSet
}
Expand Down

0 comments on commit 5ab080a

Please sign in to comment.