Skip to content

Commit

Permalink
Move namespace cache delay to reclaim resources workflow (#2658)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin committed Mar 29, 2022
1 parent 30c2867 commit c6a0cfc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 9 additions & 0 deletions service/worker/deletenamespace/reclaimresources/workflow.go
Expand Up @@ -40,6 +40,8 @@ import (
const (
// WorkflowName is the workflow name.
WorkflowName = "temporal-sys-reclaim-namespace-resources-workflow"

namespaceCacheRefreshDelay = 11 * time.Second
)

type (
Expand Down Expand Up @@ -95,6 +97,13 @@ func ReclaimResourcesWorkflow(ctx workflow.Context, params ReclaimResourcesParam

var a *Activities

// Step 0. This workflow is started right after namespace is marked as DELETED and renamed.
// Wait for namespace cache refresh to make sure no new executions are created.
err := workflow.Sleep(ctx, namespaceCacheRefreshDelay)
if err != nil {
return ReclaimResourcesResult{}, err
}

// Step 1. Delete workflow executions.
result, err := deleteWorkflowExecutions(ctx, params)
if err != nil {
Expand Down
7 changes: 0 additions & 7 deletions service/worker/deletenamespace/workflow.go
Expand Up @@ -42,8 +42,6 @@ import (
const (
// WorkflowName is the workflow name.
WorkflowName = "temporal-sys-delete-namespace-workflow"

namespaceCacheRefreshDelay = 11 * time.Second
)

type (
Expand Down Expand Up @@ -138,11 +136,6 @@ func DeleteNamespaceWorkflow(ctx workflow.Context, params DeleteNamespaceWorkflo
return result, fmt.Errorf("%w: RenameNamespaceActivity: %v", errors.ErrUnableToExecuteActivity, err)
}

err = workflow.Sleep(ctx, namespaceCacheRefreshDelay)
if err != nil {
return result, err
}

// Step 4. Reclaim workflow resources asynchronously.
ctx4 := workflow.WithChildOptions(ctx, reclaimResourcesWorkflowOptions)
reclaimResourcesFuture := workflow.ExecuteChildWorkflow(ctx4, reclaimresources.ReclaimResourcesWorkflow, reclaimresources.ReclaimResourcesParams{
Expand Down

0 comments on commit c6a0cfc

Please sign in to comment.