Terraform-provider-kubernetes: Upgrading a daemonset to provider version 0.13 fails to apply

Created on 3 Sep 2020  ·  4Comments  ·  Source: hashicorp/terraform-provider-kubernetes

Terraform Version and Provider Version

Terraform v0.12.24

  • provider.kubernetes v1.13.1

Affected Resource(s)

  • kubernetes_daemonset

Terraform Configuration Files

Reduced to a relevant equivalent config:

resource "kubernetes_daemonset" "fluent_bit" {
  metadata {
    name      = "fluent-bit"
    namespace = "example"
    labels = {
      k8s-app = "fluent-bit"
    }
  }

  spec {
    selector {
      match_labels = {
        k8s-app = "fluent-bit"
      }
    }

    template {
      metadata {
        name = "fluent-bit"
        labels = {
          k8s-app = "fluent-bit"
        }
      }

      spec {
        init_container {
          image   = "mesosphere/aws-cli:1.14.5"
          name    = "example-setup"

          volume_mount {
            name       = "configs"
            mount_path = "/configs/"
          }
        }

        container {
          image             = "fluent/fluent-bit:1.4.6"
          name              = "example"

          volume_mount {
            name       = "configs"
            mount_path = "/configs/"
            read_only  = true
          }
        }
        volume {
          name = "configs"
          empty_dir {}
        }
      }
    }
  }
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

What should have happened?

  1. The daemonset should have been determined to be up-to-date.
  2. If the daemonset needed to be updated, a behavior similar to kubectl replace should have been used, replacing the spec field for the existing daemonset.
  3. If the daemonset needed to be recreated, the deletion should have waited for the delete to complete before attempting the creation.

Actual Behavior

What actually happened?

The plan showed the configs volume requiring an update:

                  ~ volume {
                        name = "configs"
                      ~ empty_dir {
                          + size_limit = "0" # forces replacement
                        }
                    }

When applying this change, the existing daemonset was deleted, and failed to recreate:

kubernetes_daemonset.fluent_bit: Destruction complete after 3s
kubernetes_daemonset.fluent_bit: Creating...
Error: Failed to create daemonset: object is being deleted: daemonsets.apps "fluent-bit" already exists
  on fluentbit.tf line 1, in resource "kubernetes_daemonset" "fluent_bit":
 1: resource "kubernetes_daemonset" "fluent_bit" {

Steps to Reproduce

  1. Create the example resource using provider version < 0.13
  2. Apply the resource using provider version 0.13.1

Important Factoids

None known

References

  • hashicorp/terraform-provider-kubernetes#919 may be related, although I don't know if that also covers deletion behavior

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
bug

All 4 comments

I think this is related to #985

Thanks, @Redeux. I was filtering by open issues when searching, so I didn't see any of the existing closed ones.

It looks like #985 may have fixed this one, and I added a test so we'll be alerted if a bug like this occurs again. Thanks for the report!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings