canonical / canonical/postgresql-operator

Postgresql Cluster failed to start on Dual stack network if the IPv4 subnet is from a private address space (IPv6 is then prefered)

Open
#922 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
20
Forks
36
Avg merge
4d 15h
Merged PRs (30d)
30

Description

## Steps to reproduce

1. Deploy postgresql on 14/stable on 3 machines with dual stack (IPv4 and IPv6)
2. Cluster failt to start.

## Expected behavior
Cluster start properly.

## Actual behavior
The cluster fail to start because the pg_hba.conf created by partroni has only 0.0.0.0/0 in the entries and nothing for IPv6. The error in the patroni.log:

```
2025-05-29 20:59:35 UTC [91991]: ERROR: post_bootstrap
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/patroni/postgresql/bootstrap.py", line 384, in post_bootstrap
self.create_or_update_role(superuser['username'], superuser['password'], ['SUPERUSER'])
File "/usr/lib/python3/dist-packages/patroni/postgresql/bootstrap.py", line 366, in create_or_update_role
END;$$""".format(quote_literal(name), quote_ident(name, self._postgresql.connection()), ' '.join(options))
File "/usr/lib/python3/dist-packages/patroni/postgresql/__init__.py", line 335, in connection
return self._connection.get()
File "/usr/lib/python3/dist-packages/patroni/postgresql/connection.py", line 29, in get
self._connection = psycopg.connect(**self._conn_kwargs)
File "/usr/lib/python3/dist-packages/patroni/psycopg.py", line 103, in connect
ret = _connect(*args, **kwargs)
File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "XXXX:120:1::2f", port 5432 failed: FATAL: no pg_hba.conf entry for host "XXXX:120:1::2f", user "operator", database "postgres", no encryption
```

## Versions

Operating system:
Ubuntu 22.04.5 LTS

Juju CLI:
3.6.5

Juju agent:

Charm revision: 553

LXD:
Not installed

## Log output

Juju debug log:

## Additional context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.