barbeque 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/barbeque/exception_handler.rb +35 -9
- data/lib/barbeque/execution_poller.rb +3 -0
- data/lib/barbeque/executor/docker.rb +2 -2
- data/lib/barbeque/executor/hako.rb +2 -2
- data/lib/barbeque/retry_poller.rb +1 -0
- data/lib/barbeque/runner.rb +1 -0
- data/lib/barbeque/version.rb +1 -1
- data/lib/barbeque/worker.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58e7a032e02c8f3b25da0acf89cb8636677c3256
|
4
|
+
data.tar.gz: f403cc33bbe0dd813f0e48561dfd873c305e92a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6eb976a11b1ddccd77e30e26a350d583440a72ef98ac38a47527bc5481c45bf407b75d8eee713baef789cfbdc06a51163646162c12fa3dd4588f05a26261611
|
7
|
+
data.tar.gz: 032fc003c5b8285c870d278421480d309c1aab60d8f8f5d5985a0fb319221230355895fa3c4588be042f5e844fd188aa663f02edd15b025b7c65c8ec068b42d1
|
@@ -3,25 +3,51 @@ require 'barbeque/config'
|
|
3
3
|
module Barbeque
|
4
4
|
module ExceptionHandler
|
5
5
|
class << self
|
6
|
-
|
7
|
-
handler.handle_exception(e)
|
8
|
-
end
|
6
|
+
delegate :clear_context, :set_message_context, :handle_exception, to: :handler
|
9
7
|
|
10
8
|
private
|
11
9
|
|
12
10
|
def handler
|
13
|
-
@handler ||= const_get(Barbeque.config.exception_handler, false)
|
11
|
+
@handler ||= const_get(Barbeque.config.exception_handler, false).new
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
17
|
-
|
18
|
-
def
|
19
|
-
|
15
|
+
class RailsLogger
|
16
|
+
def initialize
|
17
|
+
clear_context
|
18
|
+
end
|
19
|
+
|
20
|
+
def clear_context
|
21
|
+
@message_id = nil
|
22
|
+
@message_type = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [String] message_id
|
26
|
+
# @param [String, nil] message_type
|
27
|
+
def set_message_context(message_id, message_type)
|
28
|
+
@message_id = message_id
|
29
|
+
@message_type = message_type
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param [Exception] e
|
33
|
+
def handle_exception(e)
|
34
|
+
Rails.logger.error("#{e.inspect}\nmessage_id: #{@message_id}, message_type: #{@message_type}\n#{e.backtrace.join("\n")}")
|
20
35
|
end
|
21
36
|
end
|
22
37
|
|
23
|
-
|
24
|
-
def
|
38
|
+
class Raven
|
39
|
+
def clear_context
|
40
|
+
::Raven::Context.clear!
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [String] message_id
|
44
|
+
# @param [String, nil] message_type
|
45
|
+
def set_message_context(message_id, message_type)
|
46
|
+
::Raven.tags_context(message_id: message_id, message_type: message_type)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @param [Exception] e
|
50
|
+
def handle_exception(e)
|
25
51
|
::Raven.capture_exception(e)
|
26
52
|
end
|
27
53
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'barbeque/exception_handler'
|
2
|
+
|
1
3
|
module Barbeque
|
2
4
|
class ExecutionPoller
|
3
5
|
def initialize
|
@@ -27,6 +29,7 @@ module Barbeque
|
|
27
29
|
private
|
28
30
|
|
29
31
|
def poll(job_execution)
|
32
|
+
Barbeque::ExceptionHandler.set_message_context(job_execution.message_id, nil)
|
30
33
|
executor = Executor.create
|
31
34
|
executor.poll_execution(job_execution)
|
32
35
|
end
|
@@ -18,11 +18,11 @@ module Barbeque
|
|
18
18
|
cmd = build_docker_run_command(docker_image, job_execution.job_definition.command, envs)
|
19
19
|
stdout, stderr, status = Open3.capture3(*cmd)
|
20
20
|
if status.success?
|
21
|
-
job_execution.update!(status: :running)
|
22
21
|
Barbeque::DockerContainer.create!(message_id: job_execution.message_id, container_id: stdout.chomp)
|
22
|
+
job_execution.update!(status: :running)
|
23
23
|
else
|
24
|
-
job_execution.update!(status: :failed, finished_at: Time.zone.now)
|
25
24
|
Barbeque::ExecutionLog.save_stdout_and_stderr(job_execution, stdout, stderr)
|
25
|
+
job_execution.update!(status: :failed, finished_at: Time.zone.now)
|
26
26
|
Barbeque::SlackNotifier.notify_job_execution(job_execution)
|
27
27
|
end
|
28
28
|
end
|
@@ -29,13 +29,13 @@ module Barbeque
|
|
29
29
|
cmd = build_hako_oneshot_command(docker_image, job_execution.job_definition.command, envs)
|
30
30
|
stdout, stderr, status = Bundler.with_clean_env { Open3.capture3(@hako_env, *cmd, chdir: @hako_dir) }
|
31
31
|
if status.success?
|
32
|
-
job_execution.update!(status: :running)
|
33
32
|
cluster, task_arn = extract_task_info(stdout)
|
34
33
|
Barbeque::EcsHakoTask.create!(message_id: job_execution.message_id, cluster: cluster, task_arn: task_arn)
|
35
34
|
Barbeque::ExecutionLog.save_stdout_and_stderr(job_execution, stdout, stderr)
|
35
|
+
job_execution.update!(status: :running)
|
36
36
|
else
|
37
|
-
job_execution.update!(status: :failed, finished_at: Time.zone.now)
|
38
37
|
Barbeque::ExecutionLog.save_stdout_and_stderr(job_execution, stdout, stderr)
|
38
|
+
job_execution.update!(status: :failed, finished_at: Time.zone.now)
|
39
39
|
Barbeque::SlackNotifier.notify_job_execution(job_execution)
|
40
40
|
end
|
41
41
|
end
|
data/lib/barbeque/runner.rb
CHANGED
@@ -22,6 +22,7 @@ module Barbeque
|
|
22
22
|
message = message_queue.dequeue
|
23
23
|
return unless message
|
24
24
|
|
25
|
+
Barbeque::ExceptionHandler.set_message_context(message.id, message.type)
|
25
26
|
handler = MessageHandler.const_get(message.type, false)
|
26
27
|
handler.new(message: message, message_queue: message_queue).run
|
27
28
|
end
|
data/lib/barbeque/version.rb
CHANGED
data/lib/barbeque/worker.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'barbeque/exception_handler'
|
1
2
|
require 'barbeque/execution_poller'
|
2
3
|
require 'barbeque/retry_poller'
|
3
4
|
require 'barbeque/runner'
|
@@ -50,6 +51,7 @@ module Barbeque
|
|
50
51
|
rescue => e
|
51
52
|
Barbeque::ExceptionHandler.handle_exception(e)
|
52
53
|
end
|
54
|
+
Barbeque::ExceptionHandler.clear_context
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barbeque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adminlte2-rails
|