kitchen-dokken 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c26ed0d4c8e3da6089281d6c056e1662367f49f2
4
- data.tar.gz: 380947f45341c322ba707baaec7642f62a8707b7
3
+ metadata.gz: e7e868c670043800eaf336e14a7e9de341e5cb89
4
+ data.tar.gz: 5a0276d5f8c05c06692396d2b0e6f0af0e18e36d
5
5
  SHA512:
6
- metadata.gz: 48e341852380317b136962664e0195ec0c93a07cec50f79e8d263ad549bc5a377c2674e88fa087c40b030b3c3eac437b5b0935d6d1a91fbb468465814a8cbbca
7
- data.tar.gz: 84d126bc3bd5ba32578b1e44b310066cfac3ff19ecfbfd108f9063c5708699a6d0be65a8171b453d8726e0690bef33522549a06255511faa7940b50002c61b69
6
+ metadata.gz: 75f61c6b4e1cbbb54dda5c4b848be4502c375acb0886cd59fe713174394164a4431f1d1661b20b63a9f69fc3c64f951bc6a15d176e660f9c844adb1150364d63
7
+ data.tar.gz: ac7c8282311b04de0e7c7027cab12002b2c3b42f1cc3354afaf15801ed27de65019cdd8711c49669e9e5d02c7fe18290f32cc6840ee59d4c8c96e2e77bddd856
@@ -80,8 +80,8 @@ module Kitchen
80
80
 
81
81
  def delete_work_image
82
82
  return unless Docker::Image.exist?(work_image, docker_connection)
83
- i = Docker::Image.get(work_image, docker_connection)
84
- i.remove(force: true)
83
+ with_retries { @work_image = Docker::Image.get(work_image, docker_connection) }
84
+ with_retries { @work_image.remove(force: true)}
85
85
  end
86
86
 
87
87
  def build_work_image(state)
@@ -90,8 +90,8 @@ module Kitchen
90
90
  FileUtils.mkdir_p context_root
91
91
  File.write("#{context_root}/Dockerfile", work_image_dockerfile)
92
92
 
93
- i = Docker::Image.build_from_dir(context_root, { 'nocache' => true, 'rm' => true }, docker_connection)
94
- i.tag('repo' => repo(work_image), 'tag' => tag(work_image), 'force' => true)
93
+ with_retries { @work_image = Docker::Image.build_from_dir(context_root, { 'nocache' => true, 'rm' => true }, docker_connection) }
94
+ with_retries { @work_image.tag('repo' => repo(work_image), 'tag' => tag(work_image), 'force' => true) }
95
95
  state[:work_image] = work_image
96
96
  end
97
97
 
@@ -102,7 +102,7 @@ module Kitchen
102
102
 
103
103
  def work_image_dockerfile
104
104
  from = "FROM #{platform_image}"
105
- custom = [ 'RUN /bin/sh -c "echo Built with Test Kitchen"' ]
105
+ custom = ['RUN /bin/sh -c "echo Built with Test Kitchen"']
106
106
  Array(config[:intermediate_instructions]).each { |c| custom << c }
107
107
  [from, custom].join("\n")
108
108
  end
@@ -211,28 +211,21 @@ module Kitchen
211
211
 
212
212
  def delete_image(name)
213
213
  i = Docker::Image.get(name, docker_connection)
214
- i.remove(force: true)
214
+ with_retries { i.remove(force: true) }
215
215
  rescue Docker::Error => e
216
216
  puts "Image #{name} not found. Nothing to delete."
217
217
  end
218
218
 
219
219
  def run_container(args)
220
220
  c = create_container(args)
221
- tries ||= 3
222
- begin
223
- c.start
224
- return c
225
- rescue Docker::Error => e
226
- retry unless (tries -= 1).zero?
227
- raise e.message
228
- end
221
+ with_retries { c.start }
229
222
  end
230
223
 
231
224
  def delete_container(name)
232
225
  c = Docker::Container.get(name, docker_connection)
233
226
  puts "Destroying container #{name}."
234
- c.stop
235
- c.delete(force: true, v: true)
227
+ with_retries { c.stop(force: true) }
228
+ with_retries { c.delete(force: true, v: true) }
236
229
  rescue
237
230
  puts "Container #{name} not found. Nothing to delete."
238
231
  end
@@ -258,11 +251,7 @@ module Kitchen
258
251
  end
259
252
 
260
253
  def pull_image(image)
261
- retries ||= 3
262
- Docker::Image.create({ 'fromImage' => repo(image), 'tag' => tag(image) }, docker_connection)
263
- rescue Docker::Error => e
264
- retry unless (tries -= 1).zero?
265
- raise e.message
254
+ with_retries { Docker::Image.create({ 'fromImage' => repo(image), 'tag' => tag(image) }, docker_connection) }
266
255
  end
267
256
 
268
257
  def pull_if_missing(image)
@@ -297,6 +286,22 @@ module Kitchen
297
286
  def runner_container_name
298
287
  "#{instance.name}"
299
288
  end
289
+
290
+ def with_retries(&block)
291
+ tries = 5
292
+ begin
293
+ block.call
294
+ # Only catch errors that can be fixed with retries.
295
+ rescue Docker::Error::ServerError, # 404
296
+ Docker::Error::UnexpectedResponseError, # 400
297
+ Docker::Error::TimeoutError,
298
+ Docker::Error::IOError => e
299
+ tries -= 1
300
+ puts "SEANDEBUG - :#{e}:"
301
+ retry if tries > 0
302
+ raise e
303
+ end
304
+ end
300
305
  end
301
306
  end
302
307
  end
@@ -19,6 +19,6 @@
19
19
  module Kitchen
20
20
  module Driver
21
21
  # Version string for Dokken Kitchen driver
22
- DOKKEN_VERSION = '0.0.8'
22
+ DOKKEN_VERSION = '0.0.9'
23
23
  end
24
24
  end
@@ -63,7 +63,7 @@ module Kitchen
63
63
  return if command.nil?
64
64
 
65
65
  runner = Docker::Container.get(instance_name, {}, docker_connection)
66
- o = runner.exec(Shellwords.shellwords(command)) { |stream, chunk| print "#{chunk}" }
66
+ o = runner.exec(Shellwords.shellwords(command)) { |_stream, chunk| print "#{chunk}" }
67
67
  exit_code = o[2]
68
68
 
69
69
  if exit_code != 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-dokken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean OMeara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-18 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen