Skip to content

Commit

Permalink
Revert "Finish migration of infinite workflow timeout (#1030)"
Browse files Browse the repository at this point in the history
This reverts commit f67c31b.
  • Loading branch information
wxing1292 committed Dec 10, 2020
1 parent 650beab commit fde5b78
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 1 deletion.
4 changes: 4 additions & 0 deletions common/service/dynamicconfig/constants.go
Expand Up @@ -75,6 +75,7 @@ var keys = map[Key]string{
EnableStickyQuery: "system.enableStickyQuery",
EnablePriorityTaskProcessor: "system.enablePriorityTaskProcessor",
EnableAuthorization: "system.enableAuthorization",
EnableInfiniteTimeout: "system.enableInfiniteTimeout",

// size limit
BlobSizeLimitError: "limit.blobSize.error",
Expand Down Expand Up @@ -337,6 +338,9 @@ const (
EnablePriorityTaskProcessor
// EnableAuthorization is the key to enable authorization for a namespace
EnableAuthorization
// EnableInfiniteTimeout is the key to enable infinite timeout
// TODO remove after 1.5
EnableInfiniteTimeout
// BlobSizeLimitError is the per event blob size limit
BlobSizeLimitError
// BlobSizeLimitWarn is the per event blob size limit for warning
Expand Down
95 changes: 95 additions & 0 deletions common/todo_deprecate.go
@@ -0,0 +1,95 @@
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package common

import (
"time"

"go.temporal.io/server/common/primitives/timestamp"
"go.temporal.io/server/common/service/dynamicconfig"
)

// TODO remove everything below:
// TODO remove after 1.5
// DefaultWorkflowExecutionTimeout
// DefaultWorkflowRunTimeout
// GetWorkflowExecutionTimeout
// GetWorkflowRunTimeout
// GetWorkflowTaskTimeout
const (
// DefaultWorkflowExecutionTimeout is the Default Workflow Execution timeout applied to a Workflow when
// this value is not explicitly set by the user on a Start Workflow request
// Intention is 10 years
DefaultWorkflowExecutionTimeout = 24 * 365 * 10 * time.Hour

// DefaultWorkflowRunTimeout is the Default Workflow Run timeout applied to a Workflow when
// this value is not explicitly set by the user on a Start Workflow request
// Intention is 10 years
DefaultWorkflowRunTimeout = 24 * 365 * 10 * time.Hour
)

// GetWorkflowExecutionTimeout gets the default allowed execution timeout or truncates the requested value to the maximum allowed timeout
func GetWorkflowExecutionTimeout(
requestedTimeout time.Duration,
) time.Duration {
if requestedTimeout == 0 {
requestedTimeout = DefaultWorkflowExecutionTimeout
}
return timestamp.MinDuration(
requestedTimeout,
DefaultWorkflowExecutionTimeout,
)
}

// GetWorkflowRunTimeout gets the default allowed run timeout or truncates the requested value to the maximum allowed timeout
func GetWorkflowRunTimeout(
requestedTimeout time.Duration,
executionTimeout time.Duration,
) time.Duration {
if requestedTimeout == 0 {
requestedTimeout = DefaultWorkflowRunTimeout
}

return timestamp.MinDuration(
timestamp.MinDuration(
requestedTimeout,
executionTimeout,
),
DefaultWorkflowRunTimeout,
)
}

// GetWorkflowTaskTimeout gets the default allowed execution timeout or truncates the requested value to the maximum allowed timeout
func GetWorkflowTaskTimeout(
namespace string,
requestedTimeout time.Duration,
runTimeout time.Duration,
getDefaultTimeoutFunc dynamicconfig.DurationPropertyFnWithNamespaceFilter,
) time.Duration {
if requestedTimeout == 0 {
requestedTimeout = getDefaultTimeoutFunc(namespace)
}
return timestamp.MinDuration(requestedTimeout, runTimeout)
}
2 changes: 1 addition & 1 deletion host/integration_test.go
Expand Up @@ -2240,7 +2240,7 @@ func (s *integrationSuite) TestChildWorkflowExecution() {
s.Equal(header, childStartedEvent.GetWorkflowExecutionStartedEventAttributes().Header)
s.Equal(memo, childStartedEvent.GetWorkflowExecutionStartedEventAttributes().GetMemo())
s.Equal(searchAttr, childStartedEvent.GetWorkflowExecutionStartedEventAttributes().GetSearchAttributes())
s.Equal(time.Duration(0), timestamp.DurationValue(childStartedEvent.GetWorkflowExecutionStartedEventAttributes().GetWorkflowExecutionTimeout()))
s.Equal(315360000*time.Second, timestamp.DurationValue(childStartedEvent.GetWorkflowExecutionStartedEventAttributes().GetWorkflowExecutionTimeout()))
s.Equal(200*time.Second, timestamp.DurationValue(childStartedEvent.GetWorkflowExecutionStartedEventAttributes().GetWorkflowRunTimeout()))

// Process ChildExecution completed event and complete parent execution
Expand Down
7 changes: 7 additions & 0 deletions service/frontend/service.go
Expand Up @@ -113,6 +113,10 @@ type Config struct {

// EnableServerVersionCheck disables periodic version checking performed by the frontend
EnableServerVersionCheck dynamicconfig.BoolPropertyFn

// EnableInfiniteTimeout enable infinite workflow timeout
// TODO remove after 1.5
EnableInfiniteTimeout dynamicconfig.BoolPropertyFn
}

// NewConfig returns new service config with default values
Expand Down Expand Up @@ -154,6 +158,9 @@ func NewConfig(dc *dynamicconfig.Collection, numHistoryShards int32, enableReadF
DefaultWorkflowRetryPolicy: dc.GetMapPropertyFnWithNamespaceFilter(dynamicconfig.DefaultWorkflowRetryPolicy, common.GetDefaultRetryPolicyConfigOptions()),
DefaultWorkflowTaskTimeout: dc.GetDurationPropertyFilteredByNamespace(dynamicconfig.DefaultWorkflowTaskTimeout, common.DefaultWorkflowTaskTimeout),
EnableServerVersionCheck: dc.GetBoolProperty(dynamicconfig.EnableServerVersionCheck, os.Getenv("TEMPORAL_VERSION_CHECK_DISABLED") == ""),

// TODO remove after 1.5
EnableInfiniteTimeout: dc.GetBoolProperty(dynamicconfig.EnableInfiniteTimeout, false),
}
}

Expand Down
59 changes: 59 additions & 0 deletions service/frontend/workflowHandler.go
Expand Up @@ -3764,6 +3764,35 @@ func (wh *WorkflowHandler) validateStartWorkflowTimeouts(
return wh.error(errInvalidWorkflowTaskTimeoutSeconds, scope)
}

// TODO remove this if block after 1.5
if !wh.config.EnableInfiniteTimeout() {
// TODO remove the 3 functions below
// BEGIN
request.WorkflowExecutionTimeout = timestamp.DurationPtr(
common.GetWorkflowExecutionTimeout(
timestamp.DurationValue(request.GetWorkflowExecutionTimeout()),
),
)

request.WorkflowRunTimeout = timestamp.DurationPtr(
common.GetWorkflowRunTimeout(
timestamp.DurationValue(request.GetWorkflowRunTimeout()),
timestamp.DurationValue(request.GetWorkflowExecutionTimeout()),
),
)

request.WorkflowTaskTimeout = timestamp.DurationPtr(
common.GetWorkflowTaskTimeout(
request.GetNamespace(),
timestamp.DurationValue(request.GetWorkflowTaskTimeout()),
timestamp.DurationValue(request.GetWorkflowRunTimeout()),
wh.config.DefaultWorkflowTaskTimeout,
),
)
// TODO remove the 3 functions above
// END
}

return nil
}

Expand All @@ -3783,5 +3812,35 @@ func (wh *WorkflowHandler) validateSignalWithStartWorkflowTimeouts(
return wh.error(errInvalidWorkflowTaskTimeoutSeconds, scope)
}

// TODO remove this if block after 1.5
if !wh.config.EnableInfiniteTimeout() {
// TODO remove the 3 functions below
// BEGIN
request.WorkflowExecutionTimeout = timestamp.DurationPtr(
common.GetWorkflowExecutionTimeout(
timestamp.DurationValue(request.GetWorkflowExecutionTimeout()),
),
)

request.WorkflowRunTimeout = timestamp.DurationPtr(
common.GetWorkflowRunTimeout(
timestamp.DurationValue(request.GetWorkflowRunTimeout()),
timestamp.DurationValue(request.GetWorkflowExecutionTimeout()),
),
)

request.WorkflowTaskTimeout = timestamp.DurationPtr(
common.GetWorkflowTaskTimeout(
request.GetNamespace(),
timestamp.DurationValue(request.GetWorkflowTaskTimeout()),
timestamp.DurationValue(request.GetWorkflowRunTimeout()),
wh.config.DefaultWorkflowTaskTimeout,
),
)
// TODO remove the 3 functions above
// END

}

return nil
}
22 changes: 22 additions & 0 deletions service/history/commandChecker.go
Expand Up @@ -579,6 +579,28 @@ func (v *commandAttrValidator) validateStartChildExecutionAttributes(
}
attributes.TaskQueue = taskQueue

// TODO remove this if block after 1.5
if !v.config.EnableInfiniteTimeout() {
attributes.WorkflowExecutionTimeout = timestamp.DurationPtr(
common.GetWorkflowExecutionTimeout(
timestamp.DurationValue(attributes.GetWorkflowExecutionTimeout()),
),
)

attributes.WorkflowRunTimeout = timestamp.DurationPtr(
common.GetWorkflowRunTimeout(
timestamp.DurationValue(attributes.GetWorkflowRunTimeout()),
timestamp.DurationValue(attributes.GetWorkflowExecutionTimeout()),
),
)
// Inherit workflow task timeout from parent workflow execution if not provided on command

if timestamp.DurationValue(attributes.GetWorkflowTaskTimeout()) <= 0 {
attributes.WorkflowTaskTimeout = parentInfo.DefaultWorkflowTaskTimeout
}
return nil
}

// workflow execution timeout is left as is
// if workflow execution timeout == 0 -> infinity

Expand Down
7 changes: 7 additions & 0 deletions service/history/configs/config.go
Expand Up @@ -235,6 +235,10 @@ type Config struct {

EnableDropStuckTaskByNamespaceID dynamicconfig.BoolPropertyFnWithNamespaceIDFilter
SkipReapplicationByNamespaceId dynamicconfig.BoolPropertyFnWithNamespaceIDFilter

// EnableInfiniteTimeout enable infinite workflow timeout
// TODO remove after 1.5
EnableInfiniteTimeout dynamicconfig.BoolPropertyFn
}

const (
Expand Down Expand Up @@ -396,6 +400,9 @@ func NewConfig(dc *dynamicconfig.Collection, numberOfShards int32, isAdvancedVis

EnableDropStuckTaskByNamespaceID: dc.GetBoolPropertyFnWithNamespaceIDFilter(dynamicconfig.EnableDropStuckTaskByNamespaceID, false),
SkipReapplicationByNamespaceId: dc.GetBoolPropertyFnWithNamespaceIDFilter(dynamicconfig.SkipReapplicationByNamespaceId, false),

// TODO remove after 1.5
EnableInfiniteTimeout: dc.GetBoolProperty(dynamicconfig.EnableInfiniteTimeout, false),
}

return cfg
Expand Down

0 comments on commit fde5b78

Please sign in to comment.