barbeque 2.8.0 → 2.9.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_definitions_controller.rb +1 -1
- data/app/controllers/barbeque/sns_subscriptions_controller.rb +11 -11
- data/app/models/barbeque/job_definition.rb +1 -1
- data/app/models/barbeque/job_queue.rb +1 -1
- data/app/models/barbeque/sns_subscription.rb +1 -1
- data/app/services/barbeque/sns_subscription_service.rb +10 -10
- data/db/migrate/20240415080757_fix_collations.rb +34 -0
- data/lib/barbeque/exception_handler.rb +27 -0
- data/lib/barbeque/executor/docker.rb +1 -1
- data/lib/barbeque/executor/hako.rb +1 -1
- data/lib/barbeque/executor.rb +1 -1
- data/lib/barbeque/message/notification.rb +1 -1
- data/lib/barbeque/message_handler/notification.rb +1 -1
- data/lib/barbeque/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5e37ff72ac6ed67071323a08ab28f43f33ae77c122aa6b209f2595b2ce6ddf
|
4
|
+
data.tar.gz: c490c08d35500bd1d5c4525a304cb523e459791324d7b6db423c2a681e68e1c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1881c7c91adf7dbc78317684d91aa24b6bd1c26118449564cf050f16e0fae6a807a46e553b3f9b363a4aaff8bc2292f8b9d52d8aa9382bf5103efd6eb2925074
|
7
|
+
data.tar.gz: 8ad58ebb5f384041e5ec1ec63766f24560fc5910b0f124b3b7b46bdc9cd0a540e799f774adf1814e60dee2dc8305fb06d84703ae52dfc5b8f0890b660ebe7eb7
|
@@ -60,7 +60,7 @@ class Barbeque::JobDefinitionsController < Barbeque::ApplicationController
|
|
60
60
|
def destroy
|
61
61
|
@job_definition = Barbeque::JobDefinition.find(params[:id])
|
62
62
|
@job_definition.sns_subscriptions.each do |sns_subscription|
|
63
|
-
Barbeque::
|
63
|
+
Barbeque::SnsSubscriptionService.new.unsubscribe(sns_subscription)
|
64
64
|
end
|
65
65
|
@job_definition.destroy
|
66
66
|
redirect_to job_definitions_url, notice: 'Job definition was successfully destroyed.'
|
@@ -1,24 +1,24 @@
|
|
1
1
|
class Barbeque::SnsSubscriptionsController < Barbeque::ApplicationController
|
2
2
|
def index
|
3
|
-
@sns_subscriptions = Barbeque::
|
3
|
+
@sns_subscriptions = Barbeque::SnsSubscription.all
|
4
4
|
end
|
5
5
|
|
6
6
|
def show
|
7
|
-
@sns_subscription = Barbeque::
|
7
|
+
@sns_subscription = Barbeque::SnsSubscription.find(params[:id])
|
8
8
|
end
|
9
9
|
|
10
10
|
def new
|
11
11
|
@sns_topic_arns = fetch_sns_topic_arns
|
12
|
-
@sns_subscription = Barbeque::
|
12
|
+
@sns_subscription = Barbeque::SnsSubscription.new
|
13
13
|
end
|
14
14
|
|
15
15
|
def edit
|
16
|
-
@sns_subscription = Barbeque::
|
16
|
+
@sns_subscription = Barbeque::SnsSubscription.find(params[:id])
|
17
17
|
end
|
18
18
|
|
19
19
|
def create
|
20
|
-
@sns_subscription = Barbeque::
|
21
|
-
if Barbeque::
|
20
|
+
@sns_subscription = Barbeque::SnsSubscription.new(params.require(:sns_subscription).permit(:topic_arn, :job_queue_id, :job_definition_id))
|
21
|
+
if Barbeque::SnsSubscriptionService.new.subscribe(@sns_subscription)
|
22
22
|
redirect_to @sns_subscription, notice: 'SNS subscription was successfully created.'
|
23
23
|
else
|
24
24
|
@sns_topic_arns = fetch_sns_topic_arns
|
@@ -27,7 +27,7 @@ class Barbeque::SnsSubscriptionsController < Barbeque::ApplicationController
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def update
|
30
|
-
@sns_subscription = Barbeque::
|
30
|
+
@sns_subscription = Barbeque::SnsSubscription.find(params[:id])
|
31
31
|
if @sns_subscription.update(params.require(:sns_subscription).permit(:job_definition_id))
|
32
32
|
redirect_to @sns_subscription, notice: 'SNS subscription was successfully updated.'
|
33
33
|
else
|
@@ -36,14 +36,14 @@ class Barbeque::SnsSubscriptionsController < Barbeque::ApplicationController
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def destroy
|
39
|
-
sns_subscription = Barbeque::
|
40
|
-
Barbeque::
|
39
|
+
sns_subscription = Barbeque::SnsSubscription.find(params[:id])
|
40
|
+
Barbeque::SnsSubscriptionService.new.unsubscribe(sns_subscription)
|
41
41
|
redirect_to sns_subscriptions_path, notice: 'SNS subscription was successfully destroyed.'
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
private
|
45
45
|
|
46
46
|
def fetch_sns_topic_arns
|
47
|
-
Barbeque::
|
47
|
+
Barbeque::SnsSubscriptionService.sns_client.list_topics.flat_map(&:topics).map(&:topic_arn)
|
48
48
|
end
|
49
49
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Barbeque::JobDefinition < Barbeque::ApplicationRecord
|
2
2
|
belongs_to :app
|
3
3
|
has_many :job_executions
|
4
|
-
has_many :sns_subscriptions
|
4
|
+
has_many :sns_subscriptions
|
5
5
|
has_one :slack_notification, dependent: :destroy
|
6
6
|
has_one :retry_config, dependent: :destroy
|
7
7
|
|
@@ -5,7 +5,7 @@ class Barbeque::JobQueue < Barbeque::ApplicationRecord
|
|
5
5
|
SQS_NAME_MAX_LENGTH = 80
|
6
6
|
|
7
7
|
has_many :job_executions
|
8
|
-
has_many :sns_subscriptions,
|
8
|
+
has_many :sns_subscriptions, dependent: :destroy
|
9
9
|
|
10
10
|
# SQS queue allows [a-zA-Z0-9_-]+ as queue name. Its maximum length is 80.
|
11
11
|
validates :name, presence: true, uniqueness: true, format: /\A[a-zA-Z0-9_-]+\z/,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'aws-sdk-sns'
|
2
2
|
require 'aws-sdk-sqs'
|
3
3
|
|
4
|
-
class Barbeque::
|
4
|
+
class Barbeque::SnsSubscriptionService
|
5
5
|
def self.sqs_client
|
6
6
|
@sqs_client ||= Aws::SQS::Client.new
|
7
7
|
end
|
@@ -10,7 +10,7 @@ class Barbeque::SNSSubscriptionService
|
|
10
10
|
@sns_client ||= Aws::SNS::Client.new
|
11
11
|
end
|
12
12
|
|
13
|
-
# @param [Barbeque::
|
13
|
+
# @param [Barbeque::SnsSubscription] sns_subscription
|
14
14
|
# @return [Boolean] `true` if succeeded to subscribe
|
15
15
|
def subscribe(sns_subscription)
|
16
16
|
if sns_subscription.valid?
|
@@ -20,10 +20,10 @@ class Barbeque::SNSSubscriptionService
|
|
20
20
|
update_sqs_policy!(sns_subscription)
|
21
21
|
true
|
22
22
|
rescue Aws::SNS::Errors::AuthorizationError
|
23
|
-
sns_subscription.errors
|
23
|
+
sns_subscription.errors.add(:topic_arn, 'is not authorized')
|
24
24
|
false
|
25
25
|
rescue Aws::SNS::Errors::NotFound
|
26
|
-
sns_subscription.errors
|
26
|
+
sns_subscription.errors.add(:topic_arn, 'is not found')
|
27
27
|
false
|
28
28
|
end
|
29
29
|
else
|
@@ -31,7 +31,7 @@ class Barbeque::SNSSubscriptionService
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
# @param [Barbeque::
|
34
|
+
# @param [Barbeque::SnsSubscription] sns_subscription
|
35
35
|
def unsubscribe(sns_subscription)
|
36
36
|
sns_subscription.destroy
|
37
37
|
update_sqs_policy!(sns_subscription)
|
@@ -42,14 +42,14 @@ class Barbeque::SNSSubscriptionService
|
|
42
42
|
private
|
43
43
|
|
44
44
|
def sqs_client
|
45
|
-
Barbeque::
|
45
|
+
Barbeque::SnsSubscriptionService.sqs_client
|
46
46
|
end
|
47
47
|
|
48
48
|
def sns_client
|
49
|
-
Barbeque::
|
49
|
+
Barbeque::SnsSubscriptionService.sns_client
|
50
50
|
end
|
51
51
|
|
52
|
-
# @param [Barbeque::
|
52
|
+
# @param [Barbeque::SnsSubscription] sns_subscription
|
53
53
|
def update_sqs_policy!(sns_subscription)
|
54
54
|
attrs = sqs_client.get_queue_attributes(
|
55
55
|
queue_url: sns_subscription.job_queue.queue_url,
|
@@ -90,7 +90,7 @@ class Barbeque::SNSSubscriptionService
|
|
90
90
|
}.to_json
|
91
91
|
end
|
92
92
|
|
93
|
-
# @param [Barbeque::
|
93
|
+
# @param [Barbeque::SnsSubscription] sns_subscription
|
94
94
|
def subscribe_topic!(sns_subscription)
|
95
95
|
sqs_attrs = sqs_client.get_queue_attributes(
|
96
96
|
queue_url: sns_subscription.job_queue.queue_url,
|
@@ -105,7 +105,7 @@ class Barbeque::SNSSubscriptionService
|
|
105
105
|
)
|
106
106
|
end
|
107
107
|
|
108
|
-
# @param [Barbeque::
|
108
|
+
# @param [Barbeque::SnsSubscription] sns_subscription
|
109
109
|
def unsubscribe_topic!(sns_subscription)
|
110
110
|
sqs_attrs = sqs_client.get_queue_attributes(
|
111
111
|
queue_url: sns_subscription.job_queue.queue_url,
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# In MySQL 8.0, the default collation for utf8mb4 is changed to utf8mb4_0900_ai_ci.
|
2
|
+
# The column collations are utf8mb4_0900_ai_ci after we ran migrations prior to this
|
3
|
+
# on MySQL 8.0 because we did not specify collation in create_table (thus the default is used).
|
4
|
+
# This happens on testing/development but we want to keep utf8mb4_general_ci.
|
5
|
+
#
|
6
|
+
# Note that running this should not affect the actual schema and data
|
7
|
+
# unless you've ran prior migrations on MySQL 8.0.
|
8
|
+
class FixCollations < ActiveRecord::Migration[6.1]
|
9
|
+
def change
|
10
|
+
reversible do |direction|
|
11
|
+
direction.up do
|
12
|
+
# alter column collations and default collation of every tables defined to utf8mb4_general_ci
|
13
|
+
execute 'ALTER TABLE barbeque_apps CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
14
|
+
execute 'ALTER TABLE barbeque_docker_containers CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
15
|
+
execute 'ALTER TABLE barbeque_ecs_hako_tasks CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
16
|
+
execute 'ALTER TABLE barbeque_job_executions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
17
|
+
execute 'ALTER TABLE barbeque_job_queues CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
18
|
+
execute 'ALTER TABLE barbeque_job_retries CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
19
|
+
execute 'ALTER TABLE barbeque_retry_configs CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
20
|
+
execute 'ALTER TABLE barbeque_slack_notifications CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
21
|
+
execute 'ALTER TABLE barbeque_sns_subscriptions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
22
|
+
|
23
|
+
# barbeque_job_definitions contains a column with explicitly specified collation
|
24
|
+
execute 'ALTER TABLE barbeque_job_definitions DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
|
25
|
+
change_column :barbeque_job_definitions, :command, :string, collation: 'utf8mb4_general_ci'
|
26
|
+
change_column :barbeque_job_definitions, :description, :text, collation: 'utf8mb4_general_ci'
|
27
|
+
end
|
28
|
+
|
29
|
+
direction.down do
|
30
|
+
raise ActiveRecord::IrreversibleMigration
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -51,5 +51,32 @@ module Barbeque
|
|
51
51
|
::Raven.capture_exception(e)
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
class Sentry
|
56
|
+
def initialize
|
57
|
+
::Sentry.get_current_hub.push_scope
|
58
|
+
end
|
59
|
+
|
60
|
+
def clear_context
|
61
|
+
::Sentry.get_current_hub.pop_scope
|
62
|
+
::Sentry.get_current_hub.push_scope
|
63
|
+
end
|
64
|
+
|
65
|
+
# @param [String] message_id
|
66
|
+
# @param [String, nil] message_type
|
67
|
+
def set_message_context(message_id, message_type)
|
68
|
+
::Sentry.configure_scope do |scope|
|
69
|
+
scope.set_tags(
|
70
|
+
message_id: message_id,
|
71
|
+
message_type: message_type
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# @param [Exception] e
|
77
|
+
def handle_exception(e)
|
78
|
+
::Sentry.capture_exception(e)
|
79
|
+
end
|
80
|
+
end
|
54
81
|
end
|
55
82
|
end
|
@@ -18,7 +18,7 @@ module Barbeque
|
|
18
18
|
# @param [String] yaml_dir (deprecated: renamed to definition_dir)
|
19
19
|
def initialize(hako_dir:, hako_env: {}, yaml_dir: nil, definition_dir: nil, oneshot_notification_prefix:)
|
20
20
|
@hako_dir = hako_dir
|
21
|
-
@hako_env = hako_env
|
21
|
+
@hako_env = hako_env.stringify_keys
|
22
22
|
@definition_dir =
|
23
23
|
if definition_dir
|
24
24
|
definition_dir
|
data/lib/barbeque/executor.rb
CHANGED
@@ -8,7 +8,7 @@ module Barbeque
|
|
8
8
|
attr_reader :application # [String] To specify `job_definitions.app.name`
|
9
9
|
attr_reader :job # [String] To specify `job_definitions.job`
|
10
10
|
|
11
|
-
# @param [Barneque::
|
11
|
+
# @param [Barneque::SnsSubscription] subscription
|
12
12
|
# @return [Barbeque::Message::Notification]
|
13
13
|
def set_params_from_subscription(subscription)
|
14
14
|
@application = subscription.app.name
|
@@ -9,7 +9,7 @@ module Barbeque
|
|
9
9
|
@message = message
|
10
10
|
@message_queue = message_queue
|
11
11
|
|
12
|
-
subscription =
|
12
|
+
subscription = SnsSubscription.find_by!(topic_arn: @message.topic_arn, job_queue_id: @message_queue.job_queue.id)
|
13
13
|
@message.set_params_from_subscription(subscription)
|
14
14
|
end
|
15
15
|
end
|
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: 2.
|
4
|
+
version: 2.9.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:
|
11
|
+
date: 2025-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adminlte2-rails
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: 6.1.4
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: 6.1.4
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rinku
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -426,6 +426,7 @@ files:
|
|
426
426
|
- db/migrate/20190311034445_add_notify_failure_only_if_retry_limit_reached_to_barbeque_slack_notifications.rb
|
427
427
|
- db/migrate/20190315052951_change_barbeque_retry_configs_base_delay_default_value.rb
|
428
428
|
- db/migrate/20191029105530_change_job_name_to_case_sensitive.rb
|
429
|
+
- db/migrate/20240415080757_fix_collations.rb
|
429
430
|
- lib/barbeque.rb
|
430
431
|
- lib/barbeque/config.rb
|
431
432
|
- lib/barbeque/docker_image.rb
|
@@ -476,7 +477,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
476
477
|
- !ruby/object:Gem::Version
|
477
478
|
version: '0'
|
478
479
|
requirements: []
|
479
|
-
rubygems_version: 3.
|
480
|
+
rubygems_version: 3.2.33
|
480
481
|
signing_key:
|
481
482
|
specification_version: 4
|
482
483
|
summary: Job queue system to run job with Docker
|