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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bacb04ce73c020022800976bb73ed93889a9cddb
4
- data.tar.gz: ccda73ee5de4c0409ebaaad8c62606db31ed52b4
3
+ metadata.gz: d6db975f50f90cf847c61c52623517c7d596efb0
4
+ data.tar.gz: 5ff09558f9547141d31782b9538b242583518170
5
5
  SHA512:
6
- metadata.gz: b932eb19ed1f361724190a35dd18008dd0cfb90b77f919f626041beb28176aac7642bb09264443d11ca57d49daeb7e574899704aab626f9f48ed6b0f09e7efd8
7
- data.tar.gz: 5a7bb932b1d29e098f89ed805ebbbdae46bbd31d6551631694eb228b329b38c458931daa1465f4614d47b0385e0aca3552c3e02309c089b11254a6bdffc778e9
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 { @work_image = Docker::Image.build_from_dir(context_root, { 'nocache' => true, 'rm' => true }, docker_connection) }
99
- with_retries { @work_image.tag('repo' => repo(work_image), 'tag' => tag(work_image), 'force' => true) }
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
 
@@ -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.12'
22
+ DOKKEN_VERSION = '0.0.13'
23
23
  end
24
24
  end
@@ -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
- o = runner.exec(Shellwords.shellwords(command)) { |_stream, chunk| print "#{chunk}" }
67
- exit_code = o[2]
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-dokken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean OMeara