CKS registry and state updates#154
Conversation
…ion for better state
|
@JSpon also can you add the documentation for the parameters |
|
@JSpon Please you update the documentation as well. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds Docker registry credential support to CloudStack Kubernetes cluster creation and improves error handling by attempting to retrieve cluster information when creation fails.
- Adds three new optional schema fields for Docker registry credentials (URL, username, password)
- Sets Docker registry parameters in the creation request when provided
- Implements error recovery by attempting to retrieve cluster information on creation failure
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| cluster, _, errg := cs.Kubernetes.GetKubernetesClusterByName( | ||
| name, | ||
| cloudstack.WithProject(d.Get("project").(string)), | ||
| ) | ||
| if errg == nil { | ||
| d.SetId(cluster.Id) | ||
| } |
There was a problem hiding this comment.
Setting the resource ID on creation failure is incorrect. This creates inconsistent state where Terraform believes the resource was created successfully but the actual creation failed. The original error should be returned without setting the ID, allowing Terraform to properly handle the failed creation.
| cluster, _, errg := cs.Kubernetes.GetKubernetesClusterByName( | |
| name, | |
| cloudstack.WithProject(d.Get("project").(string)), | |
| ) | |
| if errg == nil { | |
| d.SetId(cluster.Id) | |
| } |
| "docker_registry_password": { | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
| ForceNew: true, | ||
| Sensitive: true, |
There was a problem hiding this comment.
The docker_registry_password field should include DiffSuppressOnRefresh: true to prevent sensitive values from being stored in state and logged during refresh operations.
| "docker_registry_password": { | |
| Type: schema.TypeString, | |
| Optional: true, | |
| ForceNew: true, | |
| Sensitive: true, | |
| Sensitive: true, | |
| DiffSuppressOnRefresh: true, |
kiranchavala
left a comment
There was a problem hiding this comment.
Logged a issue as cks cluster creation was failing with the new provided parameters
kiranchavala
left a comment
There was a problem hiding this comment.
LGTM, merging as it's nothing to do with terraform
The parameters are successfully applied on the cks cluster
Add registry credentials to cks creation, and caàtch failures on creation on for better state