Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Adding tolerations causes plan failure with error AttributeName("tolerationSeconds"): step cannot be applied to this value #251

@soulshake

Description

@soulshake

Terraform, Provider, Kubernetes versions

Terraform version: v0.15.5
Provider version: v0.5.0
Kubernetes version: v1.21.1 (client), v1.20.4-eks-6b7464 (server)

Affected Resource(s)

  • kubernetes_manifest

Terraform Configuration Files

resource "kubernetes_manifest" "runner" {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  provider = kubernetes-alpha
 
  manifest = {
    apiVersion = "apps/v1"
    kind       = "Deployment"
    metadata = {
      name      = "test"
      namespace = "default"
    }
    spec = {
      selector = {
        matchLabels = {
          app = "example"
        }
      }
 
      template = {
        metadata = {
          labels = {
            app = "example"
          }
        }
 
        spec = {
          containers = [
            {
              image   = "alpine:latest"
              name    = "ping"
              command = ["sh", "-c"]
              args    = ["ping goo.gl"]
            }
          ]
          # causes planning to fail if added after the resource exists
          tolerations = [
            {
              effect   = "NoSchedule"
              key      = "nvidia.com/gpu"
              operator = "Exists"
            },
          ]
        }
      }
    }
  }
}
Provider config
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.46.0"
    }
    kubernetes-alpha = {
      source  = "hashicorp/kubernetes-alpha"
      version = ">= 0.5.0"
    }
  }
}
 
provider "aws" {
  region = "us-east-2"
}
 
provider "kubernetes-alpha" {
  host                   = data.aws_eks_cluster.target.endpoint
  cluster_ca_certificate = base64decode(data.aws_eks_cluster.target.certificate_authority.0.data)
  token                  = data.aws_eks_cluster_auth.target.token
}
 
data "aws_eks_cluster" "target" {
  name = "ci-apps"
}
 
data "aws_eks_cluster_auth" "target" {
  name = data.aws_eks_cluster.target.name
}

Debug Output

https://gist.github.com/soulshake/180f8264a7d89c70d929cf05585b8281

Panic Output

Steps to Reproduce

# first apply without tolerations
terraform apply
# then add tolerations and try to plan
terraform plan

Expected Behavior

The tolerations should be successfully planned/added.

Actual Behavior

Planning and applying when the resource has not yet been created is successful.

However, trying to add tolerations on an existing resource fails with an error: AttributeName("tolerationSeconds"): step cannot be applied to this value:

$ terraform plan
kubernetes_manifest.runner: Refreshing state...
╷
│ Error: Failed to update proposed state from prior state
│ 
│   with kubernetes_manifest.runner,
│   on main.tf line 32, in resource "kubernetes_manifest" "runner":
│   32: resource "kubernetes_manifest" "runner" {
│ 
│ AttributeName("spec").AttributeName("template").AttributeName("spec").AttributeName("tolerations").ElementKeyInt(0).AttributeName("tolerationSeconds"): step cannot be applied to this value

Observations:

  • If I delete the deployment, I'm able to plan and apply successfully.

Important Factoids

n/a

References

n/a

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions