-
Notifications
You must be signed in to change notification settings - Fork 136
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 #37717 - Update evr extension ownership to foreman #955
Conversation
13d9cc2
to
19812e3
Compare
I confirmed that dropping the extension also drops the related entry from |
I tested the installer with the chages here although I had to put the new code in a separate pre-hook file to be run..Suggestions on where to put this code if not this file? |
What about remote db users? Will those need to perform manual steps (we usually don't have enough permissions to change ownership of objects there) before the upgrade? |
Ya..They'll need to run the update ownership query manually as part of their upgrades. Will need to be documented. |
@evgeni docs update will go in theforeman/foreman-documentation#3167 unless someone gets to it first. |
Prepping a system for a test. |
Found an issue -- the postgres command cannot run because the postgres service is down during the installer run. We'll need to turn postgres on first. |
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'm not sure about the noop mode implementation here. I'd be tempted to change the log messages to Would do X
instead of Doing x`.
07411a5
to
0b060a5
Compare
5f2813a
to
83e3115
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.
LGTM -- I'll let @ekohl have the final say.
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.
Style wise I'm not that happy with the many conditionals and prefer the more verbose:
if app_value(:noop)
logger.debug('Would do X')
else
logger.debug('Doing X')
x()
end
My reasoning is that it's very easy to visually see the control flow.
Additionally, we already have debug statements in various methods, like start_services
and stop_services
. So you can simplify it to:
if app_value(:noop)
logger.debug('Would stop service postgresql')
else
stop_services(['postgresql'])
end
I'm wondering what you think about this.
83e3115
to
25feabd
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.
Thanks for updating. I think this is much easier to reason about and see where it could fail.
25feabd
to
030066c
Compare
8837316
to
14eb259
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 like how this is shaping up now. Some minor style comments.
14eb259
to
9b27653
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.
@evgeni I made may suggestions so I'd appreciate if you gave it a final ACK.
9b27653
to
61bf972
Compare
logger.debug("Updating ownership of the evr extension") | ||
_, success = execute_preformatted_as('postgres', "psql -d #{database} -c \"#{sql}\"", false, true) | ||
unless success | ||
logger.notice("Failed to update ownership of the evr extension.") |
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 think failing to update should be a warning?
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.
Warning or even error that halts execution?
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. It was a warning before, so that's what caught my eye.
What happens if it is not updated? Later the removal of the extension fails?
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.
Ya..The evr extension is dropped in katello migration here Katello/katello#11159 which assumes the foreman user is the owner of the extension. We could fail here instead of later on during db:migrate.
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.
Updated to fail and exit:
fail_and_exit("Failed to update ownership of the evr extension. Please make sure the following sql succeeds before proceeding: #{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.
61bf972
to
b1150db
Compare
I will need someone with superpowers to merge this one if this is good to go.. |
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.
Thanks!
Update ownership of evr extension to owner foreman to allow migrations to operate on it, specifically disable it.