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

Add terraform migrate cluster resource doc #20659

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FingerLeader
Copy link

@FingerLeader FingerLeader commented Mar 26, 2025

First-time contributors' checklist

What is changed, added or deleted? (Required)

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.4 (TiDB 8.4 versions)
  • v8.3 (TiDB 8.3 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)

What is the related PR or file link(s)?

  • This PR is translated from:
  • Other reference link(s):

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Copy link

ti-chi-bot bot commented Mar 26, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tangenta for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. labels Mar 26, 2025
Copy link

ti-chi-bot bot commented Mar 26, 2025

Hi @FingerLeader. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. missing-translation-status This PR does not have translation status info. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 26, 2025
@qiancai qiancai self-assigned this Apr 3, 2025
@qiancai qiancai added translation/no-need No need to translate this PR. area/tidb-cloud This PR relates to the area of TiDB Cloud. labels Apr 3, 2025
@ti-chi-bot ti-chi-bot bot removed the missing-translation-status This PR does not have translation status info. label Apr 3, 2025
@qiancai qiancai added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Apr 3, 2025
@qiancai
Copy link
Collaborator

qiancai commented Apr 3, 2025

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Apr 3, 2025
Copy link

ti-chi-bot bot commented Apr 3, 2025

@FingerLeader: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-verify 12e04a4 link true /test pull-verify

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@qiancai
Copy link
Collaborator

qiancai commented Apr 3, 2025

/bot-review

@@ -359,6 +359,7 @@
- [Use Backup Resource](/tidb-cloud/terraform-use-backup-resource.md)
- [Use Restore Resource](/tidb-cloud/terraform-use-restore-resource.md)
- [Use Import Resource](/tidb-cloud/terraform-use-import-resource.md)
- [Migrate Cluster Resource](/tidb-cloud/terraform-migrate-cluster-resource.md)
Copy link

Choose a reason for hiding this comment

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

The title 'Migrate Cluster Resource' might be unclear to some users. It would be better to specify what is being migrated and to where.

Suggested change
- [Migrate Cluster Resource](/tidb-cloud/terraform-migrate-cluster-resource.md)
- [Migrate Cluster Resource using Terraform](/tidb-cloud/terraform-migrate-cluster-resource.md)


You will learn how to migrate cluster resource to serverless/dedicated cluster resource in this document.

## Prerequisites
Copy link

@github-actions github-actions bot Apr 3, 2025

Choose a reason for hiding this comment

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

The sentence is not clear. It is recommended to specify what 'x.x.x' refers to.


## Step 1. Select the `tidbcloud_cluster` resource to migrate

Use the command below to get all resources.
Copy link

Choose a reason for hiding this comment

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

The sentence is not clear. It is recommended to specify what 'all resources' refers to.

Suggested change
Use the command below to get all resources.
Use the command below to list all the `tidbcloud_cluster` resources.

terraform state list | grep "tidbcloud_cluster"
```

Select the cluster resource to migrate and execute the command below to get the `id` for later use.
Copy link

Choose a reason for hiding this comment

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

The sentence is not clear. It is recommended to specify what 'id' refers to.

Suggested change
Select the cluster resource to migrate and execute the command below to get the `id` for later use.
Select the cluster resource to migrate and execute the command below to get its `id` for later use.


## Step 2. Delete the existed resource from state

Run the `terraform state rm ${your_target_cluster_resource}` to delete the resource from state.
Copy link

Choose a reason for hiding this comment

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

The sentence is not clear. It is recommended to specify what 'the resource' refers to.

Suggested change
Run the `terraform state rm ${your_target_cluster_resource}` to delete the resource from state.
Run the `terraform state rm ${your_target_cluster_resource}` command to delete the target cluster resource from the state.


## Step 3. Delete the configuration of your target resource

Find the configuration of your target resource in tf file and delete the related code.
Copy link

Choose a reason for hiding this comment

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

The sentence is not clear. It is recommended to specify what 'the configuration of your target resource' refers to.

Suggested change
Find the configuration of your target resource in tf file and delete the related code.
Find the configuration of your target cluster resource in the tf file and delete the related code.


## Step 4. Create the configuration of your new serverless/dedicated cluster resource

Create the configuration of your new serverless/dedicated cluster resource like the `main.tf` file as below:
Copy link

Choose a reason for hiding this comment

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

The sentence is not clear. It is recommended to specify what 'the configuration of your new serverless/dedicated cluster resource' refers to.

Suggested change
Create the configuration of your new serverless/dedicated cluster resource like the `main.tf` file as below:
Create the configuration for your new serverless or dedicated cluster resource in the `main.tf` file as shown below:


## Step 5. Import the target cluster

Run the following command to import the resource, replacing ${id} with the previously recorded cluster ID:
Copy link

Choose a reason for hiding this comment

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

The sentence is not clear. It is recommended to specify what 'the resource' refers to.

Suggested change
Run the following command to import the resource, replacing ${id} with the previously recorded cluster ID:
Run the following command to import the target cluster, replacing ${id} with the previously recorded cluster ID:


## Next step

Get started by managing a cluster with the [serverless cluster resource](/tidb-cloud/terraform-use-serverless-cluster-resource.md) or [dedicated cluster resource](/tidb-cloud/terraform-use-dedicated-cluster-resource.md).
Copy link

Choose a reason for hiding this comment

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

The sentence is not clear. It is recommended to specify what 'Next step' refers to.

Suggested change
Get started by managing a cluster with the [serverless cluster resource](/tidb-cloud/terraform-use-serverless-cluster-resource.md) or [dedicated cluster resource](/tidb-cloud/terraform-use-dedicated-cluster-resource.md).
Next, you can start managing a cluster with the [serverless cluster resource](/tidb-cloud/terraform-use-serverless-cluster-resource.md) or [dedicated cluster resource](/tidb-cloud/terraform-use-dedicated-cluster-resource.md).

Copy link

github-actions bot commented Apr 3, 2025

✅ AI review completed, 10 comments generated.

@pingcap pingcap deleted a comment from github-actions bot Apr 3, 2025
@lilin90 lilin90 requested a review from Copilot April 7, 2025 02:46
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Create the configuration of your new serverless/dedicated cluster resource like the `main.tf` file as below:
```
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Serverless
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated
Copy link
Preview

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

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

The resource declaration for the Dedicated cluster appears to be incorrect; it reuses 'tidbcloud_serverless_cluster' instead of 'tidbcloud_dedicated_cluster'. Consider updating the resource type to 'tidbcloud_dedicated_cluster'.

Suggested change
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated
resource "tidbcloud_dedicated_cluster" "new_cluster" {} # Dedicated

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

@lilin90
Copy link
Member

lilin90 commented Apr 7, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds documentation for migrating cluster resources to serverless/dedicated cluster resources using Terraform. The documentation provides a step-by-step guide with commands and examples. Overall, the documentation is clear and helpful, but there are a few areas that could be improved for clarity and completeness.

Summary of Findings

  • Prerequisites: Specific Terraform Provider Version: The prerequisite section mentions updating the TiDB Cloud Terraform Provider but uses a placeholder version (x.x.x). This should be replaced with a specific, tested version to ensure the instructions work correctly.
  • Inconsistent Resource Naming in Examples: In Step 4, the example configurations for serverless and dedicated clusters use the same resource name (new_cluster). This could lead to confusion and should be clarified or corrected to use distinct names.
  • Missing Context for your_target_cluster_resource: In Step 2, the documentation uses ${your_target_cluster_resource} without explicitly defining or explaining where this value comes from. It should be clarified that this is the full resource name as listed by terraform state list.

Merge Readiness

The pull request introduces a new documentation page for migrating cluster resources using Terraform. While the steps are generally well-explained, addressing the identified issues regarding the Terraform provider version, resource naming consistency, and clarification of variable usage would significantly improve the documentation's clarity and usability. I am unable to approve this pull request, and recommend that the author address the identified issues before merging.

Comment on lines +40 to +41
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Serverless
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated

Choose a reason for hiding this comment

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

high

Using the same resource name new_cluster for both serverless and dedicated clusters might be confusing. Consider using distinct names to avoid potential issues.

Suggested change
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Serverless
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated
resource "tidbcloud_serverless_cluster" "new_serverless_cluster" {} # Serverless
resource "tidbcloud_dedicated_cluster" "new_dedicated_cluster" {} # Dedicated


## Prerequisites

- [Update TiDB Cloud Terraform Provider at least x.x.x]()

Choose a reason for hiding this comment

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

medium

It's good to specify a minimum version of the Terraform provider to ensure compatibility. Can you replace x.x.x with the actual minimum required version?

Suggested change
- [Update TiDB Cloud Terraform Provider at least x.x.x]()
- [Update TiDB Cloud Terraform Provider at least 1.1.0]()


## Step 2. Delete the existed resource from state

Run the `terraform state rm ${your_target_cluster_resource}` to delete the resource from state.

Choose a reason for hiding this comment

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

medium

It would be helpful to clarify where the ${your_target_cluster_resource} value comes from. Perhaps reference the output of the command in Step 1?

Suggested change
Run the `terraform state rm ${your_target_cluster_resource}` to delete the resource from state.
Run the `terraform state rm tidbcloud_cluster.your_old_cluster` to delete the resource from state.

Comment on lines +48 to +49
terraform import tidbcloud_serverless_cluster.new_cluster ${id} # Serverless
terraform import tidbcloud_dedicated_cluster.new_cluster ${id} # Dedicated

Choose a reason for hiding this comment

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

medium

To align with the previous suggestion, the resource names here should be updated to reflect the new resource names.

Suggested change
terraform import tidbcloud_serverless_cluster.new_cluster ${id} # Serverless
terraform import tidbcloud_dedicated_cluster.new_cluster ${id} # Dedicated
terraform import tidbcloud_serverless_cluster.new_serverless_cluster ${id} # Serverless
terraform import tidbcloud_dedicated_cluster.new_dedicated_cluster ${id} # Dedicated

Copy link

ti-chi-bot bot commented Apr 7, 2025

@gemini-code-assist[bot]: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Code Review

This pull request adds documentation for migrating cluster resources to serverless/dedicated cluster resources using Terraform. The documentation provides a step-by-step guide with commands and examples. Overall, the documentation is clear and helpful, but there are a few areas that could be improved for clarity and completeness.

Summary of Findings

  • Prerequisites: Specific Terraform Provider Version: The prerequisite section mentions updating the TiDB Cloud Terraform Provider but uses a placeholder version (x.x.x). This should be replaced with a specific, tested version to ensure the instructions work correctly.
  • Inconsistent Resource Naming in Examples: In Step 4, the example configurations for serverless and dedicated clusters use the same resource name (new_cluster). This could lead to confusion and should be clarified or corrected to use distinct names.
  • Missing Context for your_target_cluster_resource: In Step 2, the documentation uses ${your_target_cluster_resource} without explicitly defining or explaining where this value comes from. It should be clarified that this is the full resource name as listed by terraform state list.

Merge Readiness

The pull request introduces a new documentation page for migrating cluster resources using Terraform. While the steps are generally well-explained, addressing the identified issues regarding the Terraform provider version, resource naming consistency, and clarification of variable usage would significantly improve the documentation's clarity and usability. I am unable to approve this pull request, and recommend that the author address the identified issues before merging.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tidb-cloud This PR relates to the area of TiDB Cloud. contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. ok-to-test Indicates a PR is ready to be tested. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. translation/no-need No need to translate this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants