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

Updating annotations fails #217

Closed
dh-harald opened this issue Nov 15, 2018 · 14 comments
Closed

Updating annotations fails #217

dh-harald opened this issue Nov 15, 2018 · 14 comments

Comments

@dh-harald
Copy link
Contributor

Hi,

Terraform Version

Terraform v0.11.10
+ provider.kubernetes v1.3.0

Affected Resource(s)

kubernetes_storage_class and others ???

Terraform Configuration Files

resource "kubernetes_storage_class" "gp2" {
  metadata {
    name = "gp2"
  }
  storage_provisioner = "kubernetes.io/aws-ebs"
  parameters {
    type      = "gp2"
    encrypted = "true"
  }
}

Steps to Reproduce

  1. terraform apply
  2. add additional annotiation to resource, for example: annotations { "label" = "test" }
  3. terraform apply

Actual Behavior

  metadata.0.annotations.%:     "0" => "1"
  metadata.0.annotations.label: "" => "test"

Error: Error applying plan:

1 error(s) occurred:

* kubernetes_storage_class.gp2: 1 error(s) occurred:

* kubernetes_storage_class.gp2: invalid resource name "/gp2": [may not contain '/']

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
@dh-harald
Copy link
Contributor Author

I think, the same issue (#37), but it looks, that root cause was different

@alexsomesan
Copy link
Member

@dh-harald Was this actually and issue in the provider?
What root cause did you arrive to?

@dh-harald
Copy link
Contributor Author

I don't know, what's the root cause, but it looks itsn't that contains slashes. It's a simple annotation without slash, and the provider fails, and breaks the state file as well:

                    "primary": {
                        "id": "/gp2",
                        "attributes": {
                            "id": "/gp2",

@alexsomesan
Copy link
Member

Could you reproduce the failure with environment variable TF_LOG=1 set?
The output of that would help us understand what'a going on (although I have a suspicion of what it is).

@dh-harald
Copy link
Contributor Author

@alexsomesan
Copy link
Member

Thanks! I'm looking over it.

@dh-harald
Copy link
Contributor Author

I've forgot an aws input state in the directory, so ignore that aws related stuffz. Without it there's the same result, I can reupload the logs without it

@ctranstrum
Copy link

Any update on this issue? Just ran into this one, and it promoted the error into the state file so that no plan, apply, destroy will work.

@dh-harald
Copy link
Contributor Author

@alexsomesan I still have this problem in 1.7.0 release... Could you take look please?

@alexsomesan
Copy link
Member

alexsomesan commented May 23, 2019 via email

@dh-harald
Copy link
Contributor Author

dh-harald commented May 24, 2019

@alexsomesan I've facing similar issue, when I'm migrating from provider of @sl1pm4t to the official one.

For example, I've a deployment, with the following code snippet:

selector {
  "app.kubernetes.io/name"       = "app
}

Now it should be

selector {
  match_labels {
    "app.kubernetes.io/name"       = "app
  }
}

I'm modifying the hcl, and then I run terraform apply, the id of the resource starts with / same as like before (in the original issue)
The interesting part, that the broken resources are the kubernetes_cluster_role and kubernetes_cluster_role_binding

@mdz
Copy link

mdz commented May 25, 2019

I encountered a similar issue when migrating from the sl1pm4t/terraform-provider-kubernetes to terraform-provider-kubernetes 1.7.0. I was able to mostly resolve it by performing a terraform state rm followed by terraform import for each affected resource. terraform apply still wants to recreate the resource, citing the namespace attribute.

@protomonk
Copy link

Same issue upgrading from sl1pm4t/terraform-provider-kubernetes with kubernetes_cluster_role and kubernetes_cluster_role_binding.

Resolved by manual editing of the state file to remove "/" from the name of the offending cluster_role and cluster_role_binding.

@alexsomesan
Copy link
Member

@protomonk and @dh-harald
In Kubernetes names of resources cannot contain / so that error about is justified.

Thesl1pm4t/terraform-provider-kubernetes has been forked quite a while ago and AFAIK isn't tracking changes from this one so the likelihood of the state files not being compatible is very high. I would recommend to not rely on that fact and either re-import the resources or re-create them.

As the original error reported in this issue is un-reproducible as described and the conversation has migrated to different aspects I am going to close this issue because it looks like there isn't any actionable item to be addressed.

Please open new specific issues for any other problems you encounter. Feel free to comment if you think there are actual actionable items here.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants