Skip to content

Commit

Permalink
Merge pull request #891 from alphagov/dependabot/bundler/govuk_sideki…
Browse files Browse the repository at this point in the history
…q-9.0.0

Bump govuk_sidekiq from 8.0.1 to 9.0.0
  • Loading branch information
JonathanHallam authored Sep 27, 2024
2 parents 005d530 + 21b9d8b commit 596cda5
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gem "pg"
gem "plek"
gem "sentry-sidekiq"
gem "sidekiq-scheduler"
gem "sidekiq-unique-jobs"
gem "sidekiq-unique-jobs", "< 8.0.8"

group :development, :test do
gem "brakeman"
Expand Down
43 changes: 19 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ GEM
msgpack (~> 1.2)
brakeman (6.2.1)
racc
brpoplpush-redis_script (0.1.3)
concurrent-ruby (~> 1.0, >= 1.0.5)
redis (>= 1.0, < 6)
builder (3.3.0)
byebug (11.1.3)
climate_control (1.2.0)
Expand Down Expand Up @@ -134,7 +131,7 @@ GEM
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
gds-api-adapters (96.0.1)
gds-api-adapters (96.0.3)
addressable
link_header
null_logger
Expand Down Expand Up @@ -177,16 +174,15 @@ GEM
sentry-rails (~> 5.3)
sentry-ruby (~> 5.3)
statsd-ruby (~> 1.5)
govuk_sidekiq (8.0.1)
govuk_sidekiq (9.0.0)
gds-api-adapters (>= 19.1.0)
govuk_app_config (>= 1.1)
redis (< 5)
redis-namespace (~> 1.6)
sidekiq (~> 6.5, >= 6.5.12)
redis-client (>= 0.22.2)
sidekiq (~> 7.0, < 8)
hashdiff (1.1.0)
hashie (5.0.0)
http-accept (1.7.0)
http-cookie (1.0.6)
http-cookie (1.0.7)
domain_name (~> 0.5)
httparty (0.22.0)
csv
Expand Down Expand Up @@ -222,7 +218,7 @@ GEM
method_source (1.0.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0604)
mime-types-data (3.2024.0903)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.25.1)
Expand Down Expand Up @@ -508,7 +504,7 @@ GEM
method_source (~> 1.0)
psych (5.1.2)
stringio
public_suffix (6.0.0)
public_suffix (6.0.1)
puma (6.4.3)
nio4r (~> 2.0)
raabro (1.4.0)
Expand Down Expand Up @@ -562,9 +558,8 @@ GEM
ffi (~> 1.0)
rdoc (6.7.0)
psych (>= 4.0.0)
redis (4.8.1)
redis-namespace (1.11.0)
redis (>= 4)
redis-client (0.22.2)
connection_pool
regexp_parser (2.9.2)
reline (0.5.10)
io-console (~> 0.5)
Expand Down Expand Up @@ -650,20 +645,20 @@ GEM
sentry-sidekiq (5.19.0)
sentry-ruby (~> 5.19.0)
sidekiq (>= 3.0)
sidekiq (6.5.12)
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
sidekiq (7.3.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
sidekiq-scheduler (5.0.6)
rufus-scheduler (~> 3.2)
sidekiq (>= 6, < 8)
tilt (>= 1.4.0, < 3)
sidekiq-unique-jobs (7.1.33)
brpoplpush-redis_script (> 0.1.1, <= 2.0.0)
sidekiq-unique-jobs (8.0.7)
concurrent-ruby (~> 1.0, >= 1.0.5)
redis (< 5.0)
sidekiq (>= 5.0, < 7.0)
thor (>= 0.20, < 3.0)
sidekiq (>= 7.0.0, < 8.0.0)
thor (>= 1.0, < 3.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -745,7 +740,7 @@ DEPENDENCIES
rubocop-govuk
sentry-sidekiq
sidekiq-scheduler
sidekiq-unique-jobs
sidekiq-unique-jobs (< 8.0.8)
simplecov
timecop
web-console
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/batch_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def create
render(json: batch_report(batch), status: :created)
else
batch.checks.each do |check|
CheckWorker.run(check.id, priority: create_params.priority)
CheckJob.run(check.id, priority: create_params.priority)
end

render(json: batch_report(batch.reload), status: :accepted)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/check_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def check

check = Check.create!(link:)

CheckWorker.run(
CheckJob.run(
check.id,
priority: check_params.priority,
synchronous: check_params.synchronous,
Expand Down
2 changes: 1 addition & 1 deletion app/models/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def trigger_webhook
return unless completed?
return if webhook_triggered

WebhookWorker.perform_async(
WebhookJob.perform_async(
BatchPresenter.new(self).report.to_json,
webhook_uri,
webhook_secret_token,
Expand Down
6 changes: 4 additions & 2 deletions app/workers/check_worker.rb → app/sidekiq/check_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class CheckWorker
include Sidekiq::Worker
class CheckJob
include Sidekiq::Job
include PerformAsyncInQueue

sidekiq_options retry: 3, lock: :until_and_while_executing, lock_args_method: :unique_args
Expand Down Expand Up @@ -56,3 +56,5 @@ def self.run(check_id, priority: "high", synchronous: false)
end
end
end

CheckWorker = CheckJob
8 changes: 5 additions & 3 deletions app/workers/cleanup_worker.rb → app/sidekiq/cleanup_job.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "sidekiq-scheduler"

class CleanupWorker
include Sidekiq::Worker
class CleanupJob
include Sidekiq::Job

def perform
checks_to_perform.each do |check_id|
CheckWorker.perform_async(check_id)
CheckJob.perform_async(check_id)
end

old_batches.delete_all
Expand All @@ -28,3 +28,5 @@ def old_batches
Batch.where(id: BatchCheck.select(:batch_id).where(check: old_checks))
end
end

CleanupWorker = CleanupJob
12 changes: 7 additions & 5 deletions app/workers/webhook_worker.rb → app/sidekiq/webhook_job.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class RestartWorkerException < RuntimeError
class RestartJobException < RuntimeError
end

class WebhookWorker
include Sidekiq::Worker
class WebhookJob
include Sidekiq::Job

sidekiq_options queue: :webhooks, retry: 4, lock: :until_and_while_executing, lock_args_method: :unique_args

Expand All @@ -25,15 +25,15 @@ def perform(report, uri, secret_token, batch_id)
connection.post do |req|
req.url uri
req.headers["Content-Type"] = "application/json"
req.headers["User-Agent"] = "#{ENV.fetch('GOVUK_APP_NAME', 'link-checker-api')} (webhook-worker)"
req.headers["User-Agent"] = "#{ENV.fetch('GOVUK_APP_NAME', 'link-checker-api')} (webhook-job)"
req.headers[SIGNATURE_HEADER] = generate_signature(report, secret_token) if secret_token
req.body = report
end

batch.update!(webhook_triggered: true)
rescue Faraday::ClientError => e
logger.error e.message
raise RestartWorkerException
raise RestartJobException
rescue Faraday::ServerError => e
logger.error e.message
end
Expand All @@ -49,3 +49,5 @@ def generate_signature(body, key)
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), key, body)
end
end

WebhookWorker = WebhookJob
2 changes: 1 addition & 1 deletion config/initializers/govuk_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
config.data_sync_excluded_exceptions += %w[
Faraday::ServerError
Faraday::ConnectionFailed
RestartWorkerException
RestartJobException
]
end
3 changes: 0 additions & 3 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@
# SidekiqUniqueJobs recommends not testing this behaviour, our tests have previously has caused flakey builds
SidekiqUniqueJobs.config.enabled = !Rails.env.test?
SidekiqUniqueJobs.config.logger_enabled = !Rails.env.test?

# Use Sidekiq strict args to force Sidekiq 6 deprecations to error ahead of upgrade to Sidekiq 7
Sidekiq.strict_args!
2 changes: 1 addition & 1 deletion config/sidekiq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:schedule:
cleanup:
every: 60m
class: CleanupWorker
class: CleanupJob
2 changes: 1 addition & 1 deletion spec/requests/batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
include_examples "returns batch report"

it "creates a job" do
expect(CheckWorker.jobs.size).to eq(2)
expect(CheckJob.jobs.size).to eq(2)
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe CheckWorker do
RSpec.describe CheckJob do
specify { expect(described_class).to have_valid_sidekiq_options }

describe "perform" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe CleanupWorker do
RSpec.describe CleanupJob do
describe "perform" do
let(:link1) { create(:link, id: 1) }
let(:link2) { create(:link, id: 2) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe WebhookWorker do
RSpec.describe WebhookJob do
specify { expect(described_class).to have_valid_sidekiq_options }

describe "perform" do
Expand Down

0 comments on commit 596cda5

Please sign in to comment.