hashicorp / terraform-provider-kubernetes

Terraform Kubernetes provider
https://www.terraform.io/docs/providers/kubernetes/
Mozilla Public License 2.0
1.6k stars 979 forks source link

kubernetes_manifest with pod and volume: inconsistent result after apply #2326

Open iluminae opened 1 year ago

iluminae commented 1 year ago

Terraform Version, Provider Version and Kubernetes Version

Terraform version: v1.4.6
Kubernetes provider version: v2.23.0
Kubernetes version: v1.26.4

Affected Resource(s)

Terraform Configuration Files

resource "kubernetes_manifest" "test" {
  manifest = {
    apiVersion = "v1"
    kind       = "Pod"
    metadata = {
      name      = "test"
      namespace = "default"
    }
    spec = {
      containers = [{
        name    = "test"
        image   = "docker.io/library/busybox:latest"
        command = ["busybox", "sh", "-c", "sleep inf"]
        volumeMounts = [{
          name      = "test"
          mountPath = "/test"
        }]
      }]
      volumes = [{
        name     = "test"
        emptyDir = {}
      }]
    }
  }
}

Debug Output

I will post this if you really need it but I think its entirely reproducible and its hard to capture that incredibly verbose output.

Panic Output

n/a

Steps to Reproduce

  1. terraform apply the above repro

Expected Behavior

pod created and terraform happy

Actual Behavior

pod created and terraform unhappy

kubernetes_manifest.test: Creating...
2023-10-20T17:45:07.584-0400 [INFO]  Starting apply for kubernetes_manifest.test
2023-10-20T17:45:07.584-0400 [DEBUG] skipping FixUpBlockAttrs
2023-10-20T17:45:07.584-0400 [DEBUG] kubernetes_manifest.test: applying the planned Create change
2023-10-20T17:45:08.841-0400 [ERROR] vertex "kubernetes_manifest.test" error: Provider produced inconsistent result after apply
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to kubernetes_manifest.test, provider "provider[\"registry.terraform.io/hashicorp/kubernetes\"]" produced an unexpected new value: .object: wrong final value type: attribute "spec": attribute
│ "volumes": tuple required.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
2023-10-20T17:45:08.869-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-10-20T17:45:08.876-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/kubernetes/2.23.0/darwin_amd64/terraform-provider-kubernetes_v2.23.0_x5 pid=70337
2023-10-20T17:45:08.876-0400 [DEBUG] provider: plugin exited

Important Factoids

References

Community Note

shanmugara commented 1 year ago

same issue here. though the pod is getting created, and I am able to update the pod with an additional volume as well. each time it throws the error, but the pod seems to getting created and updated correctly.

shanmugara commented 1 year ago

Some additional info that might help. This seems to be caused by the ServiceAccount token auto mount under volumes. Adding an additional element to the list of volumes, confusing the provider. Setting automountServiceAccountToken: false works happily without any errors.

github-actions[bot] commented 3 weeks ago

Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!