Bug 984811 - The OPENSHIFT_POSTGRESQL_VERSION environment variable is missing for some old applications which originally do not have OPENSHIFT_POSTGRES_VERSION on STG
The OPENSHIFT_POSTGRESQL_VERSION environment variable is missing for some old...
Status: CLOSED CURRENTRELEASE
Product: OpenShift Online
Classification: Red Hat
Component: Containers (Show other bugs)
2.x
Unspecified Unspecified
high Severity medium
: ---
: ---
Assigned To: Hiro Asari
libra bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-16 01:45 EDT by Jianwei Hou
Modified: 2015-05-14 19:24 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-22 11:24:42 EDT
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)

  None (edit)
Description Jianwei Hou 2013-07-16 01:45:09 EDT
Description of problem:
The OPENSHIFT_POSTGRESQL_VERSION environment variable is missing for some old applications that have postgresql-8.4 cartridge(which got created before v2 cartridge were introduced). They do not have OPENSHIFT_POSTGRES_VERSION originally.

The gear app name and UUIDs are as follows:
python27 515268a92587c8e5d7000061 
zend56 515268f82587c8e5d7000078
jbossews2 51650ae7dbd93c1fb4000005
railss 5152851c2587c833bd0001e0

Version-Release number of selected component (if applicable):
On STG
Didn't reproduce this on INT
Probably reproducible on prod

How reproducible:
Always

Steps to Reproduce:
1. SSH into a gear which has postgresql-8.4, run env|grep POST, 

Actual results:
Found that the 
OPENSHIFT_POSTGRESQL_VERSION is missing.

Expected results:
The environment variable should exist.

Additional info:
Set it as low since it does not affect any functionality
Comment 1 Jianwei Hou 2013-07-16 01:52:06 EDT
There is also a small problem caused by the bug, because $OPENSHIFT_POSTGRESQL_VERSION is missing, when you type 'psql' from rhcsh, a line of bash error is printed:

[jbossews2-sprint25.stg.rhcloud.com 51650ae7dbd93c1fb4000005]\> psql
+ psql
+ pghost=/var/lib/openshift/51650ae7dbd93c1fb4000005/postgresql//socket/
+ pattern='^/'
+ [[ ! /var/lib/openshift/51650ae7dbd93c1fb4000005/postgresql//socket/ =~ ^/ ]]
+ pguser=admin
+ pgpassword=vHIe542stdjy
+ pgdatabase=jbossews2
+ extra_args=
+ grep HISTFILE /var/lib/openshift/51650ae7dbd93c1fb4000005//.psqlrc
+ '[' 0 -ne 0 ']'
++ which psql
+ CMD=/usr/bin/psql
+ '[' = 9.2 ']'
bash: [: =: unary operator expected
+ cmd='  PGHOST=/var/lib/openshift/51650ae7dbd93c1fb4000005/postgresql//socket/     PGPORT=     PGUSER=admin     PGPASSWORD=vHIe542stdjy     PGDATABASE=jbossews2     /usr/bin/psql  
  '
++ eval PGHOST=/var/lib/openshift/51650ae7dbd93c1fb4000005/postgresql//socket/ PGPORT= PGUSER=admin PGPASSWORD=vHIe542stdjy PGDATABASE=jbossews2 /usr/bin/psql
psql (8.4.13)
Type "help" for help.

jbossews2=# 


In our source code, this is cause by line #144 in /node/misc/bin/rhcsh
<---------------------------------->
  if [ $OPENSHIFT_POSTGRESQL_VERSION = '9.2' ]; then
<---------------------------------->

It could be work arounded:
[jbossews2-sprint25.stg.rhcloud.com 51650ae7dbd93c1fb4000005]\> export OPENSHIFT_POSTGRESQL_VERSION='8.4'
[jbossews2-sprint25.stg.rhcloud.com 51650ae7dbd93c1fb4000005]\> psql
psql (8.4.13)
Type "help" for help.

jbossews2=#
Comment 2 Hiro Asari 2013-07-16 10:14:47 EDT
Have these cartridges been migrated?

bin/setup will try to detect the older environment variable and fix it: https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-postgresql/bin/setup#L5-L8
Comment 3 Xiaoli Tian 2013-07-16 10:21:45 EDT
(In reply to Hiro Asari from comment #2)
> Have these cartridges been migrated?
> 
> bin/setup will try to detect the older environment variable and fix it:
> https://github.com/openshift/origin-server/blob/master/cartridges/openshift-
> origin-cartridge-postgresql/bin/setup#L5-L8

Hi, Hiro

The problem is some old application with postgresql which was added at an very old time point (maybe before V2) does not have the older environment variable  OPENSHIFT_POSTGRES_VERSION originally, that means not all old postgresql that's  in current PROD has this old environment variable, then it can not have the new environment variable either even if after migration.

Thanks
Comment 4 Hiro Asari 2013-07-16 10:23:08 EDT
Thank you for the clarification. I'll look into this now.
Comment 6 openshift-github-bot 2013-07-16 14:50:40 EDT
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/8e71b71521585fc9069dba6158f9bd8f27d09f5f
Bug 984811

As is the case with a very old cartridge, if both
OPENSHIFT_POSTGRES_VERSION and OPENSHIFT_POSTGRESQL_VERSION do
not exist in postgresql/env directory, create one with '8.4'.

Hard coding this value should be OK, since 8.4 was the only supported
version of PostgreSQL for the cartridge this condition ever applies.
Comment 7 Hiro Asari 2013-07-16 15:14:27 EDT
Merged to stage.
Comment 8 Jianwei Hou 2013-07-16 22:37:57 EDT
Verified on STG, the problem is fixed by above commit:

[python27-sprint25.stg.rhcloud.com 515268a92587c8e5d7000061]\> env|grep VERSION
CARTRIDGE_VERSION_2=2
OPENSHIFT_PYTHON_VERSION=2.7
OPENSHIFT_POSTGRESQL_VERSION=8.4
[python27-sprint25.stg.rhcloud.com 515268a92587c8e5d7000061]\> hostname 
ex-std-node2.stg.rhcloud.com

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