Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] fix a few things in domain migration command #5374

Merged
merged 5 commits into from
Aug 9, 2023

Conversation

shijiesheng
Copy link
Contributor

@shijiesheng shijiesheng commented Aug 8, 2023

What changed?

  • add two methods in ClientFactory for migration
  • countWorkflowCheck should be on current domain
  • fix concurrency bug
  • make template look slightly better
  • refactor to move out domainMigration into separate cli entity

Why?

add two methods in ClientFactory for migration
This is needed to be able to use environment flags for internal usage

How did you test it?

shengs@shengs-C02XN3VDJGH6 cadence % go run cmd/tools/cli/main.go --do domain-1 domain migration --destination_address localhost:7933 --destination_domain domain-2 --tasklist ts1 --search_attr someID:INT
2023/08/08 10:21:28 Loading configFiles=[config/base.yaml config/development.yaml]
2023/08/08 10:21:28 Loading configFiles=[config/base.yaml config/development.yaml]
{"level":"info","ts":"2023-08-08T10:21:28.241-0700","msg":"Updated dynamic config","logging-call-at":"file_based_client.go:284"}
Validation Check:
- Domain Meta Data: true
    Current Domain:
      Name: domain-1
      UUID: d3cc0a3c-8f55-40af-9820-c48f8a0f46e5
    New Domain:
      Name: domain-2
      UUID: 203f0088-1d0f-40ac-a7c3-fdcf57ec0a99
- Workflow Check: true
    Long Running Workflow Num: 0
- Dynamic Config Check: false
    - Config Key: matching.asyncTaskDispatchTimeout
        Current Response:
          Data: "50s"
          Filters:
            - Name: domainName
              Value: "domain-1"
            - Name: taskListName
              Value: ["ts1"]
        New Response:
          Data: "20s"
          Filters:
            - Name: domainName
              Value: "domain-2"
            - Name: taskListName
              Value: ["ts1"]
- Search Attributes Check: false
    Missing Search Attributes in Current Domain:
      - someID:INT
    Missing Search Attributes in New Domain:
      - someID:INT

Potential risks

No Risk

Release notes

Documentation Changes

@@ -139,6 +135,31 @@ func (b *clientFactory) ServerAdminClient(c *cli.Context) admin.Client {
return admin.NewThriftClient(serverAdmin.New(clientConfig))
}

// ServerFrontendClientForMigration builds a frontend client (based on server side thrift interface)
func (b *clientFactory) ServerFrontendClientForMigration(c *cli.Context) frontend.Client {
Copy link
Contributor

Choose a reason for hiding this comment

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

the code is exactly the same as ServerFrontendClient, should dispatcher be replaced with something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. fixed

// ServerAdminClientForMigration builds an admin client (based on server side thrift interface)
func (b *clientFactory) ServerAdminClientForMigration(c *cli.Context) admin.Client {
b.ensureDispatcher(c)
clientConfig := b.dispatcher.ClientConfig(cadenceFrontendService)
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

}

// DEPRECATED don't use, only reserved for backward compatibility purposes
// NewClientFactory creates a new ClientFactory
func NewClientFactory() ClientFactory {
Copy link
Contributor

Choose a reason for hiding this comment

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

The method was marked as deprecated, is there a way to not use it?

Copy link
Contributor Author

@shijiesheng shijiesheng Aug 8, 2023

Choose a reason for hiding this comment

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

it was deprecated in the previous CLI pr but then I realize it should not be deprecated.

b.dispatcher = b.newClientDispatcher(c, c.GlobalString(FlagAddress))
}

func (b *clientFactory) ensureDispatcherForMigration(c *cli.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this method is not used anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

used now

@shijiesheng shijiesheng enabled auto-merge (squash) August 8, 2023 20:31
@@ -768,8 +768,8 @@ func newIndefiniteContext(c *cli.Context) (context.Context, context.CancelFunc)
}

func newTimedContext(c *cli.Context, timeout time.Duration) (context.Context, context.CancelFunc) {
if c.GlobalIsSet(FlagContextTimeout) {
Copy link
Contributor Author

@shijiesheng shijiesheng Aug 9, 2023

Choose a reason for hiding this comment

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

because this operation is not thread safe, I changed it

@shijiesheng shijiesheng merged commit 818cdb7 into uber:master Aug 9, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants