puppetlabs-docker icon indicating copy to clipboard operation
puppetlabs-docker copied to clipboard

*_docker_params_changed is not handling/parsing paths/names/destinations correctly

Open bmagistro opened this issue 3 years ago • 0 comments

The *_docker_params_changed is triggering on sequential puppet runs when nothing should have changed resulting in a container restarting every puppet run.

I believe this is very much related to #781 but didn't want to piggy back as that one seems to be discussing issues related to ports/networking and in our case I have narrowed this one down to a different aspect.

Environment

CentOS 7.9 Puppet 6.28.0

  • docker mod 6.0.2 docker 20.10.17

Working backwards on the list of detected changes. will also preface with I don't do much with ruby so approaches to fix/descriptions may not be ideal.

destinations (https://github.com/puppetlabs/puppetlabs-docker/blob/main/lib/puppet/functions/docker_params_changed.rb#L119) is failing due to the destination map built (https://github.com/puppetlabs/puppetlabs-docker/blob/main/lib/puppet/functions/docker_params_changed.rb#L113) using the wrong index. In our data (a hash) index 3 maps to the key Mode while index 2 maps to the key Destination. To allow position variability it seems like this needs to do the lookup by key instead of by index.

names (https://github.com/puppetlabs/puppetlabs-docker/blob/main/lib/puppet/functions/docker_params_changed.rb#L119) is failing due to a strict order in the comparison of the arrays. This is most easily addressed by adding a .sort on the comparison. It seems like this should be able to be addressed before the comparison when the revised names is defined (https://github.com/puppetlabs/puppetlabs-docker/blob/main/lib/puppet/functions/docker_params_changed.rb#L112) but not sure how yet.

paths (https://github.com/puppetlabs/puppetlabs-docker/blob/main/lib/puppet/functions/docker_params_changed.rb#L108) is failing because it is comparing an empty array (pp_paths) to a non-empty array (inspect_paths). I haven't dug into this one enough yet to provide a better root cause.

bmagistro avatar Dec 13 '22 04:12 bmagistro