-
Notifications
You must be signed in to change notification settings - Fork 531
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
AO3-6893 Upgrade gems and configs to Rails 7.1.x #5039
Conversation
.includes(blocked: [:pseuds, { default_pseud: { icon_attachment: { blob: { | ||
variant_records: { image_attachment: :blob }, | ||
preview_image_attachment: { blob: { variant_records: { image_attachment: :blob } } } | ||
} } } }]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change and the same one in muted/users_controller.rb
is based on the same change in Active Storage, because this is a copy of the with_attached_* scope: https://github.com/rails/rails/blob/v7.0.8.3/activestorage/lib/active_storage/attached/model.rb -> https://github.com/rails/rails/blob/v7.1.5.1/activestorage/lib/active_storage/attached/model.rb (track_variants is true for us)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's 7.1 so we should be able to re-enable these lines:
otwarchive/spec/requests/blocked_users_n_plus_one_spec.rb
Lines 15 to 17 in 603cb16
# Rails doesn't seem to want to include variants, so this won't work right now. | |
# We can revisit when https://github.com/rails/rails/pull/49231 is released OR we upgrade to Rails 7.1 | |
# blocked.default_pseud.icon.attach(io: File.open(Rails.root.join("features/fixtures/icon.gif")), filename: "icon.gif", content_type: "image/gif") |
and
otwarchive/spec/requests/muted_users_n_plus_one_spec.rb
Lines 15 to 17 in 603cb16
# Rails doesn't seem to want to include variants, so this won't work right now. | |
# We can revisit when https://github.com/rails/rails/pull/49231 is released OR we upgrade to Rails 7.1 | |
# muted.default_pseud.icon.attach(io: File.open(Rails.root.join("features/fixtures/icon.gif")), filename: "icon.gif", content_type: "image/gif") |
However, with these lines restored, I didn't get any test failures on the current main branch / Rails 7.0. Not sure why yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something related to these comments got lost in the whole active storage PR, it was quite large and there were changes to the related scope after these comments were added. I'll just uncomment the tests and we can be happy that they pass now, I guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good? news:
The test changes behaviour based on whether we show the images via the proxy url or with processed.url
, it fails only when using processed.url
. This matches the documentation. So AO3-6898 temporarily broke it, then AO3-6900 fixed it again.
I reverted AO3-6900 locally to try to make the test work, but sadly it doesn't seem to want to behave, no matter what includes I use. According to bullet, the includes
are effective when viewing the blocked user index in a browser, but the test still fails.
I recall that we also had problems with this in the initial Active Storage PR. So I'll go ahead and disable the test again and note that using processed.url
may result in N+1 queries. Hopefully we can just stick with the proxy url.
@@ -899,7 +899,7 @@ def build_options(params) | |||
external_coauthor_name: params[:external_coauthor_name], | |||
external_coauthor_email: params[:external_coauthor_email], | |||
language_id: params[:language_id] | |||
} | |||
}.compact_blank! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the nokogiri update, when encoding defaulted to empty string here, that empty string was getting used as the encoding instead of the actual encoding of the downloaded story. Getting rid of the empty string via compact_blank! makes it fall back to the encoding of the downloaded story as expected.
@@ -84,7 +84,7 @@ def document(object) | |||
json_object = object.as_json( | |||
root: false, | |||
only: [ | |||
:id, :created_at, :bookmarkable_type, :bookmarkable_id, :user_id, | |||
:id, :created_at, :bookmarkable_type, :bookmarkable_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This user_id
was duplicate with the one in the merge call later (as_json uses string keys, the merge uses symbols, so it wasn't getting overwritten by the merge). Something changed in the json serialization for Elasticsearch so it wasn't getting rid of this duplicate "user_id": nil
anymore, so deleting it here is the fix.
|
||
# Use secret from archive config | ||
config.secret_key_base = ArchiveConfig.SESSION_SECRET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Rails documentation, it's preferred to do this in credentials.yml.enc
instead: https://guides.rubyonrails.org/v7.1/configuring.html#config-secret-key-base / https://api.rubyonrails.org/v7.1.5.1/classes/Rails/Application.html#method-i-secret_key_base
@@ -99,7 +103,6 @@ class Application < Rails::Application | |||
"X-Frame-Options" => "SAMEORIGIN", | |||
"X-XSS-Protection" => "1; mode=block", | |||
"X-Content-Type-Options" => "nosniff", | |||
"X-Download-Options" => "noopen", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is suggested by the update script. It worsens Internet Explorer support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some tests failing so not my final review, but here are my initial thoughts. (And if you have time, it might be nice to convert the failing tests to RSpec instead of minitest, but that's out of scope so not a big deal either way)
db/migrate/20250129101815_add_service_name_to_active_storage_blobs.active_storage.rb
Show resolved
Hide resolved
The tests seem to be flaky, they didn't fail on the commit with the active storage changes, just the one with the robocop changes. I also had them fail on And I figured I know better than rubocop for the rest of the reviewdog complaints/didn't want to change the generated migrations. |
@@ -739,7 +739,7 @@ PERCONA_ARGS: > | |||
--max-load Threads_running=15 | |||
--critical-load Threads_running=100 | |||
--set-vars innodb_lock_wait_timeout=2 | |||
--alter-foreign-keys-method=auto | |||
--alter-foreign-keys-method=drop_swap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like @zz9pzza or @brianjaustin to confirm that this option is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the pt-online-schema-change manpage:
drop_swap
Disable foreign key checks (FOREIGN_KEY_CHECKS=0), then drop the original table before renaming the new
table into its place. This is different from the normal method of swapping the old and new table, which
uses an atomic "RENAME" that is undetectable to client applications.
This method is faster and does not block, but it is riskier for two reasons. First, for a short time
between dropping the original table and renaming the temporary table, the table to be altered simply
does not exist, and queries against it will result in an error. Secondly, if there is an error and the
new table cannot be renamed into the place of the old one, then it is too late to abort, because the old
table is gone permanently.
This method forces "--no-swap-tables" and "--no-drop-old-table".
The last line seems a bit contradictory to the initial paragraph, but we'll want to be aware that this might leave us with tables to clean up (although we haven't always done that in the past so...) Also noting that this setting is overridden by Ansible, so we'll need to change that as well.
Overall, I think this is OK. If we're particularly worried about a table going wonky, we have backups and can also disable replication for a bit to have a "good" copy to fall back to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We ended up using rebuild_constraints
instead (#5066).
# The default locale is :en and all translations from config/locales/**/*.rb,yml are auto loaded. | ||
config.i18n.load_path += Dir[Rails.root.join("config/locales/**/*.{rb,yml}")] | ||
# The default locale is :en. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The load_path configuration defaults to this since Rails 7.0: https://guides.rubyonrails.org/v7.1/configuring.html#config-i18n-load-path
Issue
https://otwarchive.atlassian.net/browse/AO3-6893
Purpose
Upgrade to Rails 7.1. Should go in after Ruby 3.2 and AO3-6892.
Testing Instructions
Refer to Jira.
Credit
Bilka