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

re-importing rancher2_cluster_template confuses template revisions #386

Closed
ninjaslothx opened this issue Jul 14, 2020 · 2 comments
Closed

Comments

@ninjaslothx
Copy link

ninjaslothx commented Jul 14, 2020

I was getting a issue similar to #365 when try to add in additional template revisions.
I built the provider off the master branch and experienced

Error: rpc error: code = Unavailable desc = transport is closing
panic: runtime error: invalid memory address or nil pointer dereference

A user in the above issue mentioned he changed computer and it went away.
I tried this to no avail but am using shared s3 state storage, so thought it might pay to delete the resource and re-import it

tf state rm rancher2_cluster_template.testing
tf import rancher2_cluster_template.testing cattle-global-data:ct-xhq5b

Once imported I went to check on my rpc error, but noticed that the import had caused terraform to try to swap around the template_revisions.
You can see v2 wanted to become v1, and vice versa.
Along with changing any config differences and the cluster_template_revision_id on the cluster which was referenced using the v1 index.

rancher2_cluster_template.testing.template_revisions.0.id

Changes only:


  ~ resource "rancher2_cluster" "testing" {
      ~ cluster_template_revision_id            = "cattle-global-data:ctr-xb8zj" -> "cattle-global-data:ctr-2qvxf"
      

  ~ resource "rancher2_cluster_template" "testing" {

      ~ template_revisions {
          ~ default             = false -> true
          ~ name                = "v2" -> "v1"
          ~ cluster_config {
              ~ rke_config {
                  ~ private_registries {
                      + password   = (sensitive value)
                    }
              ~ scheduled_cluster_scan {
                  ~ enabled = true -> false
                }

      ~ template_revisions {
          ~ default             = true -> false

          ~ name                = "v1" -> "v2"

          ~ cluster_config {
              ~ rke_config {
                  ~ private_registries {          
                      + password   = (sensitive value)
                    }

This then causes issues for obvious reasons, but also becomes an illegal operation as you are not allowed to update a template that is in use by the cluster.
Unsure if there is a better way to handle this import.

@ghost ghost added bug labels Jul 14, 2020
@rawmind0 rawmind0 removed the crash label Jul 29, 2020
@rawmind0
Copy link
Contributor

@ninjaslothx the issue has been reproduced. PR #395 includes a patch to address it

@rawmind0
Copy link
Contributor

PR merged on master and will be available on next release. Please, reopen issue if needed.

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

No branches or pull requests

2 participants