Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/jsonb_accessor-1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
vertism authored Jan 9, 2025
2 parents 11034b8 + ded3e71 commit 8686c59
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 133 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ on:
env:
PREFIX: "ct-staff"
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}

concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -71,6 +66,12 @@ jobs:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -135,6 +136,12 @@ jobs:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -199,6 +206,12 @@ jobs:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -264,6 +277,12 @@ jobs:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ gem "sass-rails", "~> 6.0"
gem "sentry-rails"
gem "sentry-ruby"
gem "shell-spinner"
gem "sidekiq", "<7"
gem "sidekiq", "<8"
gem "slim-rails", "~> 3.6"
gem "sprockets", "~> 4.2.1"

Expand Down
15 changes: 9 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ GEM
kaminari-core (1.2.2)
language_server-protocol (3.17.0.3)
libreconv (0.9.5)
logger (1.6.4)
lograge (0.12.0)
actionpack (>= 4)
activesupport (>= 4)
Expand Down Expand Up @@ -435,7 +436,8 @@ GEM
rdoc (6.7.0)
psych (>= 4.0.0)
recursive-open-struct (1.2.2)
redis (4.8.1)
redis-client (0.23.0)
connection_pool
regexp_parser (2.9.2)
reline (0.5.9)
io-console (~> 0.5)
Expand Down Expand Up @@ -539,10 +541,11 @@ GEM
colorize
shoulda-matchers (5.1.0)
activesupport (>= 5.2.0)
sidekiq (6.5.12)
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
sidekiq (7.3.7)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -688,7 +691,7 @@ DEPENDENCIES
sentry-ruby
shell-spinner
shoulda-matchers (~> 5.1)
sidekiq (< 7)
sidekiq (< 8)
simplecov
simplecov-json
site_prism (< 5.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/heartbeat_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def healthcheck
private

def redis_alive?
Sidekiq.redis_info
Sidekiq.redis(&:info)
true
rescue StandardError
false
Expand Down
8 changes: 3 additions & 5 deletions app/services/stats/base_closed_cases_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ def process(report_guid:)
report = Report.find_by(guid: report_guid)

# Put the generated report into Redis for consumption by web app
redis = Redis.new
data = nil
File.open(etl_handler.results_filepath, "r") { |f| data = f.read }
redis.set(report_guid, data, ex: 7.days)
Sidekiq.redis { |r| r.set(report_guid, data, ex: 7.days.to_i) }

if report
report.report_data = {
Expand Down Expand Up @@ -74,11 +73,10 @@ def run(**args)
end

def report_details(report)
redis = Redis.new
if redis.exists?(report.guid)
if Sidekiq.redis { |r| r.exists(report.guid).positive? }
report.status = Stats::BaseReport::COMPLETE
report.save!
redis.get(report.guid)
Sidekiq.redis { |r| r.get(report.guid) }
end
end
end
Expand Down
8 changes: 3 additions & 5 deletions app/services/stats/base_monthly_performance_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ def process(offset, report_job_guid: nil, record_limit: ROWS_PER_FRAGMENT)
.each { |kase| analyse_case(kase) }

unless report_job_guid.nil?
redis = Redis.new
redis.set(report_job_guid, @stats.stats.to_json, ex: 7.days)
Sidekiq.redis { |r| r.set(report_job_guid, @stats.stats.to_json, ex: 7.days.to_i) }
end
end

Expand Down Expand Up @@ -102,11 +101,10 @@ def to_csv

# This function is only when the report is done via ETL (tasks)
def report_details(report)
redis = Redis.new
data_collector = []
report.job_ids.each do |job_id|
if redis.exists?(job_id)
data_collector << redis.get(job_id)
if Sidekiq.redis { |r| r.exists(job_id).positive? }
data_collector << Sidekiq.redis { |r| r.get(job_id) }
end
end

Expand Down
3 changes: 1 addition & 2 deletions lib/db/database_anonymizer_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def execute_task(task_name, task_arguments)
end

def store_anonymise_status(task_arguments, tasks)
redis = Redis.new
tasks_ids = tasks.map { |task| task[:task_id] }
anonymizer_job_info = {
"start_time": task_arguments[:timestamp],
Expand All @@ -35,7 +34,7 @@ def store_anonymise_status(task_arguments, tasks)
"tasks": tasks_ids,
}
anonymizer_job_id = "anonymizer_job_#{task_arguments[:tag]}_#{Time.zone.today.strftime('%Y%m%d')}"
redis.set(anonymizer_job_id, anonymizer_job_info.to_json, ex: 7.days)
Sidekiq.redis { |r| r.set(anonymizer_job_id, anonymizer_job_info.to_json, ex: 7.days.to_i) }
end

private
Expand Down
9 changes: 0 additions & 9 deletions sidekiq_admin.ru

This file was deleted.

8 changes: 6 additions & 2 deletions spec/controllers/heartbeat_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
end

describe "#healthcheck" do
let(:redis) { double("Redis") } # rubocop:disable RSpec/VerifiedDoubles

before do
retry_set = instance_double(Sidekiq::RetrySet, size: 0)
allow(Sidekiq::RetrySet).to receive(:new).and_return(retry_set)
Expand All @@ -28,7 +30,8 @@
allow(Sidekiq::ProcessSet).to receive(:new).and_return(process_set)
dead_set = instance_double(Sidekiq::DeadSet, size: 1)
allow(Sidekiq::DeadSet).to receive(:new).and_return(dead_set)
allow(Sidekiq).to receive(:redis_info).and_raise(Errno::ECONNREFUSED)
allow(Sidekiq).to receive(:redis).and_yield(redis)
allow(redis).to receive(:info).and_raise(Errno::ECONNREFUSED)
allow(ActiveRecord::Base.connection)
.to receive(:execute).and_raise(PG::ConnectionBad)

Expand All @@ -55,7 +58,8 @@
allow(Sidekiq::ProcessSet).to receive(:new).and_return(process_set)
dead_set = instance_double(Sidekiq::DeadSet, size: 0)
allow(Sidekiq::DeadSet).to receive(:new).and_return(dead_set)
allow(Sidekiq).to receive(:redis_info).and_return({})
allow(Sidekiq).to receive(:redis).and_yield(redis)
allow(redis).to receive(:info).and_return({})

get :healthcheck
end
Expand Down
Loading

0 comments on commit 8686c59

Please sign in to comment.