kitchen-dokken 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/dokken.rb +18 -2
- data/lib/kitchen/driver/dokken_version.rb +1 -1
- data/lib/kitchen/transport/dokken.rb +26 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6db975f50f90cf847c61c52623517c7d596efb0
|
4
|
+
data.tar.gz: 5ff09558f9547141d31782b9538b242583518170
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5898ca693aab9b8122668458580032751148cf404f718d8c03d3a8941a6ab4f4f519037c34022719d89f35f5c85858034eab55ad0e6e4f4a09fa04b49116c357
|
7
|
+
data.tar.gz: 5867030831ed974e2ee63d69925c92f8da0bb27092bd5af747293b4d90aa80e390a7bab53f183e9efae8027b687657837f0140063e99b959d0d86e87fc5af825
|
@@ -95,8 +95,24 @@ module Kitchen
|
|
95
95
|
FileUtils.mkdir_p context_root
|
96
96
|
File.write("#{context_root}/Dockerfile", work_image_dockerfile)
|
97
97
|
|
98
|
-
with_retries
|
99
|
-
|
98
|
+
with_retries do
|
99
|
+
begin
|
100
|
+
@work_image = Docker::Image.build_from_dir(
|
101
|
+
context_root,
|
102
|
+
{ 'nocache' => true, 'rm' => true },
|
103
|
+
docker_connection
|
104
|
+
)
|
105
|
+
rescue
|
106
|
+
puts "SEANDEBUG: EXPLOSIONS"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
with_retries do
|
111
|
+
@work_image.tag(
|
112
|
+
'repo' => repo(work_image),
|
113
|
+
'tag' => tag(work_image),
|
114
|
+
'force' => true)
|
115
|
+
end
|
100
116
|
state[:work_image] = work_image
|
101
117
|
end
|
102
118
|
|
@@ -62,23 +62,25 @@ module Kitchen
|
|
62
62
|
def execute(command)
|
63
63
|
return if command.nil?
|
64
64
|
|
65
|
-
runner = Docker::Container.get(instance_name, {}, docker_connection)
|
66
|
-
|
67
|
-
|
65
|
+
with_retries { @runner = Docker::Container.get(instance_name, {}, docker_connection) }
|
66
|
+
with_retries do
|
67
|
+
o = @runner.exec(Shellwords.shellwords(command)) { |_stream, chunk| print "#{chunk}" }
|
68
|
+
@exit_code = o[2]
|
69
|
+
end
|
68
70
|
|
69
|
-
if exit_code != 0
|
71
|
+
if @exit_code != 0
|
70
72
|
fail Transport::DockerExecFailed,
|
71
|
-
"Docker Exec (#{exit_code}) for command: [#{command}]"
|
73
|
+
"Docker Exec (#{@exit_code}) for command: [#{command}]"
|
72
74
|
end
|
73
75
|
|
74
76
|
begin
|
75
77
|
old_image = Docker::Image.get(work_image, {}, docker_connection)
|
76
|
-
old_image.remove
|
78
|
+
with_retries { old_image.remove }
|
77
79
|
rescue
|
78
80
|
debug "#{work_image} not present. nothing to remove."
|
79
81
|
end
|
80
82
|
|
81
|
-
new_image = runner.commit
|
83
|
+
new_image = @runner.commit
|
82
84
|
new_image.tag('repo' => work_image, 'tag' => 'latest', 'force' => 'true')
|
83
85
|
end
|
84
86
|
|
@@ -115,8 +117,8 @@ module Kitchen
|
|
115
117
|
end
|
116
118
|
|
117
119
|
def login_command
|
118
|
-
runner = "#{options[:instance_name]}"
|
119
|
-
args = ['exec', '-it', runner, '/bin/bash', '-login', '-i']
|
120
|
+
@runner = "#{options[:instance_name]}"
|
121
|
+
args = ['exec', '-it', @runner, '/bin/bash', '-login', '-i']
|
120
122
|
LoginCommand.new('docker', args)
|
121
123
|
end
|
122
124
|
|
@@ -134,6 +136,21 @@ module Kitchen
|
|
134
136
|
def image_prefix
|
135
137
|
options[:image_prefix]
|
136
138
|
end
|
139
|
+
|
140
|
+
def with_retries(&block)
|
141
|
+
tries = 20
|
142
|
+
begin
|
143
|
+
block.call
|
144
|
+
# Only catch errors that can be fixed with retries.
|
145
|
+
rescue Docker::Error::ServerError, # 404
|
146
|
+
Docker::Error::UnexpectedResponseError, # 400
|
147
|
+
Docker::Error::TimeoutError,
|
148
|
+
Docker::Error::IOError => e
|
149
|
+
tries -= 1
|
150
|
+
retry if tries > 0
|
151
|
+
raise e
|
152
|
+
end
|
153
|
+
end
|
137
154
|
end
|
138
155
|
|
139
156
|
private
|