Update SDK and make machine pool cloud_credential_secret_name optional to fix plan bug #1070
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
#835
Problem
When creating an RKE2 cluster via Terraform on any hosted provider (Amazon EC2, Azure, Linode driver so far), Terraform computes a new value for a duplicate field
cloud_credential_secret_name
in the machine pool and then throws an error on a terraform apply pertaining to that new value. It works on a second run of terraform apply but is frustrating and widely seen by many customers.Solution
That field currently exists in both
rancher_cluster_v2
andrancher_cluster_v2.machine_pool
. I couldn't find docs on why the cloud credential secret was added to the machine pool. Rancher pulls the cloud credential secret from the RKECommonNodeConfig and sets it on the newly created machine here as well as the cluster management Spec but doesn't do anything further with it. This looks like a legacy-related change from this PR but I don't fully know the context of the design decision here.Rancher allows you to mix and match secrets, possibly to support the use case where a customer has machine pools in separate AWS/cloud accounts. The TF provider rancher2 must have parity with Rancher so this field cannot be removed (as I originally thought) because that would cause a regression.
Update 2/10: I believe this is a bug/compatibility issue in the Terraform plugin SDK. See comment #835 (comment) for further details.
This PR has the following fix
machine_pool.cloud_credential_secret_name
to be Optional. This keeps parity with Terraform and fixes the plan bugTesting
Engineering Testing
Manual Testing
Tested with RKE2 clusters on Amazon EC2. Each cluster provisions successfully on the first try of terraform apply. If you do not specify a cloud credential, the cluster hangs with
Waiting for viable init node
trying to create the machine. I am open to discussion on this behavior.Testing