Skip to content

fix: every PostgreSQL cluster starts after keel-host-keys - #45

Open
marcos-mendez wants to merge 1 commit into
masterfrom
fix/postgresql-cluster-after-host-keys
Open

marcos-mendez wants to merge 1 commit into
masterfrom
fix/postgresql-cluster-after-host-keys

Conversation

@marcos-mendez

Copy link
Copy Markdown
Collaborator

On the step 12 PostgreSQL image (2026-10-09), 35pgsqlpass and 36pgsqlverify failed at first boot. postgresql@17-main had started before keel-host-keys.service made the snakeoil pair: FATAL: could not load server certificate file "/etc/ssl/certs/ssl-cert-snakeoil.pem": No such file or directory.

Cause

keel-host-keys.service is Before=postgresql.service. That orders no cluster: postgresql.service is the meta unit of postgresql-common, and each [email protected] is itself Before=postgresql.service. The build removes the snakeoil pair (no key in the image), so on the first boot the cluster raced the unit that makes it.

Change

The package installs /usr/lib/systemd/system/[email protected]/keel-host-keys.conf with Wants= and After=keel-host-keys.service. A drop-in for the template applies to every cluster, in every image that has PostgreSQL (keel-postgresql, unit-postgresql for LAPP, Odoo). No Condition, so a fault stays visible. No key goes into the image. The comment in keel-host-keys.service says where the cluster order comes from.

Tests

tests/test-packaging.bats: the install line, the drop-in content, and the order as systemd sees it. With the units of postgresql-common 278 (tests/fixtures/), a probe unit that asks for the opposite order gives an ordering cycle in systemd-analyze verify with the drop-in, and none without it. systemd-analyze verify accepts the template with the drop-in.

Changelog 2.3.6+keel26. The keel-postgresql boot test gate gets the assertion that the cluster is active after first boot in a separate PR.

The step 12 PostgreSQL image of 2026-10-09 started postgresql@17-main
before keel-host-keys.service made the snakeoil pair. The cluster stopped
with 'could not load server certificate file
"/etc/ssl/certs/ssl-cert-snakeoil.pem"', and 35pgsqlpass and
36pgsqlverify failed.

keel-host-keys.service is Before=postgresql.service, but that orders no
cluster: postgresql.service is the meta unit of postgresql-common, and
each [email protected] is itself Before= it.

The package now installs the drop-in
/usr/lib/systemd/system/[email protected]/keel-host-keys.conf with
Wants= and After=keel-host-keys.service. It applies to every instance of
the template. It has no Condition, so a fault stays visible. No key goes
into the image.

tests/test-packaging.bats checks the install line and asks
systemd-analyze verify for the order, with the units of
postgresql-common 278 as fixtures: a probe that wants the opposite order
gives an ordering cycle with the drop-in and none without it.
marcos-mendez added a commit to Keel-Linux/keel-postgresql that referenced this pull request Oct 10, 2026
…first boot

On the step 12 image of 2026-10-09, postgresql@17-main started before
keel-host-keys made the snakeoil certificate and stopped. 35pgsqlpass and
36pgsqlverify failed, then 36pgsqlverify started the cluster again, so the
cluster was active at the end. The boot test failed only later, on the
declared password. Reproduced on the published layer with keel-host-keys
made 10 s slower.

tests/boot-test.sh now checks, after the first boot:
- bt_db_hooks_verdict: 35pgsqlpass and 36pgsqlverify completed, from
  /var/log/inithooks.log;
- bt_cluster_verdict: there is a cluster unit (systemctl list-units
  postgresql@*.service) and every cluster is active (running).

Seven new tests in tests/boot-test.bats; tests/lib/boot-test-lib.sh stays
at 100 percent.

The fix is Keel-Linux/inithooks#45.
@marcos-mendez

Copy link
Copy Markdown
Collaborator Author

Reproduced on the published postgresql layer in LXC, with keel-host-keys made 10 s slower: the cluster stopped on the missing snakeoil certificate and 35pgsqlpass and 36pgsqlverify failed. With this drop-in in the same rootfs, the cluster starts after keel-host-keys and both hooks complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant