Skip to content

Commit

Permalink
Revert "Merge pull request 3scale#3576 from 3scale/dependabot/bundler…
Browse files Browse the repository at this point in the history
…/sidekiq-7.1.5"

This reverts commit 90ff4b8, reversing
changes made to 9068ff9.
  • Loading branch information
jlledom committed Nov 3, 2023
1 parent c28a3ea commit c9d9080
Show file tree
Hide file tree
Showing 24 changed files with 122 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ memcached-container: &memcached-container
image: memcached:1.5-alpine

redis-container: &redis-container
image: redis:6.2-alpine
image: redis:4.0-alpine

# https://github.com/poseidon/dnsmasq
# TODO: create our own image like https://www.redhat.com/en/blog/build-ubi-containers-github-actions-buildah-and-podman
Expand Down
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ gem 'rails', '~> 6.0'
# Also, upgrading makes this test fail: SendUserInvitationWorkerTest#test_handles_errors
gem 'mail', '~> 2.7.1'

gem "activejob-uniqueness"
# Needed for XML serialization of ActiveRecord::Base
gem "activejob-uniqueness", github: "3scale/activejob-uniqueness", branch: "main"
gem 'activemodel-serializers-xml'

gem 'protected_attributes_continued', '~> 1.8.2'
Expand Down Expand Up @@ -51,10 +51,10 @@ gem '3scale_time_range', '0.0.6'
gem 'statsd-ruby', require: false

# Sidekiq
gem 'sidekiq', '~> 7', require: %w[sidekiq sidekiq/web]
gem 'sidekiq-batch', github: '3scale/sidekiq-batch', branch: 'redis-client'
gem 'sidekiq', '~> 6.4.0', require: %w[sidekiq sidekiq/web]
gem 'sidekiq-batch'
gem 'sidekiq-cron', require: %w[sidekiq/cron sidekiq/cron/web]
gem 'sidekiq-throttled', '~> 1.0.0.alpha.1'
gem 'sidekiq-throttled'

gem 'sidekiq-prometheus-exporter'

Expand All @@ -74,7 +74,7 @@ gem 'formtastic', '~> 4.0'
gem 'htmlentities', '~>4.3', '>= 4.3.4'
# TODO: Not actively maintained https://github.com/activeadmin/inherited_resources#notice replace with respond_with and fix things the rails way
gem 'inherited_resources', '~> 1.12.0'
gem 'json', '~> 2.3'
gem 'json', '~> 2.3.0'

gem 'mysql2', '~> 0.5.3'

Expand All @@ -93,7 +93,7 @@ gem 'acts-as-taggable-on', '~> 8.0'
gem 'baby_squeel', '~> 1.4.3'
gem 'browser'
gem 'diff-lcs', '~> 1.2'
gem 'hiredis-client'
gem 'hiredis', '~> 0.6.3'
gem 'httpclient', github: '3scale/httpclient', branch: 'ssl-env-cert'
gem 'json-schema', git: 'https://github.com/3scale/json-schema.git'
gem 'local-fastimage_resize', '~> 3.4.0', require: 'fastimage/resize'
Expand All @@ -106,7 +106,7 @@ gem 'ratelimit'
gem 'recaptcha', '4.13.1', require: 'recaptcha/rails'
gem 'redcarpet', '~>3.5.1', require: false
gem 'RedCloth', '~>4.3', require: false
gem 'redis', require: ['redis']
gem 'redis', '~> 4.2.0', require: ['redis', 'redis/connection/hiredis']
gem 'rest-client', '~> 2.0.2'
gem 'rubyzip', '~>1.3.0', require: false
gem 'svg-graph', require: false
Expand Down
75 changes: 35 additions & 40 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
GIT
remote: https://github.com/3scale/activejob-uniqueness.git
revision: fc560d1ab5552dc3a1602d4aaa7caaa8eba5791f
branch: main
specs:
activejob-uniqueness (0.2.0)
activejob (>= 4.2, < 7)
redlock (>= 1.2, < 2)

GIT
remote: https://github.com/3scale/ci_reporter_shell.git
revision: 30b30d655512891f56463e5f1fa125ea1f2df886
Expand Down Expand Up @@ -28,14 +37,6 @@ GIT
nokogiri (~> 1)
rspec (>= 3.0.0.a, < 4)

GIT
remote: https://github.com/3scale/sidekiq-batch.git
revision: f1c56d0b8445fd3eb337614aedba1752aa19938e
branch: redis-client
specs:
sidekiq-batch (0.1.9)
sidekiq (~> 7)

GIT
remote: https://github.com/3scale/swagger-ui_rails.git
revision: f88bb8bed4fdb57fcf5be6425f3fc10c638788d1
Expand Down Expand Up @@ -119,9 +120,6 @@ GEM
activejob (6.0.6.1)
activesupport (= 6.0.6.1)
globalid (>= 0.3.6)
activejob-uniqueness (0.2.5)
activejob (>= 4.2, < 7.1)
redlock (>= 1.2, < 2)
activemerchant (1.107.4)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
Expand Down Expand Up @@ -385,8 +383,7 @@ GEM
hashdiff (1.0.1)
hashery (2.1.2)
hashie (3.6.0)
hiredis-client (0.17.0)
redis-client (= 0.17.0)
hiredis (0.6.3)
html-pipeline (2.12.3)
activesupport (>= 2)
nokogiri (>= 1.4)
Expand Down Expand Up @@ -417,7 +414,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.6.3)
json (2.3.1)
jsonpath (1.1.2)
multi_json
jwt (1.5.6)
Expand Down Expand Up @@ -649,13 +646,10 @@ GEM
actionview (>= 5)
recursive-open-struct (1.1.3)
redcarpet (3.5.1)
redis (5.0.7)
redis-client (>= 0.9.0)
redis-client (0.17.0)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
redis-prescription (2.6.0)
redis (4.2.5)
redis-namespace (1.7.0)
redis (>= 3.0.4)
redis-prescription (1.0.0)
redlock (1.3.2)
redis (>= 3.0.0, < 6.0)
reek (6.1.0)
Expand Down Expand Up @@ -762,21 +756,22 @@ GEM
shoulda-context (2.0.0)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
sidekiq (7.1.6)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.14.0)
sidekiq-cron (1.10.1)
sidekiq (6.4.2)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
sidekiq-batch (0.1.9)
sidekiq (>= 3)
sidekiq-cron (1.9.1)
fugit (~> 1.8)
globalid (>= 1.0.1)
sidekiq (>= 6)
sidekiq (>= 4.2.1)
sidekiq-prometheus-exporter (0.2.0)
rack (>= 1.6.0)
sidekiq (>= 4.1.0)
sidekiq-throttled (1.0.0.alpha.1)
redis-prescription (~> 2.2)
sidekiq (>= 6.5)
sidekiq-throttled (0.15.0)
concurrent-ruby
redis-prescription
sidekiq
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -908,7 +903,7 @@ GEM
yabeda (~> 0.6)
yard (0.9.27)
webrick (~> 1.7.0)
zeitwerk (2.6.12)
zeitwerk (2.6.8)
zip-zip (0.3)
rubyzip (>= 1.0.0)

Expand All @@ -920,7 +915,7 @@ DEPENDENCIES
3scale_time_range (= 0.0.6)
RedCloth (~> 4.3)
active-docs!
activejob-uniqueness
activejob-uniqueness!
activemerchant (~> 1.107.4)
activemodel-serializers-xml
activerecord-oracle_enhanced-adapter (~> 6.0)
Expand Down Expand Up @@ -970,14 +965,14 @@ DEPENDENCIES
formtastic (~> 4.0)
github-markdown
hashie
hiredis-client
hiredis (~> 0.6.3)
html-pipeline
htmlentities (~> 4.3, >= 4.3.4)
httpclient!
i18n
inherited_resources (~> 1.12.0)
jquery-rails (~> 4.4)
json (~> 2.3)
json (~> 2.3.0)
json-schema!
jwt (~> 1.5.2)
kt-paperclip (~> 7.2)
Expand Down Expand Up @@ -1027,7 +1022,7 @@ DEPENDENCIES
recaptcha (= 4.13.1)
record_tag_helper (~> 1.0)
redcarpet (~> 3.5.1)
redis
redis (~> 4.2.0)
redlock
reek (= 6.01)
reform (~> 2.0.3)
Expand All @@ -1048,11 +1043,11 @@ DEPENDENCIES
secure_headers (~> 6.3.0)
selenium-webdriver (~> 3.142)
shoulda (~> 4.0)
sidekiq (~> 7)
sidekiq-batch!
sidekiq (~> 6.4.0)
sidekiq-batch
sidekiq-cron
sidekiq-prometheus-exporter
sidekiq-throttled (~> 1.0.0.alpha.1)
sidekiq-throttled
simplecov (~> 0.21.2)
slim-rails (~> 3.2)
sprockets-rails
Expand Down
3 changes: 2 additions & 1 deletion app/lib/backend/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def self.parse_config
config = File.read("#{Rails.root}/config/backend_redis.yml")
config = ERB.new(config).result(binding)
config = YAML.load(config)
config.fetch(Rails.env).deep_symbolize_keys
config = config.fetch(Rails.env).symbolize_keys
config.reverse_merge(logger: Rails.logger)
end

def initialize
Expand Down
4 changes: 0 additions & 4 deletions app/lib/system/error_reporting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def report_error(exception, logger: Rails.logger, **parameters)
end
end

def report_sidekiq_error(exception, _context, config)
report_error(exception, logger: config.logger)
end

def report_deprecation_warning(payload)
exception = DeprecationWarning.new(payload[:message], payload[:gem_name], payload[:deprecation_horizon])

Expand Down
10 changes: 5 additions & 5 deletions app/lib/system/redis_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module System
# RedisPool a simple wrapper around Redis with connection pooling
class RedisPool

def initialize(config = {})
cfg = config.to_h
pool_config = cfg.extract!(:size, :pool_timeout)
@pool = ConnectionPool.new(size: pool_config[:size] || 5, timeout: pool_config[:pool_timeout] || 5 ) do
Redis.new(cfg)
def initialize(config={})
config = config.dup
pool_config = config.extract!(:pool_size, :pool_timeout)
@pool = ConnectionPool.new(size: pool_config[:pool_size] || 5, timeout: pool_config[:pool_timeout] || 5 ) do
Redis.new(config)
end
end

Expand Down
1 change: 0 additions & 1 deletion app/lib/three_scale/redis_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ def initialize(redis_config = {})
raw_config = (redis_config || {}).symbolize_keys
sentinels = raw_config.delete(:sentinels).presence
raw_config.delete_if { |key, value| value.blank? }
raw_config[:size] ||= raw_config.delete(:pool_size) if raw_config.key?(:pool_size)

@config = ActiveSupport::OrderedOptions.new.merge(raw_config)
config.sentinels = parse_sentinels(sentinels) if sentinels
Expand Down
2 changes: 1 addition & 1 deletion app/workers/zync_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def on_complete(_bid, options)
# The number of retries is usually controlled at the origin of the failure using ThreeScale::SidekiqRetrySupport::Worker#last_attempt?,
# but in this case we are not really using Sidekiq retries, but rather re-enqueueing the job manually here
manual_retry_count = options['manual_retry_count'].to_i + 1
perform_async(event.event_id, event.data.to_json, manual_retry_count)
perform_async(event.event_id, event.data, manual_retry_count)
end

delegate :perform_async, to: :class
Expand Down
3 changes: 1 addition & 2 deletions config/examples/backend_redis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
base: &default
url: "<%= ENV.fetch('BACKEND_REDIS_URL', 'redis://localhost:6379/6') %>"
timeout: <%= ENV.fetch('BACKEND_REDIS_TIMEOUT', 1) %>
size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
pool_size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
pool_timeout: 5 # this is in seconds
sentinels: "<%= ENV['BACKEND_REDIS_SENTINEL_HOSTS'] %>"
name: <%= ENV['BACKEND_REDIS_SENTINEL_NAME'] %>
role: <%= ENV['BACKEND_REDIS_SENTINEL_ROLE'] %>

development:
Expand Down
3 changes: 1 addition & 2 deletions config/examples/redis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
base: &default
url: "<%= ENV.fetch('REDIS_URL', 'redis://localhost:6379/1') %>"
size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
pool_size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
pool_timeout: 5 # this is in seconds
sentinels: "<%= ENV['REDIS_SENTINEL_HOSTS'] %>"
name: <%= ENV['REDIS_SENTINEL_NAME'] %>
role: <%= ENV['REDIS_SENTINEL_ROLE'] %>

development:
Expand Down
21 changes: 21 additions & 0 deletions config/initializers/redis_hacks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

# Monkey patches redis-rb so connections errors with exception class `RuntimeError` and
# message "Name or service not known" (i.e. name solving problems) are properly handled
# as `Redis::BaseConnectionError` errors, which will be caught by `Redis::Client#establish_connection`

module RedisHacks
module HiredisConnection
def connect(*args)
super
rescue RuntimeError => exception
if exception.message =~ /(can't resolve)|(name or service not known)|(nodename nor servname provided, or not known)/i
raise Redis::BaseConnectionError.new(exception.message)
else
raise
end
end
end
end

Redis::Connection::Hiredis.singleton_class.prepend(RedisHacks::HiredisConnection)
4 changes: 2 additions & 2 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
config.try(:reliable!)

config.redis = ThreeScale::RedisConfig.new(System::Application.config.sidekiq).config
config.error_handlers.replace([System::ErrorReporting.method(:report_sidekiq_error)])
config.error_handlers << System::ErrorReporting.method(:report_error)

config.logger.formatter = Sidekiq::Logger::Formatters::Pretty.new

Expand All @@ -37,7 +37,7 @@
# Use PROMETHEUS_EXPORTER_BIND and PROMETHEUS_EXPORTER_PORT
# if no PROMETHEUS_EXPORT_PORT given, it will start the server with default port 9394 + index
port = ENV.fetch('PROMETHEUS_EXPORTER_PORT', 9394).to_i
port += Sidekiq.default_configuration[:index].to_i
port += Sidekiq.options[:index].to_i
ENV['PROMETHEUS_EXPORTER_PORT'] ||= port.to_s

require 'yabeda/prometheus/mmap'
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ services:
- RACK_ENV=production

redis:
image: redis:6.2-alpine
image: redis:alpine
container_name: redis-compose
ports:
- "6379:6379"
Expand Down
5 changes: 1 addition & 4 deletions features/support/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
require 'sidekiq/batch'

# Turn off Sidekiq logging which pollutes the CI logs
Sidekiq.configure_client do |config|
config.logger = Sidekiq::Logger.new(nil, level: Logger::FATAL)
end

Sidekiq.logger = Sidekiq::Logger.new(nil, level: Logger::FATAL)
Sidekiq::Testing.inline!

module Sidekiq
Expand Down
2 changes: 1 addition & 1 deletion fedora-manual-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ podman run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true --name mysql80 mys
[Redis](https://redis.io) is an in-memory data store used as DB for some of the data and it has to be running for the application to work. We recommend running it in a [Podman](https://podman.io/) container:

```
podman run -d -p 6379:6379 redis:6.2-alpine
podman run -d -p 6379:6379 redis
```

Alternatively, Redis can be run directly on your machine with `dnf`:
Expand Down
3 changes: 1 addition & 2 deletions openshift/system/config/backend_redis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
production:
url: "<%= ENV.fetch('BACKEND_REDIS_URL', 'redis://backend-redis:6379') %>"
timeout: <%= ENV.fetch('REDIS_BACKEND_TIMEOUT', 1) %>
size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
pool_size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
pool_timeout: 5 # this is in seconds
sentinels: "<%= ENV['BACKEND_REDIS_SENTINEL_HOSTS'] %>"
name: <%= ENV['BACKEND_REDIS_SENTINEL_NAME'] %>
role: <%= ENV['BACKEND_REDIS_SENTINEL_ROLE'] %>
3 changes: 1 addition & 2 deletions openshift/system/config/redis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
production:
url: "<%= ENV.fetch('REDIS_URL', 'redis://system-redis/1') %>"
size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
pool_size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
pool_timeout: 5 # this is in seconds
sentinels: "<%= ENV['REDIS_SENTINEL_HOSTS'] %>"
name: <%= ENV['REDIS_SENTINEL_NAME'] %>
role: <%= ENV['REDIS_SENTINEL_ROLE'] %>
Loading

0 comments on commit c9d9080

Please sign in to comment.