Skip to content

Commit b5f64f2

Browse files
authored
Protect UpdateWorkflowExecution API with dynamic config feature flag (#3884)
1 parent 8b6b2fb commit b5f64f2

File tree

6 files changed

+22
-0
lines changed

6 files changed

+22
-0
lines changed

common/dynamicconfig/constants.go

+5
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ const (
253253
// FrontendEnableBatcher enables batcher-related RPCs in the frontend
254254
FrontendEnableBatcher = "frontend.enableBatcher"
255255

256+
// FrontendEnableUpdateWorkflowExecution enables UpdateWorkflowExecution API in the frontend.
257+
// UpdateWorkflowExecution API is under active development and is not ready for production use.
258+
// Default value is `false`. It will be changed to `true` when this API is ready and fully tested.
259+
FrontendEnableUpdateWorkflowExecution = "frontend.enableUpdateWorkflowExecution"
260+
256261
// DeleteNamespaceDeleteActivityRPS is an RPS per every parallel delete executions activity.
257262
// Total RPS is equal to DeleteNamespaceDeleteActivityRPS * DeleteNamespaceConcurrentDeleteExecutionsActivities.
258263
// Default value is 100.

service/frontend/errors.go

+2
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,6 @@ var (
110110
errBatchOpsWorkflowFilterNotSet = serviceerror.NewInvalidArgument("Workflow executions and visibility filter are not set on request.")
111111
errBatchOpsWorkflowFiltersNotAllowed = serviceerror.NewInvalidArgument("Workflow executions and visibility filter are both set on request. Only one of them is allowed.")
112112
errBatchOpsMaxWorkflowExecutionCount = serviceerror.NewInvalidArgument("Workflow executions count exceeded.")
113+
114+
errUpdateWorkflowExecutionAPINotAllowed = serviceerror.NewPermissionDenied("UpdateWorkflowExecution operation is disabled on this namespace.", "")
113115
)

service/frontend/service.go

+4
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ type Config struct {
165165
// Batch operation dynamic configs
166166
MaxConcurrentBatchOperation dynamicconfig.IntPropertyFnWithNamespaceFilter
167167
MaxExecutionCountBatchOperation dynamicconfig.IntPropertyFnWithNamespaceFilter
168+
169+
EnableUpdateWorkflowExecution dynamicconfig.BoolPropertyFnWithNamespaceFilter
168170
}
169171

170172
// NewConfig returns new service config with default values
@@ -235,6 +237,8 @@ func NewConfig(dc *dynamicconfig.Collection, numHistoryShards int32, enableReadF
235237
EnableBatcher: dc.GetBoolPropertyFnWithNamespaceFilter(dynamicconfig.FrontendEnableBatcher, true),
236238
MaxConcurrentBatchOperation: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.FrontendMaxConcurrentBatchOperationPerNamespace, 1),
237239
MaxExecutionCountBatchOperation: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.FrontendMaxExecutionCountBatchOperationPerNamespace, 1000),
240+
241+
EnableUpdateWorkflowExecution: dc.GetBoolPropertyFnWithNamespaceFilter(dynamicconfig.FrontendEnableUpdateWorkflowExecution, false),
238242
}
239243
}
240244

service/frontend/workflow_handler.go

+4
Original file line numberDiff line numberDiff line change
@@ -3684,6 +3684,10 @@ func (wh *WorkflowHandler) UpdateWorkflowExecution(
36843684
return nil, err
36853685
}
36863686

3687+
if !wh.config.EnableUpdateWorkflowExecution(request.Namespace) {
3688+
return nil, errUpdateWorkflowExecutionAPINotAllowed
3689+
}
3690+
36873691
histResp, err := wh.historyClient.UpdateWorkflowExecution(ctx, &historyservice.UpdateWorkflowExecutionRequest{
36883692
NamespaceId: nsID.String(),
36893693
Request: request,

tests/dynamicconfig.go

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var (
5252
dynamicconfig.ReplicationTaskProcessorErrorRetryWait: time.Millisecond,
5353
dynamicconfig.ClusterMetadataRefreshInterval: 100 * time.Millisecond,
5454
dynamicconfig.NamespaceCacheRefreshInterval: NamespaceCacheRefreshInterval,
55+
dynamicconfig.FrontendEnableUpdateWorkflowExecution: true,
5556
}
5657
)
5758

tests/update_workflow_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func (s *integrationSuite) TestUpdateWorkflow_FirstWorkflowTask_AcceptComplete()
208208
Input: &updatepb.Input{Name: "update_handler", Args: payloads.EncodeString("update args")},
209209
},
210210
})
211+
s.NoError(err1)
211212
updateResultCh <- UpdateResult{Response: updateResponse, Err: err1}
212213
}
213214
go updateWorkflowFn()
@@ -402,6 +403,7 @@ func (s *integrationSuite) TestUpdateWorkflow_NewWorkflowTask_AcceptComplete() {
402403
},
403404
},
404405
})
406+
s.NoError(err1)
405407
updateResultCh <- UpdateResult{Response: updateResponse, Err: err1}
406408
}
407409
go updateWorkflowFn()
@@ -560,6 +562,7 @@ func (s *integrationSuite) TestUpdateWorkflow_FirstWorkflowTask_Reject() {
560562
},
561563
},
562564
})
565+
s.NoError(err1)
563566
updateResultCh <- UpdateResult{Response: updateResponse, Err: err1}
564567
}
565568
go updateWorkflowFn()
@@ -732,6 +735,7 @@ func (s *integrationSuite) TestUpdateWorkflow_NewWorkflowTask_Reject() {
732735
},
733736
},
734737
})
738+
s.NoError(err1)
735739
updateResultCh <- UpdateResult{Response: updateResponse, Err: err1}
736740
}
737741
go updateWorkflowFn()
@@ -969,6 +973,7 @@ func (s *integrationSuite) TestUpdateWorkflow_FirstWorkflowTask_1stAccept_2ndAcc
969973
},
970974
},
971975
})
976+
s.NoError(err1)
972977
ch <- UpdateResult{Response: updateResponse, Err: err1}
973978
}
974979

@@ -1246,6 +1251,7 @@ func (s *integrationSuite) TestUpdateWorkflow_FirstWorkflowTask_1stAccept_2ndRej
12461251
},
12471252
},
12481253
})
1254+
s.NoError(err1)
12491255
ch <- UpdateResult{Response: updateResponse, Err: err1}
12501256
}
12511257

0 commit comments

Comments
 (0)