Skip to content

port-forward closed on specific postgres command #111825

@Jeansen

Description

@Jeansen

What happened?

I've created a postgres cluster by the readme via helm and a simple manifest (see https://github.com/zalando).

I do port-forward acid-minimal-cluster-0 8098:5432 and then `psql -h localhost -p 8098 -U postgres'. I paste the password from the kubernetes secret created by the operator.

While being connected via psql, I call `\c foo', the connection will then be closed with:

E0812 19:41:10.188388 2778901 portforward.go:406] an error occurred forwarding 8098 -> 5432: error forwarding port 5432 to pod 3902fddf18f9819a2114c71be1e745f7610b8695a8a3fa1c838525af3f1576e4, uid : port forward into network namespace "/var/run/netns/eeb57a40-33aa-4feb-a081-b3609a272a89": read tcp [::1]:42206->[::1]:5432: read: connection reset by peer

BUT, if I call the psql with a direct selection of a database, like so: `psql -h localhost -p 8098 -U postgres -d foo', I can do all sorts of calls, like select, create an so on.

What did you expect to happen?

I'd expect no disconnection, no matter what command I run during a session with psql.

How can we reproduce it (as minimally and precisely as possible)?

git clone https://github.com/zalando/postgres-operator.git
helm repo add postgres-operator-charts https://opensource.zalando.com/postgres-operator/charts/postgres-operator
helm install postgres-operator postgres-operator-charts/postgres-operator

#From within the git repo, above
kubectl create -f minimal-postgres-manifest.yaml

port-forward acid-minimal-cluster-0 8098:5432
#Install posgresql-client, e.g. sudo apt install postgresql-client
psql -h localhost -p 8098 -U postgres
#paste Password from kubernetes secret and then, while in qsql run
 \c foo

Anything else we need to know?

Using PGSSLMODE=disable psql -h localhost -p 8098 -U postgres works so far, as there will be no connection drop, but uploads of larger files will hang.

Using the solution with a scat from here https://stackoverflow.com/questions/70762591/kubectl-port-forwarding-to-remote-postgres-port helped, but then data transfers are terribly slow!

Kubernetes version

Details
Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.3", GitCommit:"aef86a93758dc3cb2c658dd9657ab4ad4afc21cb", GitTreeState:"clean", BuildDate:"2022-07-13T14:30:46Z", GoVersion:"go1.18.3", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.4
Server Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.3", GitCommit:"aef86a93758dc3cb2c658dd9657ab4ad4afc21cb", GitTreeState:"clean", BuildDate:"2022-07-13T14:23:26Z", GoVersion:"go1.18.3", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

Details On premise

OS version

Details
PRETTY_NAME="Debian GNU/Linux bookworm/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# paste output here

Install tools

Details

Container runtime (CRI) and version (if applicable)

Details crio 1.24.2

Related plugins (CNI, CSI, ...) and versions (if applicable)

Details ```console Calico: Client Version: v3.23.3 Git commit: 3a3559be1 Cluster Version: v3.23.3 Cluster Type: typha,kdd,k8s,operator,bgp,kubeadm ```

PROMETHEUS_VERSION='14.12.0'
ROOK_VERSION='v1.9.3'
DASHBOARD_VERSION='5.4.1'
METRICS_VERSION='3.8.2'
METALLB_VERSION='0.12.1'
INGRESS_VERSION='4.1.1'

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/appsCategorizes an issue or PR as relevant to SIG Apps.sig/cliCategorizes an issue or PR as relevant to SIG CLI.

    Type

    No type

    Projects

    Status

    Needs Triage

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions