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

converged_if_changed triggered on empty property #828

Open
chasebolt opened this issue Feb 18, 2017 · 6 comments
Open

converged_if_changed triggered on empty property #828

chasebolt opened this issue Feb 18, 2017 · 6 comments

Comments

@chasebolt
Copy link
Contributor

working_dir says it is being set to an empty string, though it is not defined as a property, causing converge_if_changed to run and updating the container. interesting bit is docker inspect shows the working_dir was not actually set to an empty string. expected result is docker run to immediately return with no action needed after the redeploy.

docker_image 'uchiwa/uchiwa' do
  notifies :redeploy, 'docker_container[uchiwa]', :immediately
end

docker_container 'uchiwa' do
  repo 'uchiwa/uchiwa'
  tag 'latest'
  port '3000:3000'
end
  * docker_image[uchiwa/uchiwa] action pull
    - Pull image uchiwa/uchiwa:latest
  * docker_container[uchiwa] action redeploy
    - create uchiwa
    -   set container_name              to "uchiwa" (default value)
    -   set repo                        to "uchiwa/uchiwa"
    -   set tag                         to "latest"
    -   set command                     to nil (default value)
    -   set cap_add                     to nil (default value)
    -   set cap_drop                    to nil (default value)
    -   set cgroup_parent               to "" (default value)
    -   set cpu_shares                  to 0 (default value)
    -   set cpuset_cpus                 to "" (default value)
    -   set devices                     to [] (default value)
    -   set dns                         to [] (default value)
    -   set dns_search                  to [] (default value)
    -   set domain_name                 to "" (default value)
    -   set entrypoint                  to nil (default value)
    -   set env                         to [] (default value)
    -   set extra_hosts                 to nil (default value)
    -   set exposed_ports               to {"3000/tcp"=>{}}
    -   set hostname                    to nil (default value)
    -   set ipc_mode                    to "" (default value)
    -   set labels                      to {} (default value)
    -   set links                       to nil (default value)
    -   set ip_address                  to nil (default value)
    -   set mac_address                 to nil (default value)
    -   set memory                      to 0 (default value)
    -   set memory_swap                 to 0 (default value)
    -   set network_disabled            to false (default value)
    -   set network_mode                to "bridge"
    -   set outfile                     to nil (default value)
    -   set port_bindings               to {"3000/tcp"=>[{"HostIp"=>"0.0.0.0", "HostPort"=>"3000"}]}
    -   set pid_mode                    to "" (default value)
    -   set privileged                  to false (default value)
    -   set publish_all_ports           to false (default value)
    -   set remove_volumes              to false (default value)
    -   set restart_maximum_retry_count to 0 (default value)
    -   set restart_policy              to nil (default value)
    -   set ro_rootfs                   to false (default value)
    -   set security_opts               to nil (default value)
    -   set signal                      to "SIGTERM" (default value)
    -   set sysctls                     to {} (default value)
    -   set tty                         to false (default value)
    -   set ulimits                     to nil (default value)
    -   set user                        to "" (default value)
    -   set userns_mode                 to "" (default value)
    -   set uts_mode                    to "" (default value)
    -   set volumes                     to {} (default value)
    -   set volumes_from                to nil (default value)
    -   set volume_driver               to nil (default value)
    -   set working_dir                 to "" (default value)
    -   set volumes_binds               to nil (default value)
    - starting uchiwa
  * docker_container[uchiwa] action run
    - deleting uchiwa
    - update uchiwa
    -   set working_dir to "" (was "/go/src/github.com/sensu/uchiwa")
    - starting uchiwa
@jondoe1337
Copy link

jondoe1337 commented May 23, 2017

Can confirm this for the case that an ip_address is set.

In the recipe docker_container.rb there is already a workaround mentioned in line 151:
# these are a special case for us because our names differ from theirs

We fixed it by adding the following lines after 155:

ip_address container.info['NetworkSettings']['Networks'][network_mode]['IPAMConfig']['IPv4Address'] if
  container.info['NetworkSettings'] &&
  container.info['NetworkSettings']['Networks'] &&
  container.info['NetworkSettings']['Networks'][network_mode] &&
  container.info['NetworkSettings']['Networks'][network_mode]['IPAMConfig']  &&
  container.info['NetworkSettings']['Networks'][network_mode]['IPAMConfig']['IPv4Address']

@s-bernard
Copy link
Contributor

I confirm the ip_address bug which is very annoying.

@chasebolt
Copy link
Contributor Author

ip_address bug should be resolved in v2.16.2

@jondoe1337
Copy link

jondoe1337 commented Apr 17, 2018

Still happening with ip_address in version 4.2.0.

@vorezal
Copy link

vorezal commented Jan 25, 2019

Just in case anyone else finds this, it looks like the ip_address issue is due to the docker-api gem using a version of the docker Engine API that is too old and does not return anything for container.info['NetworkSettings']['Networks']. Until that is updated to at least 1.21 or different logic is included here to bypass the limitation setting a static ip address for docker containers will not be recognized on subsequent chef-client runs.

@rmoriz
Copy link
Contributor

rmoriz commented Jun 18, 2020

This also affects memory_swap and user when using chef-client v16. Interestingly it worked with chef 14 for unknown reasons (no re-creation of containers on each converge).

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

No branches or pull requests

7 participants