Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THREESCALE-10180: Bump sidekiq from 6.4.2 to 7.1.5 #3576

Merged
merged 3 commits into from
Oct 24, 2023

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Oct 5, 2023

See https://github.com/sidekiq/sidekiq/blob/main/docs/7.0-API-Migration.md and https://github.com/sidekiq/sidekiq/blob/main/docs/7.0-Upgrade.md

Bumps sidekiq from 6.4.2 to 7.1.5.

Changelog

Sourced from sidekiq's changelog.

7.1.5

  • FEATURE: Job filtering within the Web UI. This feature has been open sourced from Sidekiq Pro. #6052
  • API CHANGE Error handlers now take three arguments ->(ex, context, config). The previous calling convention will work until Sidekiq 8.0 but will print out a deprecation warning. #6051
  • Fix issue with the batch_size and at options in S::Client.push_bulk #6040
  • Fix inline testing firing batch callbacks early #6057
  • Use new log broadcast API in Rails 7.1 #6054
  • Crash if user tries to use RESP2 protocol: 2 #6061

7.1.4

  • Fix empty retry_for logic #6035

7.1.3

  • Add sidekiq_options retry_for: 48.hours to allow time-based retry windows #6029
  • Support sidekiq_retry_in and sidekiq_retries_exhausted_block in ActiveJobs (#5994)
  • Lowercase all Rack headers for Rack 3.0 #5951
  • Validate Sidekiq::Web page refresh delay to avoid potential DoS, CVE-2023-26141, thanks for reporting Keegan!

7.1.2

  • Mark Web UI assets as private so CDNs won't cache them #5936
  • Fix stackoverflow when using Oj and the JSON log formatter #5920
  • Remove spurious enqueued_at from scheduled ActiveJobs #5937

7.1.1

  • Support multiple CurrentAttributes #5904
  • Speed up latency fetch with large queues on Redis <7 #5910
  • Allow a larger default client pool #5886
  • Ensure Sidekiq.options[:environment] == RAILS_ENV #5932

7.1.0

  • Improve display of ActiveJob arguments in Web UI [#5825, cover]
  • Update push_bulk to push batch_size jobs at a time and allow laziness [#5827, fatkodima] This allows Sidekiq::Client to push unlimited jobs as long as it has enough memory for the batch_size.
  • Update perform_bulk to use push_bulk internally.
  • Change return value of push_bulk to map 1-to-1 with arguments.

... (truncated)

Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    You can disable automated security fix PRs for this repo from the Security Alerts page.

@dependabot dependabot bot added dependencies Pull requests that update a dependency file ruby Pull requests that update Ruby code labels Oct 5, 2023
@jlledom jlledom changed the title Bump sidekiq from 6.4.2 to 7.1.5 THREESCALE-10180: Bump sidekiq from 6.4.2 to 7.1.5 Oct 5, 2023
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (9458902) 94.34% compared to head (19a1e84) 94.36%.
Report is 21 commits behind head on master.

❗ Current head 19a1e84 differs from pull request most recent head 19bd2cf. Consider uploading reports for the commit 19bd2cf to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3576      +/-   ##
==========================================
+ Coverage   94.34%   94.36%   +0.02%     
==========================================
  Files        2799     2798       -1     
  Lines       92720    92935     +215     
==========================================
+ Hits        87476    87700     +224     
+ Misses       5244     5235       -9     
Files Coverage Δ
app/controllers/api/integrations_controller.rb 78.16% <ø> (+0.63%) ⬆️
app/helpers/api/integrations_helper.rb 91.80% <ø> (+3.74%) ⬆️
app/lib/backend/storage.rb 100.00% <100.00%> (ø)
app/lib/system/redis_pool.rb 100.00% <100.00%> (ø)
app/lib/three_scale/redis_config.rb 94.44% <100.00%> (-0.91%) ⬇️
app/workers/zync_worker.rb 93.85% <100.00%> (ø)
config/initializers/yabeda.rb 100.00% <100.00%> (ø)
config/routes.rb 99.19% <ø> (+0.80%) ⬆️
features/step_definitions/custom_web_steps.rb 90.52% <100.00%> (ø)
features/step_definitions/messages_steps.rb 97.91% <100.00%> (-0.09%) ⬇️
... and 9 more

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -123,7 +123,7 @@ memcached-container: &memcached-container
image: memcached:1.5-alpine

redis-container: &redis-container
image: redis:4.0-alpine
image: redis:6.2-alpine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redis 4 is not supported by Sidekiq 7. CircleCI needs to upgrade it's image to 6.2. That's fine, since 6.2 is the only supported version also for porta: https://access.redhat.com/articles/2798521

Gemfile Show resolved Hide resolved
gem 'sidekiq-cron', require: %w[sidekiq/cron sidekiq/cron/web]
gem 'sidekiq-lock'
gem 'sidekiq-throttled'
gem 'sidekiq-throttled', '~> 1.0.0.alpha.1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not especially happy using an alpha but it's the only available version supporting Sidekiq 7

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In rubygems most releases are alpha anyway...

app/lib/backend/storage.rb Show resolved Hide resolved
app/lib/system/error_reporting.rb Show resolved Hide resolved
@@ -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, manual_retry_count)
perform_async(event.event_id, event.data.to_json, manual_retry_count)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a parameter not being sent as string to Redis. I wonder why this haven't reported errors to Bugsnag in production, as it's deprecated since Redis 6.4

docker-compose.yml Show resolved Hide resolved
Copy link
Contributor

@jlledom jlledom Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No needed since we removed the patch, however, we keep testing the same functionality in test/unit/redis_connection_error_test.rb

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the patch because we don't use the old hiredis gem anymore.

app/lib/three_scale/redis_config.rb Outdated Show resolved Hide resolved
Comment on lines 4 to 7
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'] %>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the examples to encourage using :size over :pool_size, and to make customers know about the new :name param, which is mandatory when using redis sentinels.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should set :name to some default value (e.g. default) if it's missing?

Do you know if having "" for name would cause any problems?

I'm looking here https://github.com/redis-rb/redis-client/blob/1ab081c1d0e47df5d55e011c9390c70b2eef6731/lib/redis_client/sentinel_config.rb#L32-L38

and it seems that the error is thrown only if the value is nil, but I'm not sure if it can "break" somewhere in another place if the name is empty...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't set a default because the name is must be a user defined redis sentinel group. The :name param is only mandatory when using redis sentinels, it can be nil for standalone and for master-replicas redis installations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clients using redis sentinels, the :name param is mandatory now and it will break their configurations if they don't add it. So we must add a release note to mention this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK, I thought it was only a client thing...

In that case - wouldn't it be better to keep the name nil if BACKEND_REDIS_SENTINEL_NAME is missing?

From the link I pasted above, it seems that in this case name will be derived from the URL host, and otherwise fail.

But if it is set to empty - will it work as expected?... 🤔

This is just theoretical thinking, I haven't tried it myself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to set it to nil when the env variable isn't set. Although, from my tests in local, I'd say there's no difference in the behavior. Either the name matches exactly the sentinel group name, or it fails, no matter if empty, nil or a default value set by redis-client.

Copy link
Contributor

@josemigallas josemigallas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Consider it approved if my comments are not relevant.

Gemfile Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
@@ -6,6 +6,7 @@ def initialize(redis_config = {})
raw_config = (redis_config || {}).symbolize_keys
sentinels = raw_config.delete(:sentinels).presence
raw_config.delete_if { |key, value| value.blank? }
set_pool_size(raw_config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set_pool_size(raw_config)
raw_config[:size] ||= raw_config[:pool_size] if raw_config.key?(:pool_size)

But it's fine either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't work because it doesn't remove the :pool_size param.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set_pool_size(raw_config)
raw_config[:size] ||= raw_config.delete(:pool_size) if raw_config.key?(:pool_size)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that could work


exception = assert_raises(RedisClient::CannotConnectError) { redis._client.send(:connect) }
assert_equal 'No sentinels available', exception.message
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this testing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same as test/unit/redis_hacks_test.rb. Just I renamed it to still test the behavior, even when we removed the monkey patch.

akostadinov
akostadinov previously approved these changes Oct 12, 2023
akostadinov
akostadinov previously approved these changes Oct 17, 2023
Copy link
Contributor

@akostadinov akostadinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice. Thank you. See one comment about SaaS. Also what bothers me is that we still pull-in redis-namespace with ratelimitter. I wonder if this can be avoided. Not for this PR.

@@ -1,9 +1,10 @@
base: &default
url: "<%= ENV.fetch('BACKEND_REDIS_URL', 'redis://localhost:6379/6') %>"
timeout: <%= ENV.fetch('BACKEND_REDIS_TIMEOUT', 1) %>
pool_size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
size: <%= ENV.fetch('RAILS_MAX_THREADS', 5) %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a reminder, did you create a PR for SaaS with this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but I think we don't need it just now, because it's backwards compatible: https://github.com/3scale/porta/pull/3576/files#diff-ad73aa14ad3c1b2d53ac0808de8bbf07f16747d251bf28258622caa5bc7b21c5R9

So, we can update it when it is already deployed.

@@ -107,7 +107,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', '~> 4.2.0', require: ['redis', 'redis/connection/hiredis']
gem 'redis', require: ['redis']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is require: ['redis'] still needed?... just curious

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I actually misread it 😬 I thought this was for the new redis-client gem...

So, we have two gems: redis for non-sidekiq stuff and redis-client for sidekiq stuff, right?
But for redis we dropped hiredis, why is that? It is not compatible?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, what if we use redis-client for non-sidekiq also? 🤔

I guess the configs are compatible, so this will be more or less changing this line only? https://github.com/3scale/porta/blob/dependabot/bundler/sidekiq-7.1.5/app/lib/system/redis_pool.rb#L13

(and a couple of more)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the Redis gems ecosystem is highly confusing, since all gems have basically the same name 😵‍💫. I'll try to summarize it:

So before updating redis-rb we had:

  • redis (4.X) -> builtin client -> hiredis (ruby) -> hiredis (C)

And now:

  • redis (5.X) -> redis-client -> hiredis-client -> hiredis (C)

So, we have two gems: redis for non-sidekiq stuff and redis-client for sidekiq stuff, right?

Kind of, porta uses redis API (e.g. /app/models/billing_summary.rb), but redis depends on redis-client, so they aren't two different gems to do the same. Sidekiq calls redis-client directly (See here)

But for redis we dropped hiredis, why is that? It is not compatible?

Because it doesn't support TLS (redis/hiredis-rb#58)

I'm wondering, what if we use redis-client for non-sidekiq also?

Porta uses redis API, so we would need to invent some solution like Sidekiq does. Apisonator also has something similar (https://github.com/3scale/apisonator/blob/v3.4.3/lib/3scale/backend/storage_async/client.rb)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG, this is extremely confusing indeed 😵‍💫
Thanks a lot for this comment, it clarifies a lot!

Copy link
Contributor

@mayorova mayorova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... I think there might be one thing missing here...

While I was investigating switching redis for redis-client globally, I stumbled on the following:
We are using activejob-uniqueness, which is our own fork, based on version 0.2.0, and I think the only purpose of it was to support the old Ruby 2.4 (which we don't need to support anymore).

That version was not compatible with Sidekiq 7 (not sure about Sidekiq 6 though): https://github.com/veeqo/activejob-uniqueness/blob/main/CHANGELOG.md#added-1

I guess we need to upgrade, because some of our jobs use this.

@jlledom
Copy link
Contributor

jlledom commented Oct 24, 2023

I guess we need to upgrade, because some of our jobs use this.

Good catch. Done.

@jlledom jlledom requested a review from mayorova October 24, 2023 12:10
@@ -20,7 +20,7 @@ gem 'rails', '~> 6.0'
gem 'mail', '~> 2.7.1'

# Needed for XML serialization of ActiveRecord::Base
gem "activejob-uniqueness", github: "3scale/activejob-uniqueness", branch: "main"
gem "activejob-uniqueness"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please also swap it with the next line?
The # Needed for XML serialization of ActiveRecord::Base comment actually belongs to 'activemodel-serializers-xml', so having it here is confusing 😬

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@mayorova mayorova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @jlledom 🏆 🥇

@jlledom jlledom force-pushed the dependabot/bundler/sidekiq-7.1.5 branch from c2479c8 to de032a9 Compare October 24, 2023 12:48
@jlledom jlledom merged commit 90ff4b8 into master Oct 24, 2023
4 of 5 checks passed
@jlledom jlledom deleted the dependabot/bundler/sidekiq-7.1.5 branch October 24, 2023 14:23
jlledom added a commit to jlledom/porta that referenced this pull request Nov 3, 2023
…/sidekiq-7.1.5"

This reverts commit 90ff4b8, reversing
changes made to 9068ff9.
jlledom added a commit that referenced this pull request Nov 6, 2023
* Revert "Hotfix for hiredis-client on ppc64le (#3606)"

This reverts commit 8865ce7.

* Revert "Fix regression: boot:redis task (#3604)"

This reverts commit eb88cc2.

* Revert "Merge pull request #3576 from 3scale/dependabot/bundler/sidekiq-7.1.5"

This reverts commit 90ff4b8, reversing
changes made to 9068ff9.

* Remove activejob-uniqueness fork

* Keep the correct job parameter format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants