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

ovirt-engine-setup database checks: being member of the database owner is also ok #842

Merged
merged 1 commit into from
May 4, 2023

Conversation

betanummeric
Copy link

fixes issue #841

This PR makes the database check succeed also when some object is not owned by the user, but the user is member of some role which owns the object.

The pg_catalog.pg_has_role function is available since postgres 8.1 (released in 2005).
The argument 'usage' means that the user does not need to explicitly switch to the owner role using SET ROLE, which may be necessary with the alternative 'member'.

is also ok

see oVirt#841

Signed-off-by: Felix Hamme <felix.hamme@ionos.com>
@didib
Copy link
Member

didib commented Apr 25, 2023

Makes sense. Did you verify backup/restore?

@emesika might want to review as well.

@betanummeric
Copy link
Author

@didib Backup and restore are tested successfully.

@michalskrivanek
Copy link
Member

lgtm, let's run ost

@michalskrivanek
Copy link
Member

/ost

@didib
Copy link
Member

didib commented Apr 27, 2023

Sorry for being annoying. Did you test also the backup/restore done by engine-setup itself? It backs up the database at some point, and clears and restores it if there was a failure and it needs to rollback. To cause it to fail, you can simply press ^C at a strategic point - after backup, before finishing the transaction - or something like this:

dnf install otopi-debug-plugins
# install and setup an engine with your patch and with a DB configured as you want
OTOPI_FORCE_FAIL_STAGE=STAGE_MISC OTOPI_FORCE_FAIL_PRIORITY=PRIORITY_LOW engine-setup

@betanummeric
Copy link
Author

These commands are tested:

engine-setup --reconfigure-components
engine-backup --mode=backup --scope=all --file=ovirt-engine-backup-test.backup --log=ovirt-engine-backup.log
engine-backup --mode=restore --scope=db --file=ovirt-engine-backup-test.backup --log=ovirt-engine-restore.log --restore-permissions

Is this sufficient?

@didib
Copy link
Member

didib commented Apr 27, 2023

These commands are tested:

engine-setup --reconfigure-components
engine-backup --mode=backup --scope=all --file=ovirt-engine-backup-test.backup --log=ovirt-engine-backup.log
engine-backup --mode=restore --scope=db --file=ovirt-engine-backup-test.backup --log=ovirt-engine-restore.log --restore-permissions

Is this sufficient?

It is, for testing engine-backup. But engine-setup has its own backup/restore code, which does not use engine-backup.

@didib
Copy link
Member

didib commented Apr 27, 2023

To clarify: engine-setup has to backup, and potentially restore, only on upgrades - so that if the upgrade fails, you get back to your original state, before trying to upgrade. So you should first do a clean setup, then upgrade (can be to same version), and fail it in the middle of upgrade - after it backed up and before it committed.

@betanummeric
Copy link
Author

I can now also confirm a successful restore upon a failed upgrade (interrupted with ctrl+c). The engine worked after that.

[ INFO  ] Cleaning async tasks and compensations
[ INFO  ] Unlocking existing entities
[ INFO  ] Checking the Engine database consistency
[ INFO  ] Stage: Transaction setup
[ INFO  ] Stopping engine service
[ INFO  ] Stopping ovirt-fence-kdump-listener service
[ INFO  ] Stopping dwh service
[ INFO  ] Stopping vmconsole-proxy service
[ INFO  ] Stopping websocket-proxy service
[ INFO  ] Stopping service: grafana-server
[ INFO  ] Stage: Misc configuration (early)
[ INFO  ] Stage: Package installation
[ INFO  ] Stage: Misc configuration
[ INFO  ] Running vacuum full on the engine schema
[ INFO  ] Running vacuum full elapsed 0:00:02.563703
[ INFO  ] Upgrading CA
[ INFO  ] Configuring WebSocket Proxy
[ INFO  ] Backing up ***:engine to '/var/lib/ovirt-engine/backups/engine-20230504075229.1edo8krs.dump'.                                                                                                                  
[ INFO  ] Creating/refreshing Engine database schema
^C[ ERROR ] Failed to execute stage 'Misc configuration': SIG2
[ INFO  ] Rolling back database schema
[ INFO  ] Clearing Engine database engine
[ INFO  ] Restoring Engine database engine
[ INFO  ] Restoring file '/var/lib/ovirt-engine/backups/engine-20230504075229.1edo8krs.dump' to ***:engine.                                                                                                              
[ INFO  ] Stage: Clean up
          Log file is located at /var/log/ovirt-engine/setup/ovirt-engine-setup-20230504075206-ozuwpw.log
[ INFO  ] Generating answer file '/var/lib/ovirt-engine/setup/answers/20230504075244-setup.conf'
[ INFO  ] Stage: Pre-termination
[ INFO  ] Stage: Termination
[ ERROR ] Execution of setup failed

@didib
Copy link
Member

didib commented May 4, 2023

LGTM, merging. Thanks!

@didib didib merged commit d37b4f7 into oVirt:master May 4, 2023
@betanummeric
Copy link
Author

thanks for merging :)

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.

4 participants