Skip to content

Commit 02f6752

Browse files
authored
display and update namespace replication state (#844)
<!--- Note to EXTERNAL Contributors --> <!-- Thanks for opening a PR! If it is a significant code change, please **make sure there is an open issue** for this. We work best with you when we have accepted the idea first before you code. --> <!--- For ALL Contributors 👇 --> ## What was changed Allow display and update namespace replication state. ## Why? We want to check namespace replication state quickly from cli, and update it if needed. ## Checklist <!--- add/delete as needed ---> 1. Closes <!-- add issue number here --> 2. How was this tested: Tested locally with server change temporalio/temporal#8234 3. Any docs updates needed? (not sure if update is needed) https://docs.temporal.io/cli/operator#update
1 parent 5b3e079 commit 02f6752

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

temporalcli/commands.gen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,7 @@ type TemporalOperatorNamespaceUpdateCommand struct {
14321432
PromoteGlobal bool
14331433
HistoryArchivalState StringEnum
14341434
HistoryUri string
1435+
ReplicationState StringEnum
14351436
Retention Duration
14361437
VisibilityArchivalState StringEnum
14371438
VisibilityUri string
@@ -1458,6 +1459,8 @@ func NewTemporalOperatorNamespaceUpdateCommand(cctx *CommandContext, parent *Tem
14581459
s.HistoryArchivalState = NewStringEnum([]string{"disabled", "enabled"}, "")
14591460
s.Command.Flags().Var(&s.HistoryArchivalState, "history-archival-state", "History archival state. Accepted values: disabled, enabled.")
14601461
s.Command.Flags().StringVar(&s.HistoryUri, "history-uri", "", "Archive history to this `URI`. Once enabled, can't be changed.")
1462+
s.ReplicationState = NewStringEnum([]string{"normal", "handover"}, "")
1463+
s.Command.Flags().Var(&s.ReplicationState, "replication-state", "Replication state. Accepted values: normal, handover.")
14611464
s.Retention = 0
14621465
s.Command.Flags().Var(&s.Retention, "retention", "Length of time a closed Workflow is preserved before deletion.")
14631466
s.VisibilityArchivalState = NewStringEnum([]string{"disabled", "enabled"}, "")

temporalcli/commands.operator_namespace.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ func (c *TemporalOperatorNamespaceUpdateCommand) run(cctx *CommandContext, args
281281
}
282282
replicationConfig := &replication.NamespaceReplicationConfig{
283283
Clusters: clusters,
284+
State: replicationState(c.ReplicationState.String()),
284285
}
285286
updateRequest = &workflowservice.UpdateNamespaceRequest{
286287
Namespace: nsName,
@@ -316,6 +317,7 @@ func printNamespaceDescriptions(cctx *CommandContext, responses ...*workflowserv
316317
"Config.WorkflowExecutionRetentionTtl": resp.Config.WorkflowExecutionRetentionTtl.AsDuration(),
317318
"ReplicationConfig.ActiveClusterName": resp.ReplicationConfig.ActiveClusterName,
318319
"ReplicationConfig.Clusters": resp.ReplicationConfig.Clusters,
320+
"ReplicationConfig.State": resp.ReplicationConfig.State,
319321
"Config.HistoryArchivalState": resp.Config.HistoryArchivalState,
320322
"Config.VisibilityArchivalState": resp.Config.VisibilityArchivalState,
321323
"IsGlobalNamespace": resp.IsGlobalNamespace,
@@ -334,7 +336,8 @@ func printNamespaceDescriptions(cctx *CommandContext, responses ...*workflowserv
334336
"NamespaceInfo.Name", "NamespaceInfo.Id", "NamespaceInfo.Description",
335337
"NamespaceInfo.OwnerEmail", "NamespaceInfo.State", "NamespaceInfo.Data",
336338
"Config.WorkflowExecutionRetentionTtl", "ReplicationConfig.ActiveClusterName",
337-
"ReplicationConfig.Clusters", "Config.HistoryArchivalState", "Config.VisibilityArchivalState",
339+
"ReplicationConfig.Clusters", "ReplicationConfig.State",
340+
"Config.HistoryArchivalState", "Config.VisibilityArchivalState",
338341
"IsGlobalNamespace", "FailoverVersion", "FailoverHistory", "Config.HistoryArchivalUri",
339342
"Config.VisibilityArchivalUri",
340343
"Config.CustomSearchAttributeAliases",
@@ -352,3 +355,13 @@ func archivalState(input string) enums.ArchivalState {
352355
}
353356
return enums.ARCHIVAL_STATE_UNSPECIFIED
354357
}
358+
359+
func replicationState(input string) enums.ReplicationState {
360+
switch input {
361+
case "normal":
362+
return enums.REPLICATION_STATE_NORMAL
363+
case "handover":
364+
return enums.REPLICATION_STATE_HANDOVER
365+
}
366+
return enums.REPLICATION_STATE_UNSPECIFIED
367+
}

temporalcli/commandsgen/commands.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,12 @@ commands:
17361736
description: |
17371737
Archive history to this `URI`.
17381738
Once enabled, can't be changed.
1739+
- name: replication-state
1740+
type: string-enum
1741+
description: Replication state.
1742+
enum-values:
1743+
- normal
1744+
- handover
17391745
- name: retention
17401746
type: duration
17411747
description: Length of time a closed Workflow is preserved before deletion.

0 commit comments

Comments
 (0)