Bug 1838845

Summary: Metering operator can't connect to postgres DB from Operator Hub
Product: OpenShift Container Platform Reporter: Peter Ruan <pruan>
Component: Metering OperatorAssignee: tflannag
Status: CLOSED ERRATA QA Contact: Peter Ruan <pruan>
Severity: high Docs Contact:
Priority: high    
Version: 4.7CC: btofel, jmalde, sd-operator-metering, tflannag
Target Milestone: ---   
Target Release: 4.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-24 15:01:20 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: 1917590    

Description Peter Ruan 2020-05-21 21:22:21 UTC
Description of problem:
Metering operator can't connect to postgres DB from Operator Hub even though the installation show all pods are running.



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

How reproducible:
always

Steps to Reproduce:
1. install postgres 10 DB from operator hub
2. expose the postgres service (oc expose svc xxx) and note the cluster ip
2. install metering operator from operator hub
3. configure meteringconfig to use postgres as storage using the following config (replace with cluster ip corresponding to your actual cluster)

apiVersion: metering.openshift.io/v1
kind: MeteringConfig
metadata:
  name: operator-metering
  namespace: openshift-metering
spec:
  storage:
    hive:
      type: "s3"
      s3:
        bucket: "qe-metering-pruan-mac"
        region: "us-west-1"
        secretName: "my-aws-secret"
        # Set to false if you want to provide an existing bucket, instead of
        # having Metering create the bucket on your behalf.
        createBucket: true
      type: s3
    type: hive
  reporting-operator:
    spec:
      resources:
        limits:
          cpu: 500m
          memory: 500Mi
        requests:
          cpu: 50m
          memory: 100Mi
  presto:
    spec:
      coordinator:
        resources:
          limits:
            cpu: 1
            memory: 2Gi
          requests:
            cpu: 500m
            memory: 1Gi

  hive:
    spec:
      config:
        db:
          url: "jdbc:postgresql://172.30.60.85:5432/hive"
          driver: "org.postgresql.Driver"
          username: "pruan"
          password: "redhat-2020"
      metastore:
        storage:
          create: false
        resources:
          limits:
            cpu: 2
            memory: 2Gi
          requests:
            cpu: 500m
            memory: 650Mi
      server:
        resources:
          limits:
            cpu: 1
            memory: 1Gi
          requests:
            cpu: 500m
            memory: 500Mi




Actual results:
no table created in the `hive` table within psql

postgres=# \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 hive      | pruan    | UTF8     | en_US.utf8 | en_US.utf8 | 
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(4 rows)

postgres=# \c hive
You are now connected to database "hive" as user "postgres".
hive=# select current_user;
 current_user 
--------------
 postgres
(1 row)

hive=# \dt
Did not find any relations.


Expected results:
db created with tables.

Additional info:

Comment 1 Peter Ruan 2020-05-21 22:40:17 UTC
metastore container run log

http://pastebin.test.redhat.com/867634

Comment 20 Peter Ruan 2021-02-04 01:38:26 UTC
verified 

$ oc get pods
NAME                                  READY   STATUS      RESTARTS   AGE
hive-metastore-0                      2/2     Running     0          35m
hive-server-0                         3/3     Running     0          35m
metering-operator-748b647694-hhmmj    1/1     Running     0          6h18m
postgresql-1-8x99n                    1/1     Running     0          121m
postgresql-1-deploy                   0/1     Completed   0          121m
presto-coordinator-0                  2/2     Running     0          35m
reporting-operator-6ff56ccc6d-86jw9   2/2     Running     0          34m


apiVersion: metering.openshift.io/v1
kind: MeteringConfig
metadata:
  name: operator-metering
  namespace: openshift-metering
spec:
  storage:
    hive:
      s3:
        bucket: "qe-metering-pruan-mac"
        region: "us-west-1"
        secretName: "my-aws-secret"
        # Set to false if you want to provide an existing bucket, instead of
        # having Metering create the bucket on your behalf.
        createBucket: true
      type: s3
    type: hive
  reporting-operator:
    spec:
      resources:
        limits:
          cpu: 500m
          memory: 500Mi
        requests:
          cpu: 50m
          memory: 100Mi
  presto:
    spec:
      coordinator:
        resources:
          limits:
            cpu: 1
            memory: 2Gi
          requests:
            cpu: 500m
            memory: 1Gi

  hive:
    spec:
      config:
        db:
          url: "jdbc:postgresql://172.30.86.168:5432/hive"
          driver: "org.postgresql.Driver"
          username: "pruan"
          password: "redhat-2020"
          autoCreateMetastoreSchema: false
      metastore:
        storage:
          create: false
        resources:
          limits:
            cpu: 2
            memory: 2Gi
          requests:
            cpu: 500m
            memory: 650Mi
      server:
        resources:
          limits:
            cpu: 1
            memory: 1Gi
          requests:
            cpu: 500m
            memory: 500Mi



starting PostgreSQL 12.5 on x86_64-redhat-linux-gnu

Comment 23 errata-xmlrpc 2021-02-24 15:01:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.7.0 extras and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:5635