Skip to content
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

Halt upgrades if evr is not owned by foreman #953

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ianballou
Copy link
Contributor

Halts upgrades if the evr extension in Katello external DBs are not owned by foreman. Skips the checks if the evr extension does not exist.

Related installer PR: theforeman/foreman-installer#984

def run
# No check is needed if the evr extension does not exist
evr_exists = find_evr_exists
return if !evr_exists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just turn this into more of a evr_exists? method, so that you can reduce these two lines to:

return unless evr_exists?

error_msg = 'The evr extension is not owned by the foreman DB owner. Please run the following command to fix it: ' \
"UPDATE pg_extension SET extowner = (SELECT oid FROM pg_authid WHERE rolname='foreman') WHERE extname='evr';"
foreman_owns_evr = find_foreman_owns_evr
fail!(error_msg) if !foreman_owns_evr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same idea here, switch to foreman_owns_evr? method name and then do:

fail!(error_msg) unless foreman_own_evr?

fail!('Could not determine if the evr extension is owned by the foreman DB owner')
end

def self.query_for_evr_existence
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not need to be a class method

SQL
end

def self.query_to_find_evr_owner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not need to be a class method

end

def run
# No check is needed if the evr extension does not exist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can drop this, the code reads well enough to tell me what's happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants