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

fix docker custom configuration #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

juwit
Copy link
Contributor

@juwit juwit commented Jan 3, 2025

Problem

When using a clevercloud_docker resource, environment variables are automatically added to the Docker App.

For example, with the following simple code :

resource "clevercloud_docker" "docker_instance" {
  name = "docker_instance"
  region = "par"
  # horizontal scaling
  min_instance_count = 1
  max_instance_count = 2
  # vertical scaling
  smallest_flavor = "XS"
  biggest_flavor  = "M"
}

The following env-vars are automatically added by the provider :

image

The CC_DOCKER_FIXED_CIDR_V6 is set to false, as it should be a CIDR.

This bad configuration prevents applications to start with the following logs :

We are now in /home/bas/app_4905572e-fd59-4f8a-ad1d-4718ad29179e, let's build and run the app.
Deploying commit ID 16ae8295732a77cb708c908abba6b9e95f1ae3ef
Error: malformed fixed_cidr_v6 address
Deploy failed

This issue as already been found in #87.

workaround

To address this issue, overriding the environment variable with null in the Terraform configuration works, but is an ugly workaround :

resource "clevercloud_docker" "docker_instance" {
  ...
  environment = {
     CC_DOCKER_FIXED_CIDR_V6 = null
  }
}

By doing so, the provider doesn't set the environment variable

best solution

It seems that the argument named enable_ipv6 is named badly, or does not work as expected.
I'm not sure whether this argument should be renamed or if the underlying code should be rewritten, but this will need some work

proposed solution

This PR proposes to simply remove the default values for arguments that occur an env var to be set, so no defaut env var is added.
This will allow the simple use-cases to work, and will also allow these values to be set.

This works well as the provider code checks wether the argument has a value before addin the env var :

pkg.IfIsSetB(p.EnableIPv6, func(e bool) { env["CC_DOCKER_FIXED_CIDR_V6"] = strconv.FormatBool(e) })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants