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

emptyDir with medium hugepages is not supported #2302

Closed
trunet opened this issue Sep 28, 2023 · 1 comment · Fixed by #2395
Closed

emptyDir with medium hugepages is not supported #2302

trunet opened this issue Sep 28, 2023 · 1 comment · Fixed by #2395
Labels

Comments

@trunet
Copy link

trunet commented Sep 28, 2023

As defined here:

ValidateFunc: validateAttributeValueIsIn([]string{"", "Memory"}),

I got when defining medium HugePages-2Mi:
│ Error: "spec.0.template.0.spec.0.volume.2.empty_dir.0.medium" must contain a value from []string{"", "Memory"}, got "HugePages-2Mi"

This is allowed as showed here: https://kubernetes.io/docs/tasks/manage-hugepages/scheduling-hugepages/

Terraform Version, Provider Version and Kubernetes Version

Terraform version: v1.5.7
Kubernetes provider version: v2.23.0
Kubernetes version: 1.28.2

Affected Resource(s)

  • kubernetes_deployment_v1

Terraform Configuration Files

resource "kubernetes_deployment_v1" "foo" {
  metadata {
    name      = "foo"
    namespace = "foo"

    labels = {
      "app.kubernetes.io/name" = "foo"
    }
  }

  spec {
    replicas = 1

    strategy {
      type = "Recreate"
    }

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

    template {
      metadata {
        labels = {
          "app.kubernetes.io/name" = "foo"
        }
      }

      spec {
        container {
          name              = "foo"
          image             = "alpine:latest"
          resources {
            requests = {
              hugepages-2Mi = "500Mi"
              memory = "500Mi"
            }
            limits = {
              hugepages-2Mi = "500Mi"
              memory = "1Gi"
            }
          }
          volume_mount {
            name      = "hugepages"
            mount_path = "/dev/hugepages"
          }
        }
        volume {
          name = "hugepages"
          empty_dir {
            medium = "HugePages-2Mi"
          }
        }
      }
    }
  }
}

Debug Output

Panic Output

Steps to Reproduce

  1. terraform apply

Expected Behavior

It should create /dev/hugepages

Actual Behavior

It fails to apply

Important Factoids

References

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
@trunet trunet added the bug label Sep 28, 2023
trunet added a commit to trunet/terraform-provider-kubernetes that referenced this issue Sep 28, 2023
@sheneska
Copy link
Contributor

Hi @trunet, The reason this is throwing an error is because implementing validateAttributeValueIsInAndContain in this way may be too imprecise as values that should match exactly might match as sub-strings and vice versa. Ideally the ValidateFunc should take two lists as arguments: one for exact matches and one for prefix (not sub-string) matches. For prefixes, it's good to ensure that they actually use prefix matches instead of strings.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants