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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a07ec80487438ab32f44b7af709d578cdd3e3a3
4
- data.tar.gz: cc0639ff64e3c992e960b454e2e9dab8faf7e6b6
3
+ metadata.gz: 99c32b91addc8f074b6b5ebef438f279f14180e7
4
+ data.tar.gz: e8d36e10bb202841c2e8770ee390822276d7f557
5
5
  SHA512:
6
- metadata.gz: 26042a230e695187cc8bf37c6842189a42909512c22fd5a5bfc328cf22d88257f498532a644973f4dfc788988d65e8aedf29c4f57d15aa8e7ed52356862c6567
7
- data.tar.gz: 36e3894bdba8d78175fab0610031e8953086b0ee1f6a538b2b1beeda9b3c1d79da706b0065369a20494a6d4e13ee1fe7cc66fed98bb67cd88885cbff32d1c010
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.failed?
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,8 @@ module Barbeque::JobExecutionsHelper
10
10
  'warning'
11
11
  when 'pending'
12
12
  'info'
13
+ when 'error'
14
+ 'danger'
13
15
  else
14
16
  'default'
15
17
  end
@@ -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
@@ -9,6 +9,7 @@ class Barbeque::JobRetry < Barbeque::ApplicationRecord
9
9
  success: 1,
10
10
  failed: 2,
11
11
  retried: 3,
12
+ error: 4,
12
13
  }
13
14
 
14
15
  # @return [Hash] - A hash created by `JobExecutor::Retry#log_result`
@@ -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.failed?
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.failed?
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
- stdout, stderr, status = run_command
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, status)
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, status)
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 status.success?
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
- else
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
- stdout, stderr, result = run_command
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, result)
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
- # @param [Process::Status] result
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 result.success?
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
- else
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
 
@@ -1,3 +1,3 @@
1
1
  module Barbeque
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
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.1
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-04-27 00:00:00.000000000 Z
11
+ date: 2017-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adminlte2-rails