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

provider/docker: Add support for multiple docker_image pull_triggers #10843

Closed
hmcgonig opened this issue Dec 19, 2016 · 2 comments
Closed

provider/docker: Add support for multiple docker_image pull_triggers #10843

hmcgonig opened this issue Dec 19, 2016 · 2 comments

Comments

@hmcgonig
Copy link
Contributor

hmcgonig commented Dec 19, 2016

Terraform Version

0.7.13

Affected Resource(s)

Please list the resources as a list, for example:

  • docker_image

Terraform Configuration Files

data "docker_registry_image" "elasticsearch" {
  name = "elasticsearch:latest"
}

resource "docker_image" "elasticsearch" {
  keep_locally = true
  name = "${data.docker_registry_image.elasticsearch.name}"
  pull_trigger = "${data.docker_registry_image.elasticsearch.sha256_digest}"
}

Currently, the above will pull the elasticsearch image into every host in my docker swarm cluster. In my environment I have found that when scaling up my docker swarm, I have no way to trigger another docker_image.elasticsearch pull so that my new swarm node gets an ES image. Currently, the workaround is that I would have to taint this resource to get it on my new node. Alternatively I can interpolate the cluster size and sha256 together.

I'm proposing support for something like this:

data "docker_registry_image" "elasticsearch" {
  name = "elasticsearch:latest"
}

resource "docker_image" "elasticsearch" {
  keep_locally = true
  name = "${data.docker_registry_image.elasticsearch.name}"
  pull_triggers = ["${data.docker_registry_image.elasticsearch.sha256_digest}", "${var.swarm_size}"]
}

So pull_trigger becomes a list called pull_triggers so that image pulls can be invoked by state changes other than just sha changes.

The other change required is that currently when pulling images, the docker provider first checks to see which images are already pulled, then if the image you want is not pulled, it pulls it. When using swarm, while setting up a new swarm host, terraform will not pull existing images onto new hosts, because those same images already exist on some nodes of the cluster already. The simplest fix I can see is to remove this check that sees if an image is already pulled. Pulling an image that you already have just results in a no-op with the side-effect that new swarm hosts will now also download the image as needed.

Later today I'll be throwing together a PR for this enhancement since it should be a very easy change, but I just wanted to get an issue out there for tracking. Thanks!

@stack72
Copy link
Contributor

stack72 commented Jan 3, 2017

Closed via #10845

@stack72 stack72 closed this as completed Jan 3, 2017
@ghost
Copy link

ghost commented Apr 18, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants