Replication broken in dual stack clusters

Description

In a dual stack cluster the replication fails with the following error:

2022-05-31 15:07:59,371 ERROR: Exception when working with master via replication connection Traceback (most recent call last):   File "/usr/lib/python3.6/site-packages/patroni/postgresql/rewind.py", line 173, in _check_timeline_and_lsn     with self._postgresql.get_replication_connection_cursor(**leader.conn_kwargs()) as cur:   File "/usr/lib64/python3.6/contextlib.py", line 81, in __enter__     return next(self.gen)   File "/usr/lib/python3.6/site-packages/patroni/postgresql/__init__.py", line 816, in get_replication_connection_cursor     with get_connection_cursor(**conn_kwargs) as cur:   File "/usr/lib64/python3.6/contextlib.py", line 81, in __enter__     return next(self.gen)   File "/usr/lib/python3.6/site-packages/patroni/postgresql/connection.py", line 43, in get_connection_cursor     conn = psycopg2.connect(**kwargs)   File "/usr/lib64/python3.6/site-packages/psycopg2/__init__.py", line 127, in connect     conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not translate host name "2003:xxxx:xxxx::xxxx 10.x.x.x" to address: Name or service not known

I noticed that the PATRONI_POSTGRESQL_CONNECT_ADDRESS and PATRONI_RESTAPI_CONNECT_ADDRESS env var are both set to a nonsens value of both pod IPs separated by a space. This seems to be caused [here|https://github.com/percona/percona-docker/blob/1db7d7840b87beb3c0adaebde36d1fc15d4f1603/postgresql-containers/bin/postgres-ha/bootstrap/pre-bootstrap.sh#L124.]

 

This completely prevents usage of the replicas feature and maybe even more in dual stack clusters.

A possible simple solution would probably be to split the string returned by hostname -i and just use the first IP.

Environment

K3s v1.23.6 as a dual stack cluster with Calico.

Confluence content

mentioned on

Smart Checklist

Activity

Show:

Ivan Pylypenko June 13, 2022 at 10:15 AM

Hi

At the moment operator and all underlaying routines expects single stack cluster network only (patroni should be provided with exact address to listen on). 
We may consider adding dual stack in the future if that is feasible. Up to  

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Smart Checklist

Created May 31, 2022 at 3:30 PM
Updated July 15, 2024 at 3:33 PM

Flag notifications