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

docker_config_json does not work with bootstrap_env vars #1727

Closed
mustafa89 opened this issue Dec 21, 2021 · 2 comments · Fixed by #1680
Closed

docker_config_json does not work with bootstrap_env vars #1727

mustafa89 opened this issue Dec 21, 2021 · 2 comments · Fixed by #1680

Comments

@mustafa89
Copy link

mustafa89 commented Dec 21, 2021

Description

Passing docker_config_json results in the EKS node not being able to join the cluster. Caused because printf strips the slashes \ in the encoded json.

locals {
docker_config_json = <<JSON
  {
    "bridge": "none",
    "log-driver": "json-file",
    "log-opts": {
      "max-size": "10m",
      "max-file": "10"
    },
    "live-restore": true,
    "max-concurrent-downloads": 10
  }
JSON
}

replace strips the empty spaces.

jsonencode(replace(local.docker_config_json, "/[[:space:]]/", ""))

outputs:

"{\"bridge\":\"none\",\"log-driver\":\"json-file\",\"log-opts\":{\"max-size\":\"10m\",\"max-file\":\"10\"},\"live-restore\":true,\"max-concurrent-downloads\":10}"

When the above is passed to the userdata script.
printf strips the escapes, and export strips the quotes "" resulting in a malformed json object and docker service failing to start.

I've tried all the bash alchemy I know, If there is a way to accomplosh this where i could populate the json object properly in the environment, it would be very nice.

Removing the printf and replacing it with a cat heredoc file insertion could fix this I believe keeping the escaping intact and the export would then inject a properly formated json object in the environment.

⚠️ Note

  • Behavior was tested on bash shell. (behaves differently on zsh)
  • Tried without jsonencode. tried adding quotes to the json object inside the local as well.
  • Not using a custom AMI

Versions

Terraform: 0.13.6
Provider(s): AWS: 3.63.0
Module: 17.23.0

Reproduction

Add the following to the node group definition as well as the local defined in the description

 bootstrap_env = {
           DOCKER_CONFIG_JSON = jsonencode(replace(local.docker_config_json, "/[[:space:]]/", ""))
  }

EKS node won't be able to join the cluster. SSH in to the node and look insde /etc/docker/daemon.json we can see the malformed json.

@antonbabenko
Copy link
Member

This issue has been resolved in version 18.0.0 🎉

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants