-
Notifications
You must be signed in to change notification settings - Fork 293
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
Refs #37678 - Update evr migration to use DSL #11098
Conversation
@ekohl : I have this PR here based on your reviews: https://github.com/Katello/katello/pull/11087/files#diff-cbabbde17488e6694825cf9687cc62368facc56fa11e554341e05c994b99ca1d . |
execute <<~SQL | ||
DROP EXTENSION evr CASCADE; | ||
SQL | ||
disable_extension('evr') |
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.
If you want the CASCADE option you need to use force: true
:
disable_extension('evr') | |
disable_extension('evr', force: true) |
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.
My dev box is at this version: https://github.com/rails/rails/blob/v6.1.7.8/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb which does a cascade by default and doesn't accept the force parameter.
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.
Oh, so that's something we need to think about when we upgrade. I also now see it should have been force: :cascade
.
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.
Is it more dangerous to switch to using disable_extension
that could change into a non-cascading removal in the future than to keep using raw SQL?
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.
Worked well for me, tested on a 4.13 to nightly upgrade on Alma 8.
Did you also upgrade from PostgreSQL 12 to 13? I wouldn't expect this PR to just solve the upgrade issue. |
I ran through the upgrade steps but I can't remember if Postgres 13 was already on my 4.13 box. Do we need to test it on Postgres 12? At least from the docs, users should be on Postgres 13 when they upgrade to nightly / 4.14. Edit: confirmed I was already on Postgresql 13. I'll try again on 12, but I'm still curious why it's necessary (is it only to unblock nightly?). |
@ekohl Do we have any way of running nightlies against PRs? Is that a thing? |
You need to combine https://theforeman.github.io/forklift/development/#packit-pr-builds and https://theforeman.github.io/forklift/testing/#pipeline-testing but I don't know how well it works since it only should be set up on the last install, not the n-2 and n-1 versions. It's probably easier to start a pipeline, let it fail and then manually install the patched version and rerun
After that you can use |
I've reproduced the issue by upgrading from Katello 4.12 instead of from Katello 4.13.
After some investigation, it's looking like we may need to drop the evr extension from the database via the installer. Using |
This thread might have a way to actually change the ownership (scroll down): https://postgrespro.com/list/thread-id/2333512 |
Here's how I fixed it:
|
https://postgrespro.com/list/id/CANu8FiwUHNbRkpVCGRkzqvQZVxTm1v9NsrRWkWU-KKD-W-xfqQ@mail.gmail.com says you also need to update UPDATE pg_shdepend
SET refobjid = {oid_of_new_owner}
WHERE refobjid = {oid_of old_owner}
AND deptype = 'o'; And I doubt the user |
The I think the above will blanket change things from |
Some notes on using It looks like you can use the
|
For some reference, here's an untested script that I had chatgpt produce just for display purposes:
|
This seemed to be sufficient to drop the extension and upgrade:
|
Thoughts on something like this: theforeman/foreman-installer#955 |
External DB users will need to run the same command via our docs at upgrade time. |
Now that we know using the active record method doesn't fix nightly, do we need this PR? I'm a little worried about the method in question turning into a non-cascading drop. |
Closing. This is not needed anymore. We rewrote the new migration with reviews from here: |
What are the changes introduced in this pull request?
The evr migration was using SQL to drop the extension possibly causing privilege issues in EL8 upgrade pipeline in nightlies.
Considerations taken when implementing this change?
What are the testing steps for this pull request?
To test new installs, run bundle exec rails katello:reset
To test upgrades:
You could follow this on the dev box:
git reset --hard 8fed606
bundle exec rails katello:reset
Create and sync a repo to test data migration. You could also have some host registered to test data migration on installed_packages table
git checkout this branch
run db:migrate and make sure everything works normally.