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

refresh collation version when pulp_ansible is installed #863

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions definitions/procedures/restore/reindex_databases.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Procedures::Restore
class ReindexDatabases < ForemanMaintain::Procedure
include ForemanMaintain::Concerns::SystemService
include ForemanMaintain::Concerns::SystemHelpers

metadata do
description 'REINDEX databases'
Expand All @@ -16,6 +17,11 @@ def run

spinner.update('Reindexing the databases')
execute!('runuser - postgres -c "reindexdb -a"')
if check_min_version('python3.11-pulp-ansible', '0.20.0')
execute!('runuser -c '\
'\'echo "ALTER COLLATION pulp_ansible_semver REFRESH VERSION;"'\
'| psql pulpcore\' postgres')
Comment on lines +21 to +23
Copy link
Member

Choose a reason for hiding this comment

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

This isn't needed for remote DBs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not when they don't switch the OS :)

end
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions test/definitions/procedures/restore/reindex_databases_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
reindex_command = 'runuser - postgres -c "reindexdb -a"'

subject.stubs(:'execute!').with(reindex_command).returns(0)
subject.stubs(:check_min_version).returns(false)
result = run_procedure(subject)
assert result.success?, 'the procedure was expected to succeed'
end

it 'reindexes all DBs if DB is local and pulp-ansible is present' do
reindex_command = 'runuser - postgres -c "reindexdb -a"'
collate_command = 'runuser -c \'echo "ALTER COLLATION pulp_ansible_semver REFRESH VERSION;"'\
'| psql pulpcore\' postgres'

subject.stubs(:'execute!').with(reindex_command).returns(0)
subject.stubs(:check_min_version).with('python3.11-pulp-ansible', '0.20.0').returns(true)
subject.stubs(:'execute!').with(collate_command).returns(0)
result = run_procedure(subject)
assert result.success?, 'the procedure was expected to succeed'
end
Expand Down
Loading