barbeque 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/barbeque/job_executions_controller.rb +1 -1
- data/app/helpers/barbeque/job_executions_helper.rb +2 -0
- data/app/models/barbeque/job_execution.rb +5 -0
- data/app/models/barbeque/job_retry.rb +1 -0
- data/app/views/barbeque/job_definitions/show.html.haml +1 -1
- data/app/views/barbeque/job_executions/show.html.haml +1 -1
- data/lib/barbeque/message_handler/job_execution.rb +16 -5
- data/lib/barbeque/message_handler/job_retry.rb +17 -6
- data/lib/barbeque/version.rb +1 -1
- 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: 99c32b91addc8f074b6b5ebef438f279f14180e7
|
4
|
+
data.tar.gz: e8d36e10bb202841c2e8770ee390822276d7f557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ddf10732282032a55500b9c613c9bec72b43f399473d3a8199fd632a015e0c9a8b2eb04eb741d4eb48feae9a19e5b1b82ed9610ba8d6533f11487b986955faf
|
7
|
+
data.tar.gz: 66d16bc796d4534107906cf454eb78a6f83022efcd2a47c9d1dc9ef331a49aa23072f26b59d85c04aee770ad57bfb0478e3dcd1653cf9276b945daa92f854cc6
|
@@ -7,7 +7,7 @@ class Barbeque::JobExecutionsController < Barbeque::ApplicationController
|
|
7
7
|
|
8
8
|
def retry
|
9
9
|
@job_execution = Barbeque::JobExecution.find(params[:job_execution_id])
|
10
|
-
raise ActionController::BadRequest unless @job_execution.
|
10
|
+
raise ActionController::BadRequest unless @job_execution.retryable?
|
11
11
|
|
12
12
|
result = Barbeque::MessageRetryingService.new(message_id: @job_execution.message_id).run
|
13
13
|
@job_execution.retried!
|
@@ -10,6 +10,7 @@ class Barbeque::JobExecution < Barbeque::ApplicationRecord
|
|
10
10
|
success: 1,
|
11
11
|
failed: 2,
|
12
12
|
retried: 3,
|
13
|
+
error: 4,
|
13
14
|
}
|
14
15
|
|
15
16
|
paginates_per 15
|
@@ -18,4 +19,8 @@ class Barbeque::JobExecution < Barbeque::ApplicationRecord
|
|
18
19
|
def execution_log
|
19
20
|
@execution_log ||= Barbeque::ExecutionLog.load(execution: self)
|
20
21
|
end
|
22
|
+
|
23
|
+
def retryable?
|
24
|
+
failed? || error?
|
25
|
+
end
|
21
26
|
end
|
@@ -65,7 +65,7 @@
|
|
65
65
|
= link_to job_execution_path(job_execution), class: 'btn btn-default btn-sm btn-flat' do
|
66
66
|
%i.fa.fa-chevron-right
|
67
67
|
Details
|
68
|
-
- if job_execution.
|
68
|
+
- if job_execution.retryable?
|
69
69
|
= link_to job_execution_retry_path(job_execution), method: :post, class: 'btn btn-default btn-sm btn-flat',
|
70
70
|
data: { disable_with: 'retrying...', confirm: "Are you sure to retry #{@job_definition.job} ##{job_execution.id}?" } do
|
71
71
|
%i.fa.fa-refresh
|
@@ -8,7 +8,7 @@
|
|
8
8
|
\##{@job_execution.id} of
|
9
9
|
= link_to @job_execution.job_definition do
|
10
10
|
#{@job_execution.job_definition.job}
|
11
|
-
- if @job_execution.
|
11
|
+
- if @job_execution.retryable?
|
12
12
|
.col-md-2
|
13
13
|
= link_to job_execution_retry_path(@job_execution), method: :post, class: 'btn btn-default btn-block pull-right',
|
14
14
|
data: { disable_with: 'retrying...', confirm: "Are you sure to retry #{@job_execution.job_definition.job} ##{@job_execution.id}?" } do
|
@@ -20,9 +20,15 @@ module Barbeque
|
|
20
20
|
raise DuplicatedExecution.new(e.message)
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
begin
|
24
|
+
stdout, stderr, status = run_command
|
25
|
+
rescue Exception => e
|
26
|
+
job_execution.update!(status: :error, finished_at: Time.now)
|
27
|
+
notify_slack(job_execution)
|
28
|
+
raise e
|
29
|
+
end
|
24
30
|
job_execution.update!(status: status.success? ? :success : :failed, finished_at: Time.now)
|
25
|
-
notify_slack(job_execution
|
31
|
+
notify_slack(job_execution)
|
26
32
|
|
27
33
|
log_result(job_execution, stdout, stderr)
|
28
34
|
end
|
@@ -34,19 +40,24 @@ module Barbeque
|
|
34
40
|
Barbeque::ExecutionLog.save(execution: execution, log: log)
|
35
41
|
end
|
36
42
|
|
37
|
-
def notify_slack(job_execution
|
43
|
+
def notify_slack(job_execution)
|
38
44
|
return if job_execution.slack_notification.nil?
|
39
45
|
|
40
46
|
client = Barbeque::SlackClient.new(job_execution.slack_notification.channel)
|
41
|
-
if
|
47
|
+
if job_execution.success?
|
42
48
|
if job_execution.slack_notification.notify_success
|
43
49
|
client.notify_success("*[SUCCESS]* Succeeded to execute #{job_execution_link(job_execution)}")
|
44
50
|
end
|
45
|
-
|
51
|
+
elsif job_execution.failed?
|
46
52
|
client.notify_failure(
|
47
53
|
"*[FAILURE]* Failed to execute #{job_execution_link(job_execution)}" \
|
48
54
|
" #{job_execution.slack_notification.failure_notification_text}"
|
49
55
|
)
|
56
|
+
else
|
57
|
+
client.notify_failure(
|
58
|
+
"*[ERROR]* Failed to execute #{job_execution_link(job_execution)}" \
|
59
|
+
" #{job_execution.slack_notification.failure_notification_text}"
|
60
|
+
)
|
50
61
|
end
|
51
62
|
end
|
52
63
|
|
@@ -23,11 +23,18 @@ module Barbeque
|
|
23
23
|
end
|
24
24
|
job_execution.update!(status: 'retried')
|
25
25
|
|
26
|
-
|
26
|
+
begin
|
27
|
+
stdout, stderr, result = run_command
|
28
|
+
rescue Exception => e
|
29
|
+
job_retry.update!(status: :error, finished_at: Time.now)
|
30
|
+
job_execution.update!(status: :error)
|
31
|
+
notify_slack(job_retry)
|
32
|
+
raise e
|
33
|
+
end
|
27
34
|
status = result.success? ? :success : :failed
|
28
35
|
job_retry.update!(status: status, finished_at: Time.now)
|
29
36
|
job_execution.update!(status: status)
|
30
|
-
notify_slack(job_retry
|
37
|
+
notify_slack(job_retry)
|
31
38
|
|
32
39
|
log_result(job_retry, stdout, stderr)
|
33
40
|
end
|
@@ -40,20 +47,24 @@ module Barbeque
|
|
40
47
|
end
|
41
48
|
|
42
49
|
# @param [Barbeque::JobRetry] job_retry
|
43
|
-
|
44
|
-
def notify_slack(job_retry, result)
|
50
|
+
def notify_slack(job_retry)
|
45
51
|
return if job_retry.slack_notification.nil?
|
46
52
|
|
47
53
|
client = Barbeque::SlackClient.new(job_retry.slack_notification.channel)
|
48
|
-
if
|
54
|
+
if job_retry.success?
|
49
55
|
if job_retry.slack_notification.notify_success
|
50
56
|
client.notify_success("*[SUCCESS]* Succeeded to retry #{job_retry_link(job_retry)}")
|
51
57
|
end
|
52
|
-
|
58
|
+
elsif job_retry.failed?
|
53
59
|
client.notify_failure(
|
54
60
|
"*[FAILURE]* Failed to retry #{job_retry_link(job_retry)}" \
|
55
61
|
" #{job_execution.slack_notification.failure_notification_text}"
|
56
62
|
)
|
63
|
+
else
|
64
|
+
client.notify_failure(
|
65
|
+
"*[ERROR]* Failed to retry #{job_retry_link(job_retry)}" \
|
66
|
+
" #{job_execution.slack_notification.failure_notification_text}"
|
67
|
+
)
|
57
68
|
end
|
58
69
|
end
|
59
70
|
|
data/lib/barbeque/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2017-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adminlte2-rails
|