terraform-provider-docker icon indicating copy to clipboard operation
terraform-provider-docker copied to clipboard

Can't set size_bytes in tmpfs_options on docker_service mount

Open JanKoppe opened this issue 2 years ago • 2 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and docker Provider) Version

Terraform v1.4.6 on linux_amd64

  • provider registry.terraform.io/kreuzwerker/docker v3.0.2

Affected Resource(s)

  • docker_service

Terraform Configuration Files

terraform {
  required_version = "~>1.0"

  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "~>3.0"
    }
  }
}

provider "docker" {}

resource "docker_service" "primary" {
  name = "foobar"
  task_spec {
    container_spec {
      image = "busybox"
      mounts {
        target = "/dev/shm"
        type   = "tmpfs"
        tmpfs_options {
          mode       = 644
          size_bytes = 256 * 1024 * 1024 # 256 MBytes
        }
      }
    }
  }
}

Debug Output

https://gist.github.com/JanKoppe/d93bf3ef99103f7b76e3461f8d1260ae

Panic Output

Expected Behaviour

Docker service with the requested tmpfs mount should have been created

Actual Behaviour

Terraform will finish the plan step, but crash in the apply step. No resources are created.

Steps to Reproduce

  1. terraform apply

Important Factoids

A quick glance at the code shows a discrepancy between data types used here:

https://github.com/kreuzwerker/terraform-provider-docker/blob/master/internal/provider/resource_docker_service_structures.go#L835

and here:

https://github.com/kreuzwerker/terraform-provider-docker/blob/master/internal/provider/resource_docker_service_structures.go#L256

I believe the first one should be changed to int as well. I'd like to offer trying to work on a fix for this.

References

  • #0000

JanKoppe avatar Jun 12 '23 06:06 JanKoppe