Bug 960063

Summary: check DB objects before upgrade (owner engine)
Product: Red Hat Enterprise Virtualization Manager Reporter: Pavel Stehlik <pstehlik>
Component: ovirt-engineAssignee: Eli Mesika <emesika>
Status: CLOSED CURRENTRELEASE QA Contact: Jiri Belka <jbelka>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.2.0CC: acathrow, alonbl, bazulay, emesika, iheim, jkt, lpeer, Rhev-m-bugs, yeylon
Target Milestone: ---Keywords: Triaged
Target Release: 3.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: infra
Fixed In Version: is10 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: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pavel Stehlik 2013-05-06 14:11:44 UTC
Description of problem:
 Check & stop upgrade in case there are objects in DB not owned by engine user. 
 This routine should prevent from failing upgrade in later stage. This could currently happened in case user perform materialized views (& other changes) by different user (eg: postgres).


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. login as user postgres
2. replace view - eg:  creatematerializedviewas('vm_device_view',10);
3.
  
Actual results:
upgrade will fail & rollback will run

Expected results:
put permissions check at very start of upgrade script among other checks

Additional info:

Comment 1 Eli Mesika 2013-05-07 08:07:53 UTC
We must first create our objects in our own schema for that and not in 'public'

Comment 2 Eli Mesika 2013-05-07 21:10:16 UTC
this is what had been concluded with Barak

until BZ 951923 will be implemented in 3.3 we will have a temporary utility for this that will check only Materialized Views definitions for proper ownership by user 'engine'

Comment 4 Eli Mesika 2013-07-08 11:59:51 UTC
Proposed solution :

1) Setup will validate objects owner and exit with a message listing all objects that are not owned by engine

2) The MV SPs that creates database objects will use PG current_user to verify that the user creating the MVs is engine

Comment 5 Alon Bar-Lev 2013-07-08 12:14:18 UTC
(In reply to Eli Mesika from comment #4)
> Proposed solution :
> 
> 1) Setup will validate objects owner and exit with a message listing all
> objects that are not owned by engine

In other words: if object were created with user other than the engine user, these must be manually fixed before installation can proceed.

Please ACK.

Comment 6 Eli Mesika 2013-07-29 09:12:13 UTC
(In reply to Alon Bar-Lev from comment #5)
> (In reply to Eli Mesika from comment #4)
> > Proposed solution :
> > 
> > 1) Setup will validate objects owner and exit with a message listing all
> > objects that are not owned by engine
> 
> In other words: if object were created with user other than the engine user,
> these must be manually fixed before installation can proceed.
> 
> Please ACK.

ACK

Comment 7 Eli Mesika 2013-08-11 14:03:08 UTC
(In reply to Eli Mesika from comment #4)
> Proposed solution :
> 
> 1) Setup will validate objects owner and exit with a message listing all
> objects that are not owned by engine
> 
> 2) The MV SPs that creates database objects will use PG current_user to
> verify that the user creating the MVs is engine

Patch addresses issue 2)
1) should be done by the installer

Comment 8 Eli Mesika 2013-08-12 13:01:39 UTC
fixed in commit : af7e115

Comment 9 Jiri Belka 2013-10-31 15:06:16 UTC
Please provide verification steps. Thank you.

Comment 10 Eli Mesika 2013-10-31 15:34:35 UTC
(In reply to Jiri Belka from comment #9)
> Please provide verification steps. Thank you.

1) create an empty database from root account run
 su - postgres -c "psql -d template1 -c \"create database engine_960063  owner engine;\""

2) from dbscripts dir run
   ./create_schema.sh -u engine -d engine_960063

3) run
   psql -U postgres -c "select * from  CreateMaterializedView('v_vds', 'vds', 30, false, 60);" engine_960063 

you should get:

ERROR:  Materialized view v_vds should be created with user 'engine'.

Comment 11 Jiri Belka 2013-10-31 16:12:00 UTC
ok, is20.1

Comment 12 Itamar Heim 2014-01-21 22:26:34 UTC
Closing - RHEV 3.3 Released

Comment 13 Itamar Heim 2014-01-21 22:29:59 UTC
Closing - RHEV 3.3 Released