-
Notifications
You must be signed in to change notification settings - Fork 294
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
Fixes #37852 - Support Rails 7.0 #11155
base: master
Are you sure you want to change the base?
Conversation
4f91a1c
to
1ac6a68
Compare
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 see lots of changes around the error handling and I think that's already Rails 6.1 compatible. Perhaps something that we can already merge to reduce the size of this PR?
@@ -63,7 +63,7 @@ def setup | |||
|
|||
@validator.validate(@content_facet) | |||
|
|||
assert_empty @content_facet.errors.values | |||
assert_empty @content_facet.errors.map { |error| error.message } |
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.
assert_empty @content_facet.errors.map { |error| error.message } | |
assert_empty @content_facet.errors.map(&:message) |
@SatelliteQE/TeamPhoenix |
PRT Result
|
PRT Result
|
@chris1984 I doubt PRT is going to be of any use. You need updated Foreman and Rails and we haven't packaged that. |
1ac6a68
to
b806bb1
Compare
b26b87d
to
1f31c0f
Compare
The test failure is unrelated to this PR, it for some reason wasn't caught by GHA for theforeman/foreman_remote_execution#913 |
1f31c0f
to
3ec89a1
Compare
app/lib/katello/util/data.rb
Outdated
@@ -6,7 +6,7 @@ def self.array_with_indifferent_access(variable) | |||
end | |||
|
|||
def self.hexdigest(string) | |||
defined?(ActiveSupport::Digest) ? ActiveSupport::Digest.hexdigest(string) : Digest::MD5.hexdigest(string) | |||
defined?(ActiveSupport::Digest) ? OpenSSL::Digest::SHA1.hexdigest(string)[0...32] : Digest::MD5.hexdigest(string) |
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 forces SHA1 for hexdigest since it was default in Rails < 7. This makes sure Katello behaves the same way and the tests are green.
I'd ask maintainers to check the needed changes for this plugin to support SHA256. Afterwards this line can be switched back (until Rails upgrades the default to SHA512).
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.
@parthaa said in https://community.theforeman.org/t/rails-7-upgrade/37771/27 that the actual value doesn't matter, as long as it's consistent.
I wonder if the old code was ever used. rails/rails@82822a3 introduced ActiveSupport::Digest
and was introduced in Rails 5.2 (by a former Foreman developer). Perhaps a PR to replace it al with direct calls to ActiveSupport::Digest.hexdigest()
is a better approach.
Having said that, I find it interesting that the class itself still defaults to md5: https://github.com/rails/rails/blob/4df235f7c0149ac7be86580d41a74a7785cb9bb9/activesupport/lib/active_support/digest.rb#L9
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.
So should I just revert the changes back and simply update IDs in VCR tests?
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.
Since the IDs just need to be random numbers, I think it's fine to use the new SHA 256 default. I was going to suggest continuing to use SHA1 like suggested here so the VCR recordings could be avoided, but that's already done, so I think we're all good.
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 just thought if it will break stuff for upgrading users:
- IDs are generated or rather mapped (for the same input
A
-> the same outputB
) - These IDs are stored somewhere
- Newer hashing class will create for the same input
A
-> the same output, but differentC
- The stored
B
can't be referenced byA
, since hashed version isC
.
But if mapping goes only before storing and then the app using only stored values (without any further #hexdigest
calls on A
to reference stored value) then yeah, it should be safe. We just would need to update tests whenever new default comes from Rails.
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 haven't found anywhere where we actually try to regenerate and look up any IDs that get created via hexdigest
. Rather, we work with the value that's stored in the database.
3ec89a1
to
80bf04c
Compare
katello.gemspec
Outdated
@@ -63,7 +63,7 @@ Gem::Specification.new do |gem| | |||
|
|||
# UI | |||
gem.add_dependency "deface", '>= 1.0.2', '< 2.0.0' | |||
gem.add_dependency "angular-rails-templates", "~> 1.1.0" | |||
gem.add_dependency "angular-rails-templates", "~> 1.2.0" |
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 split this off into #11222.
80bf04c
to
d05c4ae
Compare
I see you split off #11226 into a separate PR, which is great. Are you also planning to split of the removal of require statements? I'd think that's also compatible with our current Zeitwerk and that only scopes this PR to the digest changes. |
d05c4ae
to
b835788
Compare
.github/workflows/ruby.yml
Outdated
@@ -27,7 +27,7 @@ jobs: | |||
plugin: katello | |||
postgresql_container: ghcr.io/theforeman/postgresql-evr | |||
test_existing_database: false | |||
foreman_version: develop # set to the Foreman release branch after branching :) | |||
foreman_version: refs/pull/10299/head # set to the Foreman release branch after branching :) |
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.
Comment reminder to revert this back to develop before merging.
When I locally rebase this I see there are some changes remaining where the |
hmm seems connected to diff --git a/app/lib/katello/api/v2/rendering.rb b/app/lib/katello/api/v2/rendering.rb
index 653e41a76e..a987e9ebde 100644
--- a/app/lib/katello/api/v2/rendering.rb
+++ b/app/lib/katello/api/v2/rendering.rb
@@ -41,8 +41,9 @@ module Katello
def respond_with_template(action, resource_name, options = {}, &_block)
yield if block_given?
status = options[:status] || 200
+ template = options[:full_template] || "katello/api/v2/#{resource_name}/#{action}"
- render :template => "katello/api/v2/#{resource_name}/#{action}",
+ render :template => template,
:status => status,
:locals => options.slice(:object_name, :root_name, :locals),
:layout => "katello/api/v2/layouts/#{options[:layout]}" Guessing relative paths dont work with zeitwerk ? - respond_for_show(:resource => host, :template => '../../../api/v2/hosts/show')
+ respond_for_show(:resource => host, :full_template => 'katello/api/v2/hosts/show') |
b835788
to
622a6dc
Compare
622a6dc
to
4217a15
Compare
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 looking fine to me, I tested it a bit with theforeman/foreman#10299.
Just don't forget to change the foreman version back to develop for testing!
4217a15
to
928df93
Compare
Sorry for pushing after approval. I've just rebased both Foreman PR and this one, just to ensure it's still green, so I can drop the last commit to make it ready for merge. |
928df93
to
a3df767
Compare
What are the changes introduced in this pull request?
We're updating Rails version in Foreman: theforeman/foreman#10299 (please visit it first if you have any questions/suggestions, there are many comments regarding the changes)
This PR tries to make Katello Rails 7 friendly (compatible).
Considerations taken when implementing this change?
#<<
for ActiveModel::Errors objectsWhat are the testing steps for this pull request?
Ensuring CI is green.
If you really want some 🍪, test some workflows live.