Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions common/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3094,6 +3094,11 @@ WorkerActivitiesPerSecond, MaxConcurrentActivityTaskPollers.
false,
`WorkerEnableHistoryRateLimiter decides whether to generate migration tasks with history length rate limiter.`,
)
WorkerDryRunMode = NewGlobalBoolSetting(
"worker.dryRunMode",
Comment on lines +3097 to +3098
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the name more accurate? there's other stuff going on in the worker besides xdc

Suggested change
WorkerDryRunMode = NewGlobalBoolSetting(
"worker.dryRunMode",
WorkerXDCDryRunMode = NewGlobalBoolSetting(
"worker.xdcDryRunMode",

false,
`WorkerDryRunMode causes XDC system workflows (force-replication, namespace-handover) to complete immediately without doing real work. Use for testing.`,
)
MaxUserMetadataSummarySize = NewNamespaceIntSetting(
"limit.userMetadataSummarySize",
400,
Expand Down
6 changes: 6 additions & 0 deletions service/worker/migration/activities.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type (
namespaceReplicationQueue persistence.NamespaceReplicationQueue
generateMigrationTaskViaFrontend dynamicconfig.BoolPropertyFn
enableHistoryRateLimiter dynamicconfig.BoolPropertyFn
dryRunMode dynamicconfig.BoolPropertyFn
workflowVerifier WorkflowVerifier
chasmRegistry *chasm.Registry
}
Expand Down Expand Up @@ -152,6 +153,11 @@ func (r verifyResult) isVerified() bool {
// changing all existing tooling around namespace migration to start workflows & activities on the new task queue.
// Another approach is to use separate workers for workflow tasks and activities and keep existing tooling unchanged.

// IsDryRunMode returns whether the cell is in dry-run mode.
func (a *activities) IsDryRunMode(_ context.Context) (bool, error) {
return a.dryRunMode(), nil
}

// GetMetadata returns history shard count and namespaceID for requested namespace.
func (a *activities) GetMetadata(_ context.Context, request metadataRequest) (*metadataResponse, error) {
nsEntry, err := a.namespaceRegistry.GetNamespace(namespace.Name(request.Namespace))
Expand Down
20 changes: 20 additions & 0 deletions service/worker/migration/force_replication_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ func ForceReplicationWorkflow(ctx workflow.Context, params ForceReplicationParam
}, nil
})

if dryRun, _ := isDryRunMode(ctx); dryRun {
return nil
}

if err := validateAndSetForceReplicationParams(ctx, &params); err != nil {
return err
}
Expand Down Expand Up @@ -217,6 +221,10 @@ func ForceReplicationWorkflowV2(ctx workflow.Context, params ForceReplicationPar
}, nil
})

if dryRun, _ := isDryRunMode(ctx); dryRun {
return nil
}

if err := validateAndSetForceReplicationParams(ctx, &params); err != nil {
return err
}
Expand Down Expand Up @@ -337,6 +345,18 @@ func ForceTaskQueueUserDataReplicationWorkflow(ctx workflow.Context, params Task
return err
}

func isDryRunMode(ctx workflow.Context) (bool, error) {
lao := workflow.LocalActivityOptions{
StartToCloseTimeout: 5 * time.Second,
}
var a *activities
var dryRun bool
err := workflow.ExecuteLocalActivity(
workflow.WithLocalActivityOptions(ctx, lao), a.IsDryRunMode,
).Get(ctx, &dryRun)
return dryRun, err
}

func validateAndSetForceReplicationParams(ctx workflow.Context, params *ForceReplicationParams) error {
if len(params.Namespace) == 0 {
return temporal.NewNonRetryableApplicationError("InvalidArgument: Namespace is required", "InvalidArgument", nil)
Expand Down
1 change: 1 addition & 0 deletions service/worker/migration/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (wc *replicationWorkerComponent) activities() *activities {
forceReplicationMetricsHandler: wc.MetricsHandler.WithTags(metrics.WorkflowTypeTag(forceReplicationWorkflowName)),
generateMigrationTaskViaFrontend: dynamicconfig.WorkerGenerateMigrationTaskViaFrontend.Get(wc.DynamicCollection),
enableHistoryRateLimiter: dynamicconfig.WorkerEnableHistoryRateLimiter.Get(wc.DynamicCollection),
dryRunMode: dynamicconfig.WorkerDryRunMode.Get(wc.DynamicCollection),
workflowVerifier: wc.WorkflowVerifier,
chasmRegistry: wc.ChasmRegistry,
}
Expand Down
5 changes: 5 additions & 0 deletions service/worker/migration/handover_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ func NamespaceHandoverWorkflow(ctx workflow.Context, params NamespaceHandoverPar
if err := validateAndSetNamespaceHandoverParams(&params); err != nil {
return err
}

if dryRun, _ := isDryRunMode(ctx); dryRun {
return nil
}

retryPolicy := &temporal.RetryPolicy{
InitialInterval: time.Second,
MaximumInterval: time.Second,
Expand Down
Loading