dapp 0.35.34 → 0.35.35

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
  SHA256:
3
- metadata.gz: 75df26997563b6ea7d45457b94ad70d4dfe8b0574b06ae3a8b16b282bb8f8612
4
- data.tar.gz: 950507212825affd8cab0a81da77203929acdc6469fb925099fb05d7f6accbbf
3
+ metadata.gz: 962963230c35adae042eb0857ac0680679dc693df4f07de532fed95711b0a7c9
4
+ data.tar.gz: 5ce37d21f2b25fcf16fddbc6fc2ee6a03bf7f51f8634161497d5484d64b61c06
5
5
  SHA512:
6
- metadata.gz: d2f58525f3883f00f85e8de17bc3597a22653cf6c564b27516107a34fe8f6e705517a1cec01181fd2699c405c57c7e2436956bfd20ec93df9ddf22a14bbe55ab
7
- data.tar.gz: 6d9670547b1bad6792fd6895dd8c528240f70442ccaa9a8ed95d1fae06bbadb2bd197d009a2d883da0ebde605a43eac462217ffb272286760d45675895460409
6
+ metadata.gz: 985aff68a55fb1f36035d495917643e72a85facf352551e84ac463187d8532c2c1ac889e8e26974b72d51c938b512d55ea919f72e6f7e6ee970e021b7fbd9a2a
7
+ data.tar.gz: 6f9d1df209449b7d35a126798ce87baa47aedde309eb43014f8badd72e1c0272b2d443e73be50b00d529243c4e0cc09591b9ee1a2c772be9b17fa39ba00fa9bd
data/bin/dapp CHANGED
@@ -53,7 +53,8 @@ def set_gitlab_cancel_handler
53
53
 
54
54
  parents_pids.each do |pid|
55
55
  if not process_alive? pid
56
- File.open(File.join(ENV["HOME"], ".dapp", "cancelled"), "a") do |file|
56
+ home_dir = (ENV["DAPP_HOME"] || File.join(ENV["HOME"], ".dapp"))
57
+ File.open(File.join(home_dir, "cancelled"), "a") do |file|
57
58
  file.write "#{Process.pid}\n"
58
59
  end
59
60
 
@@ -180,7 +180,7 @@ module Dapp
180
180
 
181
181
  class << self
182
182
  def home_dir
183
- File.join(Dir.home, ".dapp")
183
+ ENV["DAPP_HOME"] || File.join(Dir.home, ".dapp")
184
184
  end
185
185
 
186
186
  def options
@@ -1,6 +1,9 @@
1
1
  module Dapp
2
2
  class Dapp
3
3
  module Ruby2Go
4
+ class Error < ::Dapp::Error::Base
5
+ end
6
+
4
7
  def ruby2go_image(args_hash)
5
8
  _ruby2go("image", args_hash)
6
9
  end
@@ -33,8 +36,8 @@ module Dapp
33
36
  _ruby2go("slug", args_hash)
34
37
  end
35
38
 
36
- def ruby2go_deploy_watcher(args_hash)
37
- _ruby2go("deploy-watcher", args_hash)
39
+ def ruby2go_deploy_watcher(args_hash, **kwargs)
40
+ _ruby2go("deploy-watcher", args_hash, **kwargs)
38
41
  end
39
42
 
40
43
  def ruby2go_init
@@ -47,13 +50,15 @@ module Dapp
47
50
  "DAPP_BIN_#{progname.gsub("-", "_").upcase}"
48
51
  end
49
52
 
50
- def _ruby2go(progname, args_hash)
53
+ def _ruby2go(progname, args_hash, tmp_dir: nil)
54
+ tmp_dir = _ruby2go_tmp_dir if tmp_dir.nil?
55
+
51
56
  call_id = SecureRandom.uuid
52
57
 
53
- args_file = File.join(_ruby2go_tmp_dir, "args.#{call_id}.json")
58
+ args_file = File.join(tmp_dir, "args.#{call_id}.json")
54
59
  File.open(args_file, "w") {|f| f.write JSON.dump(args_hash)}
55
60
 
56
- res_file = File.join(_ruby2go_tmp_dir, "res.#{call_id}.json")
61
+ res_file = File.join(tmp_dir, "res.#{call_id}.json")
57
62
 
58
63
  if bin_path = ENV[_ruby2go_bin_path_env_var_name(progname)]
59
64
  unless File.exists? bin_path
@@ -84,7 +89,7 @@ module Dapp
84
89
  File.open(res_file, "r") {|f| res = JSON.load(f.read)}
85
90
  res
86
91
  else
87
- raise ::Dapp::Error::Base, code: :ruby2go_command_unexpected_exitstatus, data: { progname: progname, status_code: status_code }
92
+ raise ::Dapp::Dapp::Ruby2Go::Error, code: :ruby2go_command_unexpected_exitstatus, data: { progname: progname, status_code: status_code }
88
93
  end
89
94
  end
90
95
 
@@ -155,6 +155,7 @@ module Dapp
155
155
  watch_hooks_condition_mutex = ::Mutex.new
156
156
  watch_hooks_condition = ::ConditionVariable.new
157
157
  deploy_has_began = false
158
+
158
159
  unless dry_run? and watch_hooks.any?
159
160
  watch_hooks_thr = Thread.new do
160
161
  watch_hooks_condition_mutex.synchronize do
@@ -168,13 +169,30 @@ module Dapp
168
169
  begin
169
170
  if ENV["KUBEDOG"] != "0"
170
171
  timeout = self.options[:timeout] || 300
171
- res = ruby2go_deploy_watcher(
172
- "action" => "watch job",
173
- "resourceName" => job.name,
174
- "namespace" => release.namespace,
175
- "timeout" => timeout,
176
- "logsFromTime" => kube_deploy_start_time
177
- )
172
+ tmp_dir = Dir.mktmpdir('dapp-ruby2go-', tmp_base_dir)
173
+ res = nil
174
+
175
+ begin
176
+ res = ruby2go_deploy_watcher(
177
+ {
178
+ "action" => "watch job",
179
+ "resourceName" => job.name,
180
+ "namespace" => release.namespace,
181
+ "timeout" => timeout,
182
+ "logsFromTime" => kube_deploy_start_time
183
+ },
184
+ tmp_dir: tmp_dir,
185
+ )
186
+ rescue ::Dapp::Dapp::Ruby2Go::Error => err
187
+ # ignore interrupt
188
+ if err.net_status[:data][:status_code] == 17
189
+ res = {}
190
+ else
191
+ raise
192
+ end
193
+ ensure
194
+ FileUtils.rmtree(tmp_dir)
195
+ end
178
196
 
179
197
  if res["error"]
180
198
  $stderr.puts(::Dapp::Dapp.paint_string(::Dapp::Helper::NetStatus.message(res["error"]), :warning))
@@ -196,7 +214,6 @@ module Dapp
196
214
  # ошибку для информации пользователю без завершения работы dapp.
197
215
  $stderr.puts(::Dapp::Dapp.paint_string(::Dapp::Helper::NetStatus.message(e), :warning))
198
216
  end
199
-
200
217
  end # Thread
201
218
  end # unless
202
219
 
@@ -218,6 +235,8 @@ module Dapp
218
235
  release.install_helm_release
219
236
  end
220
237
 
238
+ watch_hooks_thr.join if !dry_run? && watch_hooks_thr && watch_hooks_thr.alive?
239
+
221
240
  if cmd_res.error?
222
241
  if cmd_res.stderr.end_with? "has no deployed releases\n"
223
242
  log_warning "[WARN] Helm release #{release.name} is in improper state: #{cmd_res.stderr}"
@@ -229,8 +248,6 @@ module Dapp
229
248
  raise ::Dapp::Error::Command, code: :kube_helm_failed, data: {output: (cmd_res.stdout + cmd_res.stderr).strip}
230
249
  else
231
250
  kube_delete_helm_auto_purge_trigger_file(release.name)
232
-
233
- watch_hooks_thr.join if !dry_run? && watch_hooks_thr && watch_hooks_thr.alive?
234
251
  log_info((cmd_res.stdout + cmd_res.stderr).strip)
235
252
  end
236
253
  end
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = "0.35.34"
2
+ VERSION = "0.35.35"
3
3
  BUILD_CACHE_VERSION = 33
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.34
4
+ version: 0.35.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov