Bug 1022691 - check database object ownership to engine before upgrade
check database object ownership to engine before upgrade
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine-setup (Show other bugs)
3.3.0
Unspecified Unspecified
high Severity high
: ---
: 3.3.0
Assigned To: Sandro Bonazzola
sefi litmanovich
integration
: Triaged
Depends On:
Blocks: 3.3snap3
  Show dependency treegraph
 
Reported: 2013-10-23 15:26 EDT by Alon Bar-Lev
Modified: 2014-01-21 17:29 EST (History)
11 users (show)

See Also:
Fixed In Version: is24
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 20935 None None None Never
oVirt gerrit 20968 None None None Never
oVirt gerrit 21277 None None None Never

  None (edit)
Description Alon Bar-Lev 2013-10-23 15:26:01 EDT
During legacy backup/restore procedure, users used postgres user instead of engine user to restore, this leads to have object owned by postgres.

We need to abort setup in this case, asking user to run the ownership change script[1].

Eli, please specify sql statements to run and assign to sandaro.

Thanks!

[1] http://gerrit.ovirt.org/#/c/18682/
Comment 1 Eli Mesika 2013-10-24 01:34:44 EDT
(In reply to Alon Bar-Lev from comment #0)
> During legacy backup/restore procedure, users used postgres user instead of
> engine user to restore, this leads to have object owned by postgres.
> 
> We need to abort setup in this case, asking user to run the ownership change
> script[1].
> 
> Eli, please specify sql statements to run and assign to sandaro.

pg_dump -s  -h <server> -p <port> -U <user> <db>|grep -i 'owner to postgres' |wc -l

This should return 0 , if returns something greater than that , fail and ask the user to run the script [1]

[1] http://gerrit.ovirt.org/#/c/18682/
Comment 2 Alon Bar-Lev 2013-10-24 04:13:24 EDT
(In reply to Eli Mesika from comment #1)
> (In reply to Alon Bar-Lev from comment #0)
> > During legacy backup/restore procedure, users used postgres user instead of
> > engine user to restore, this leads to have object owned by postgres.
> > 
> > We need to abort setup in this case, asking user to run the ownership change
> > script[1].
> > 
> > Eli, please specify sql statements to run and assign to sandaro.
> 
> pg_dump -s  -h <server> -p <port> -U <user> <db>|grep -i 'owner to postgres'
> |wc -l
> 
> This should return 0 , if returns something greater than that , fail and ask
> the user to run the script [1]
> 
> [1] http://gerrit.ovirt.org/#/c/18682/

Eli, I am very sorry... but re-assign...

I would really really prefer to have sql statement for that that I can execute within opened connection to the database over using pg_dump. Is that possible?
Comment 3 Eli Mesika 2013-10-24 05:02:25 EDT
(In reply to Alon Bar-Lev from comment #2)
> (In reply to Eli Mesika from comment #1)
> > (In reply to Alon Bar-Lev from comment #0)

> I would really really prefer to have sql statement for that that I can
> execute within opened connection to the database over using pg_dump. Is that
> possible?


select nsp.nspname as object_schema,
       cls.relname as object_name,
       rol.rolname as owner,
       case cls.relkind
         when 'r' then 'TABLE'
         when 'i' then 'INDEX'
         when 'S' then 'SEQUENCE'
         when 'v' then 'VIEW'
         when 'c' then 'TYPE'
         else cls.relkind::text
       end as object_type
from pg_class cls
  join pg_roles rol on rol.oid = cls.relowner
  join pg_namespace nsp on nsp.oid = cls.relnamespace
where nsp.nspname not in ('information_schema', 'pg_catalog')
  and nsp.nspname not like 'pg_toast%'
  and rol.rolname != 'engine'
order by nsp.nspname, cls.relname;
Comment 4 Sandro Bonazzola 2013-11-07 09:38:53 EST
merged on upstream master and 3.3 branches, 
 Change-Id: I45b655e88c25dd51e567405cc6747b42dfd8a98b
Comment 5 Alon Bar-Lev 2013-11-14 09:18:23 EST
Not merged completely.
Comment 6 sefi litmanovich 2013-12-04 05:14:26 EST
Verified on RHEL6.5 RHEVM3.3 IS25.

steps of verification:

1) on a running environment with rhevm3.2.5 sf22, entered with user engine to DB and altered ownership of users table from engine to postgres
2) upgraded rhevm to 3.3 IS25.
3) engine-setup:

Failed to execute stage 'Setup validation': Cannot upgrade the database schema due to wrong ownership of some database entities.
Please execute: /usr/share/ovirt-engine/setup/dbutils/changedbowner.sh -s localhost -p 5432 -d engine -f postgres -t engine
Using the password of the "postgres" user.

4)/usr/share/ovirt-engine/setup/dbutils/changedbowner.sh -s localhost -p 5432 -d engine -f postgres -t engine

5) engine-setup - works fine
Comment 7 Itamar Heim 2014-01-21 17:26:25 EST
Closing - RHEV 3.3 Released
Comment 8 Itamar Heim 2014-01-21 17:29:50 EST
Closing - RHEV 3.3 Released

Note You need to log in before you can comment on or make changes to this bug.