Skip to content

postgres-operator health check fails and results in - psql: could not connect to server: No such file or directory #406

Closed
@nchiluku

Description

@nchiluku
  1. The problem is reproducible on single master as well as multi master Kubernetes Cluster. Kubernetes installed successfully.
    kubectl get nodes
    NAME STATUS ROLES AGE VERSION
    master01 Ready master 6d v1.10.4
    worker01 Ready node 6d v1.10.4
    worker02 Ready node 6d v1.10.4
  2. I tried setting postgres-operator using https://crunchydata.github.io/postgres-operator/stable/installation/manual-installation/.
    a) Defined variables in .bashrc. Not repeating them here.
    b) mkdir -p $HOME/odev/src $HOME/odev/bin $HOME/odev/pkg $GOPATH/src/github.com/crunchydata/
    cd $GOPATH/src/github.com/crunchydata
    git clone https://github.com/CrunchyData/postgres-operator.git
    cd postgres-operator
    git checkout 3.3.0
    c) Created the namespace demo
    d) Create HostPath Directory
    sudo mkdir /data
    sudo chmod 777 /data
    e) Create some sample Persistent Volumes using the following script:
    $COROOT/pv/create-pv.sh
    d) Deployed using build images
    make pull
    cd $HOME
    tar xvzf ./postgres-operator.3.3.tar.gz
    copy pgo client to somewhere in your path (e.g. cp pgo /usr/local/bin)
    cd $COROOT
    make installrbac
    make deployoperator
    e) postgres-operator ran successfully.
    kubectl get pod --selector=name=postgres-operator
    NAME READY STATUS RESTARTS AGE
    postgres-operator-77f949bf58-lv8j6 2/2 Running 0 2d
    f) kubectl get crd
    NAME AGE
    pgbackups.cr.client-go.k8s.io 3d
    pgclusters.cr.client-go.k8s.io 3d
    pgingests.cr.client-go.k8s.io 3d
    pgpolicies.cr.client-go.k8s.io 3d
    pgreplicas.cr.client-go.k8s.io 3d
    pgtasks.cr.client-go.k8s.io 3d
    pgupgrades.cr.client-go.k8s.io 3d
    g) kubectl get service postgres-operator
    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    postgres-operator ClusterIP 10.233.10.224 8443/TCP 2d
    export CO_APISERVER_URL=https://10.233.10.224:8443
    h)pgo version
    pgo client version 3.3.0
    apiserver version 3.3.0
    i) pgo create cluster mycluster --pgpool
    NAME READY STATUS RESTARTS AGE
    pg-test-664467cc8d-jqfs8 0/1 Running 0 7h
    pg-test-pgpool-64547c847f-fbfsl 1/1 Running 0 1d
    postgres-operator-77f949bf58-lv8j6 2/2 Running 0 1d
    j) kubectl describe pod podname
    Events:
    Type Reason Age From Message

Warning Unhealthy 2m (x2608 over 7h) kubelet, dev2-worker01 (combined from similar events): Readiness probe failed: Mon Oct 15 16:48:36 UTC 2018 INFO: Setting PGROOT to /usr/pgsql-10.
psql: could not connect to server: No such file or directory

Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

3) Added below to postgres-operator/examples/custom-config/pg_hba.conf file and reinstalled the cluster. The behavior did not change.
hostnossl all all 0.0.0.0/0 trust
host all all 0.0.0.0/0 trust
SAME error
Warning Unhealthy 2m (x2608 over 7h) kubelet, dev2-worker01 (combined from similar events): Readiness probe failed: Mon Oct 15 16:48:36 UTC 2018 INFO: Setting PGROOT to /usr/pgsql-10.
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

4) Tried 2.6.0 version too.
Same issue, encountered same health check issues.
psql -h 127.0.0.1 -U testuser postgres
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
5) After port forwarding tried again:
psql -h 127.0.0.1 -U postgres postgres
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
6) kubectl exec pg-test-664467cc8d-jqfs8 -it /bin/bash
bash-4.2$ psql -h localhost
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

  • [x ] bug report
  • feature request
  • support request

Do you want to request a feature or report a bug?
Bug report

What is the current behavior?
kubectl exec -it pg-test-664467cc8d-lrmnt /bin/bash
bash-4.2$ psql -h localhost
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

If the current behavior is a bug, please provide the steps to reproduce:
Please see above.

What is the expected behavior?
Should connect to postgres using psql

What is the motivation or use case for changing the behavior?
None

Other information (e.g. detailed explanation, related issues, suggestions how to fix, etc)
Please see above.

Please tell us about your environment:

  • Operating

System:
Centos7

  • Container

Image Tag:
Can reproduce on 2.7, 3.3.0 and 3.2.0

  • PostgreSQL

Version:
Tried 9 and 10

  • Platform

(Docker, Kubernetes, OpenShift):
kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.4", GitCommit:"5ca598b4ba5abb89bb773071ce452e33fb66339d", GitTreeState:"clean", BuildDate:"2018-06-06T08:00:59Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.4", GitCommit:"5ca598b4ba5abb89bb773071ce452e33fb66339d", GitTreeState:"clean", BuildDate:"2018-06-06T08:00:59Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

  • Platform

Version:
uname -a
Linux 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions