Bug 980760

Summary: [origin_runtime_157]Postgresql-8.4 and postgresql-9.2 shouldn't be added to the same app
Product: OpenShift Online Reporter: Yan Du <yadu>
Component: PodAssignee: Abhishek Gupta <abhgupta>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: hasari, qiuzhang, yujzhang
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: devenv_3489 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-22 15:20:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 980739    

Description Yan Du 2013-07-03 08:00:53 UTC
Description of problem:
add Postgresql-8.4 to an app with postgresql-9.2 embedded,Postgresql-8.4 can be added successfully. run psql in user shell, show "psql 8.4.13" 

add Postgresql-9.2 to an app with postgresql-8.4 embedded,Postgresql-9.2 can be added successfully. run psql in user shell, show "psql version 8.4, server version 9.2"


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



How reproducible:
Always


Steps to Reproduce:

1.Create an app and added postgresql-9.2 to the app
$ rhc app create j7s jbossas-7 -s
$ rhc cartridge add -a j7s -c postgresql-9.2

2. add postgresql-8.4 to the same app should be 8.4 here?yes
$ rhc cartridge add -a j7s -c postgresql-8.4

3. ssh the app and env
$ rhc app ssh j7s
$ psql



Actual results:

[j7s-111.dev.rhcloud.com 574972695356251140259840]\> psql
psql (8.4.13)
Type "help" for help.


add Postgresql-9.2 an app with postgresql-8.4 embedded, the actual results is:

[j7s-111.dev.rhcloud.com 574972695356251140259840]\> psql
psql (8.4.13, server 9.2.4)
WARNING: psql version 8.4, server version 9.2.
         Some psql features might not work.
Type "help" for help.



Expected results:

should be failed when add Postgresql-8.4 to an app embedded postgresql-9.2, or vice versa. Or at least remind user that the old psql will not be used after new psql added

Comment 1 Yujie Zhang 2013-07-03 09:24:50 UTC
From website console, it will fail when adding postgresql-8.4 and postgresql-9.2 with the following error message:

Cartridge createdb: database creation failed: ERROR: database "python" already exists /var/lib/openshift/920236177523642741030912/postgresql/bin/post_install: line 18: error: command not found

We should have a more friendly error message for the failure, at least reduce the code error.

Comment 2 Hiro Asari 2013-07-03 14:02:12 UTC
*** Bug 980739 has been marked as a duplicate of this bug. ***

Comment 3 Hiro Asari 2013-07-05 02:44:59 UTC
The addition of postgresql-8.4 succeeds presumably because $PATH is somehow amenable to such a maneuver in this scenario; CLI manages to connect to the new PostgreSQL 8.4 instance instead of the existing 9.2 installation.

If 979442 cannot be fixed in a timely manner, we will need to get around this problem by fixing the CLI case. For a more friendly error message, I guess we can just trap the PostgreSQL error (duplicate schema name).

Comment 4 Hiro Asari 2013-07-09 21:52:43 UTC
*** Bug 979442 has been marked as a duplicate of this bug. ***

Comment 5 Abhishek Gupta 2013-07-09 23:44:05 UTC
Fixed with --> https://github.com/openshift/origin-server/pull/3024

Comment 6 Abhishek Gupta 2013-07-09 23:50:28 UTC
Note to QE: 
We have now fixed this both during initial application creation as well as when adding a cartridge to an existing application. As part of the verification for this bug, in addition to the test cases related to this bug, please also run regression tests for:

1. Application creation with multiple cartridges
2. Adding a cartridge to an application
3. Adding downloadable (manifest URL) cartridges
4. Removing a cartridge from an application (both redhat carts as well as downloadable carts)

Comment 7 openshift-github-bot 2013-07-10 08:44:17 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/82fff217b1c0cac0258e695d0918091bb27a0c0b
Fix for bug 980760
 - Preventing multiple versions of a cartridge from being added to the application

Comment 8 Hiro Asari 2013-07-10 13:24:09 UTC
The message can be a little off: https://github.com/openshift/origin-server/pull/3024/files#r5114152

$ bx bin/rhc cartridge add postgresql-8.4 -a rack
Adding postgresql-8.4 to application 'rack' ... postgresql-8.4 cannot co-exist with application cartridge postgresql-9.2

It's not a big problem, of course.

Comment 9 Abhishek Gupta 2013-07-10 19:05:17 UTC
Changed the error message to be more clear based on feedback received from Hiro.

https://github.com/openshift/origin-server/pull/3049

Comment 10 Abhishek Gupta 2013-07-10 20:59:11 UTC
Fixed in devenv_3480

Comment 11 Yan Du 2013-07-11 05:00:51 UTC
verified on devenv_3481
rhc-1.11.4


postgresql-8.4 and postgresql-9.2 still can be added to same app, if added a download cartridge


steps to reproduce:
1. prepare a postgresql-9.2 download cartridge
2. rhc app create r19 ruby-1.9 postgresql-8.4
3. cadd -a r19 https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml
4. rhc app show r19


[root@localhost ~]# rhc app show r19
r19 @ http://r19-aaa.dev.rhcloud.com/ (uuid: 222748430800175419621376)
----------------------------------------------------------------------
  Created: 12:37 AM
  Gears:   1 (defaults to small)
  Git URL: ssh://222748430800175419621376.rhcloud.com/~/git/r19.git/
  SSH:     222748430800175419621376.rhcloud.com

  ruby-1.9 (Ruby 1.9)
  -------------------
    Gears: Located with postgresql-8.4, dy-dypostgresql-9.2

  postgresql-8.4 (PostgreSQL Database 8.4)
  ----------------------------------------
    Gears:          Located with ruby-1.9, dy-dypostgresql-9.2
    Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT
    Database Name:  r19
    Password:       z7lzjHbNbqxR
    Username:       adminpjztiks

  dy-dypostgresql-9.2 (PostgreSQL Database 9.2)
  ---------------------------------------------
    From:           https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml
    Gears:          Located with ruby-1.9, postgresql-8.4
    Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT
    Database Name:  r19
    Password:       M_3HMQz3FZxf
    Username:       adminevxywgu


show the confict infomation Application creation with multiple cartridges and Adding a cartridge to an application


root@Daphne test]# rhc app create php php-5.3 postgresql-8.4 postgresql-9.2
Application Options
-------------------
  Namespace:  111
  Cartridges: php-5.3, postgresql-8.4, postgresql-9.2
  Gear Size:  default
  Scaling:    no

Creating application 'php' ... postgresql-9.2 cannot co-exist with postgresql-8.4 in the same application

[root@localhost test]# rhc cartridge add -a r18 -c postgresql-9.2
Adding postgresql-9.2 to application 'r18' ... postgresql-9.2 cannot co-exist with cartridge postgresql-8.4 in your application

[root@localhost ~]# rhc cartridge add -a j2s -c postgresql-8.4
Adding postgresql-8.4 to application 'j2s' ... postgresql-8.4 cannot co-exist with cartridge postgresql-9.2 in your application

Comment 12 Yan Du 2013-07-11 08:34:54 UTC
pls. just ignore #Comment 11

Retest the issue on devenv_3483 and do regression test according #Comment 6
rhc-1.11.4

1. Application creation with multiple cartridges

root@Daphne test]# rhc app create php php-5.3 postgresql-8.4 postgresql-9.2
Application Options
-------------------
  Namespace:  111
  Cartridges: php-5.3, postgresql-8.4, postgresql-9.2
  Gear Size:  default
  Scaling:    no

Creating application 'php' ... postgresql-9.2 cannot co-exist with postgresql-8.4 in the same application




2. Adding a cartridge to an application

[root@localhost test]# rhc cartridge add -a r18 -c postgresql-9.2
Adding postgresql-9.2 to application 'r18' ... postgresql-9.2 cannot co-exist with cartridge postgresql-8.4 in your application

[root@localhost ~]# rhc cartridge add -a j2s -c postgresql-8.4
Adding postgresql-8.4 to application 'j2s' ... postgresql-8.4 cannot co-exist with cartridge postgresql-9.2 in your application



3. Adding downloadable (manifest URL) cartridges

[root@Daphne test]# rhc cartridge add -a j2 https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml
The cartridge 'https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml' will be
downloaded and installed
Adding https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml to application 'j2' ... done

dy-dypostgresql-9.2 (PostgreSQL Database 9.2)
---------------------------------------------
  From:           https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml
  Gears:          Located with jbossews-2.0
  Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT
  Database Name:  j2
  Password:       kfKzt7TpEl5Z
  Username:       adminlimhmtj

PostgreSQL 9.2 database added.  Please make note of these credentials:
   Root User: adminlimhmtj
   Root Password: kfKzt7TpEl5Z
   Database Name: j2
Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT

[j2-111.dev.rhcloud.com 332107186515648966557696]\> psql
psql (9.2.4)
Type "help" for help.


4. Removing a cartridge from an application (both redhat carts as well as downloadable carts)

[root@localhost ~]# rhc cartridge remove -a php -c postgresql-9.2
Removing a cartridge is a destructive operation that may result in loss of data associated with the
cartridge.

Are you sure you wish to remove postgresql-9.2 from 'php'? (yes|no): yes

Removing postgresql-9.2 from 'php' ... removed


[root@localhost ~]# rhc cartridge remove -a j2 -c dy-dypostgresql-9.2
Removing a cartridge is a destructive operation that may result in loss of data associated with the
cartridge.

Are you sure you wish to remove dy-dypostgresql-9.2 from 'j2'? (yes|no): yes

Removing dy-dypostgresql-9.2 from 'j2' ... removed




5. still a little problem when add a download psql-9.2 to a app with redhat-psql-9.2 embedded.

it will shown "dy-dypostgresql-9.2 cannot co-exist with cartridge dy-dypostgresql-9.2 in your application"


[root@localhost ~]# rhc cartridge add -a phps -c postgresql-9.2
Adding postgresql-9.2 to application 'phps' ... done

postgresql-9.2 (PostgreSQL Database 9.2)
----------------------------------------
  Gears:          1 small
  Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT
  Database Name:  phps
  Password:       QdTceBsaS4US
  Username:       adminb6dtusd

PostgreSQL 9.2 database added.  Please make note of these credentials:
   Root User: adminb6dtusd
   Root Password: QdTceBsaS4US
   Database Name: phps
Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT

[root@localhost ~]# rhc cartridge add -a phps https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml
 
The cartridge 'https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml' will be
downloaded and installed
Adding https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml to application 'phps' ...
dy-dypostgresql-9.2 cannot co-exist with cartridge dy-dypostgresql-9.2 in your application

Comment 13 Abhishek Gupta 2013-07-11 20:24:15 UTC
Fixed with --> https://github.com/openshift/origin-server/pull/3068

Also, we are now removing downloaded cart manifest entry from application document in mongo (downloaded_cart_map list) if adding a url based cart fails. Please verify this fix as well.

Comment 14 openshift-github-bot 2013-07-11 22:19:35 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/5aa387e1deb2a66410fb9a08502261d3bccff1b5
Fix for bug 980760
 - fixing error message on validation failure
 - removing downloaded cart manifest entry from app if adding a url based cart fails

Comment 15 Yan Du 2013-07-12 02:45:52 UTC
Test on devenv_3489
rhc-1.11.4

[root@localhost ~]# rhc cartridge add -a j1 https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml
The cartridge 'https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml' will be
downloaded and installed
Adding https://raw.github.com/duyanyan/dypostgresql/master/metadata/manifest.yml to application 'j1' ... dy-dypostgresql-9.2 cannot co-exist with cartridge postgresql-9.2 in your application

move to verified.