-
Notifications
You must be signed in to change notification settings - Fork 989
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 #37825 - Upgrade Rails to 7.0 #10299
base: develop
Are you sure you want to change the base?
Conversation
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.
In #9328 I also updated spring. Is that not needed? I recall running into it, but that could have been a Ruby thing or I was just looking at changelogs.
@@ -5,7 +5,7 @@ module Token | |||
included do | |||
has_one :token, :foreign_key => :host_id, :dependent => :destroy, :inverse_of => :host, :class_name => 'Token::Build' | |||
|
|||
scope :for_token, ->(token) { joins(:token).where(:tokens => { :value => token }).where("expires >= ?", Time.now.utc.to_s(:db)).select('hosts.*') } | |||
scope :for_token, ->(token) { joins(:token).where(:tokens => { :value => token }).where("expires >= ?", Time.now.utc.to_fs(:db)).select('hosts.*') } |
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.
TIL: there's .to_fs
in Rails. I wonder if Rails is smart enough to understand
scope :for_token, ->(token) { joins(:token).where(:tokens => { :value => token }).where("expires >= ?", Time.now.utc.to_fs(:db)).select('hosts.*') } | |
scope :for_token, ->(token) { joins(:token).where(:tokens => { :value => token }).where("expires >= ?", Time.now.utc).select('hosts.*') } |
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.
Have you tried if moving the settings into initializers works with Rails 6.1?
class ::FakePlugin; end | ||
class ::FakePlugin::FakeModel; end | ||
class ::FakePlugin::FakeModel < ApplicationRecord; end |
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.
Should this even be
module FakePlugin
class FakeModel < ApplicationRecord
end
end
b2971c8
to
c93acc6
Compare
There left only one test failure, I'm looking into it, for now I've got no clue :/ Apart from that, it's ready unless we want to be more correct and apply/incorporate these changes: https://railsdiff.org/6.1.7.8/7.0.8.4 |
Now it fails due to ldap_fluff, since it's locked on active_support < 7 (https://github.com/theforeman/ldap_fluff/blob/master/ldap_fluff.gemspec#L21). Weird that it didn't fail before... Also, @ekohl and @adamruzicka or maybe @ShimShtein, since you have more experience with the codebase and Rails, could you please help me get why the test fails? I'll be out for the next week (30.09 - 06.10), so I hope we won't waste that week. Regarding the test: I think it's due to code reloading happening somewhere in the |
app/models/nic/base.rb
Outdated
@@ -124,11 +124,6 @@ class Jail < ::Safemode::Jail | |||
:children_mac_addresses, :nic_delay, :fqdn, :shortname, :type, :managed?, :bond?, :bmc?, :provision? | |||
end | |||
|
|||
# include STI inheritance column in audits |
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.
Hmm, re-visiting this, I think that's not a correct solution :/ Although, I didn't find this method being overridden for other STIs...
Finally, it's green and with minimal changes needed. Ready for full review. |
@@ -15,13 +15,5 @@ def new(attributes = nil, &block) | |||
super | |||
end | |||
end | |||
|
|||
def save(*args, **kwargs) |
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 this was the whole problem? That it set an instance variable on the class? That looks nasty and I wonder how that worked in the past.
From reading the Rails source I get the impression should handle this itself.
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.
Yes, it seems so. I couldn't find a reason why we did that at the first place, so I hope removing doesn't break anything.
I'm still going to try basic processes (CRUDing a virtual host, running jobs, some Katello-related stuff, oscap, etc) to verify PRs after everything open is green.
Without this patch Ansible-related scopes for Host::Managed.includes() would look like: [ { host_ansible_roles: :ansible_roles }, { ansible_role: [{ ansible_variables: [:lookup_values] }] } ], which for some reason worked before Rails 7. After this patch, it looks like: [ { host_ansible_roles: { ansible_role: [{ ansible_variables: [:lookup_values] }] } } ].
Based on #10131, but with additional commit needed for Rails upgrade.