-
Notifications
You must be signed in to change notification settings - Fork 689
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
base: master
Are you sure you want to change the base?
Add terraform migrate cluster resource doc #20659
Conversation
Signed-off-by: FingerLeader <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
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 Once the patch is verified, the new status will be reflected by the 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. |
/ok-to-test |
@FingerLeader: The following test failed, say
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. |
/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) |
There was a problem hiding this comment.
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.
- [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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
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. |
There was a problem hiding this comment.
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.
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. |
There was a problem hiding this comment.
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.
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. |
There was a problem hiding this comment.
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.
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: |
There was a problem hiding this comment.
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.
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: |
There was a problem hiding this comment.
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.
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). |
There was a problem hiding this comment.
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.
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). |
✅ AI review completed, 10 comments generated. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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'.
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.
/gemini review |
There was a problem hiding this 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 byterraform 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.
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Serverless | ||
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the same resource name new_cluster
for both serverless and dedicated clusters might be confusing. Consider using distinct names to avoid potential issues.
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]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
## Step 2. Delete the existed resource from state | ||
|
||
Run the `terraform state rm ${your_target_cluster_resource}` to delete the resource from state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
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. |
terraform import tidbcloud_serverless_cluster.new_cluster ${id} # Serverless | ||
terraform import tidbcloud_dedicated_cluster.new_cluster ${id} # Dedicated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To align with the previous suggestion, the resource names here should be updated to reflect the new resource names.
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 |
@gemini-code-assist[bot]: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this:
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. |
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.
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?