From f6de73cf476a5ee3a8e8ef0aac1d64ad77781a81 Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Sun, 6 Dec 2020 13:47:28 -0500 Subject: [PATCH] Temporarily use .all instead of .get to fetch containers Signed-off-by: Clinton Wolfe --- lib/kitchen/driver/dokken.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/kitchen/driver/dokken.rb b/lib/kitchen/driver/dokken.rb index 4030583..b59158e 100644 --- a/lib/kitchen/driver/dokken.rb +++ b/lib/kitchen/driver/dokken.rb @@ -368,8 +368,16 @@ def create_chef_container(state) lockfile = Lockfile.new "#{home_dir}/.dokken-#{chef_container_name}.lock" begin lockfile.lock - with_retries { ::Docker::Container.get(chef_container_name, {}, docker_connection) } + with_retries { + # TEMPORARY FIX - docker-api 2.0.0 has a buggy Docker::Container.get - use .all instead + # https://github.com/swipely/docker-api/issues/566 + # ::Docker::Container.get(chef_container_name, {}, docker_connection) + found = ::Docker::Container.all({all: true}, docker_connection).select { |c| c.info["Names"].include?("/#{chef_container_name}") } + raise ::Docker::Error::NotFoundError.new(chef_container_name) if found.empty? + debug "Chef container already exists, continuing" + } rescue ::Docker::Error::NotFoundError + debug "Chef container does not exist, creating a new Chef container" with_retries do begin debug "driver - creating volume container #{chef_container_name} from #{chef_image}"