Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/etc/postgresql/15/main/pg_hba.conf: No such file or directory #11

Closed
kwent opened this issue Feb 25, 2025 · 9 comments
Closed

/etc/postgresql/15/main/pg_hba.conf: No such file or directory #11

kwent opened this issue Feb 25, 2025 · 9 comments

Comments

@kwent
Copy link

kwent commented Feb 25, 2025

This began to fail as this morning. Any ideas ?

Run ankane/setup-postgres@v1
curl -s https://www.postgresql.org/media/keys/ACCC[4](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:5)CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt noble-pgdg main
sudo pg_dropcluster 16 main
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/pgdg.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
Get:1 http://apt.postgresql.org/pub/repos/apt noble-pgdg InRelease [129 kB]
Get:2 http://apt.postgresql.org/pub/repos/apt noble-pgdg/main amd64 Packages [308 kB]
Fetched 437 kB in 1s (408 kB/s)
Reading package lists...
sudo apt-get install postgresql-1[5](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:6)
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  postgresql-client-15
Suggested packages:
  postgresql-doc-15
The following NEW packages will be installed:
  postgresql-15 postgresql-client-15
0 upgraded, 2 newly installed, 0 to remove and 8 not upgraded.
Need to get 16.9 MB of archives.
After this operation, 60.3 MB of additional disk space will be used.
Get:1 http://apt.postgresql.org/pub/repos/apt noble-pgdg/main amd64 postgresql-client-15 amd64 15.12-1.pgdg24.04+1 [1712 kB]
Get:2 http://apt.postgresql.org/pub/repos/apt noble-pgdg/main amd[6](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:7)4 postgresql-15 amd64 15.12-1.pgdg24.04+1 [15.2 MB]
Preconfiguring packages ...
Fetched 16.9 MB in 1s (12.5 MB/s)
Selecting previously unselected package postgresql-client-15.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... [7](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:8)0%
(Reading database ... 75%
(Reading database ... [8](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:9)0%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 221580 files and directories currently installed.)
Preparing to unpack .../postgresql-client-15_15.12-1.pgdg24.04+1_amd64.deb ...
Unpacking postgresql-client-15 (15.12-1.pgdg24.04+1) ...
Selecting previously unselected package postgresql-15.
Preparing to unpack .../postgresql-15_15.12-1.pgdg24.04+1_amd64.deb ...
Unpacking postgresql-15 (15.12-1.pgdg24.04+1) ...
Setting up postgresql-client-15 (15.12-1.pgdg24.04+1) ...
Setting up postgresql-15 (15.12-1.pgdg24.04+1) ...
Processing triggers for postgresql-common (274.pgdg24.04+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
  en_us
Removing obsolete dictionary files:

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
tee: /etc/postgresql/15/main/pg_hba.conf: No such file or directory
node:child_process:[9](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:10)66
    throw err;
    ^

Error: Command failed: echo "
# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             postgres                                peer
local   all             all                                     peer
host    all             $USER           127.0.0.1/32            trust
host    all             $USER           ::1/128                 trust
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
" | sudo tee /etc/postgresql/15/main/pg_hba.conf
tee: /etc/postgresql/15/main/pg_hba.conf: No such file or directory

    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at checkExecSyncError (node:child_process:891:11)
    at execSync (node:child_process:963:15)
    at updateHba (/home/runner/work/_actions/ankane/setup-postgres/v1/index.js:66:3)
    at Object.<anonymous> (/home/runner/work/_actions/ankane/setup-postgres/v1/index.js:164:3)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:[10](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:11))
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:[11](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:12)04:12) {
  status: 1,
  signal: null,
  output: [
    null,
    Buffer(489) [Uint8Array] [
       10,  35,  32,  84,  89, 80, 69, 32, 32,  68,  65, 84,
       65,  66,  65,  83,  69, 32, 32, 32, 32,  32,  32, 32,
       32,  85,  83,  69,  82, 32, 32, 32, 32,  32,  32, 32,
       32,  32,  32,  32,  32, 65, 68, 68, 82,  69,  83, 83,
       32,  32,  32,  32,  32, 32, 32, 32, 32,  32,  32, 32,
       32,  32,  32,  32,  32, 77, 69, 84, 72,  79,  68, 10,
      108, 111,  99,  97, 108, 32, 32, 32, 97, 108, 108, 32,
       32,  32,  32,  32,  32, 32, 32, 32, 32,  32,  32, 32,
      1[12](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:13), 111, 115, 116,
      ... 389 more items
    ],
    Buffer(68) [Uint8Array] [
      116, 101, 101,  58,  32,  47, 101, 116,  99,  47, 112,
      111, 115, 116, 103, 114, 101, 115, 1[13](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:14), 108,  47,  49,
       53,  47, 109,  97, 105, 110,  47, 112, 103,  95, 104,
       98,  97,  46,  99, 111, 110, 102,  58,  32,  78, 111,
       32, 115, 117,  99, 104,  32, 102, 105, 108, 101,  32,
      111, 1[14](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:15),  32, 100, 105, 114, 101,  99, 116, 111, 114,
      121,  10
    ]
  ],
  pid: 4843,
  stdout: Buffer(489) [Uint8Array] [
     10,  35,  32,  84,  89, 80, 69, 32, 32,  68,  65, 84,
     65,  66,  65,  83,  69, 32, 32, 32, 32,  32,  32, 32,
     32,  85,  83,  69,  82, 32, 32, 32, 32,  32,  32, 32,
     32,  32,  32,  32,  32, 65, 68, 68, 82,  69,  83, 83,
     32,  32,  32,  32,  32, 32, 32, 32, 32,  32,  32, 32,
     32,  32,  32,  32,  32, 77, 69, 84, 72,  79,  68, 10,
    108, 111,  99,  97, 108, 32, 32, 32, 97, 108, 108, 32,
     32,  32,  32,  32,  32, 32, 32, 32, 32,  32,  32, 32,
    112, 111, 1[15](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:16), 116,
    ... 389 more items
  ],
  stderr: Buffer(68) [Uint8Array] [
    1[16](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:17), 101, 101,  58,  32,  47, 101, 116,  99,  47, 112,
    111, 115, 116, 103, 114, 101, 115, 113, 108,  47,  49,
     53,  47, 109,  97, 105, 110,  47, 112, 103,  95, 104,
     98,  97,  46,  99, 111, 110, 102,  58,  32,  78, 111,
     32, 115, 1[17](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:18),  99, 104,  32, 102, 105, 108, 101,  32,
    111, 114,  32, 100, 105, 114, 101,  99, 116, 111, 114,
    121,  10
  ]
}

Node.js v20.[18](https://github.com/acme/acme/actions/runs/13526936991/job/37799929443#step:7:19).0
0s
@ankane
Copy link
Owner

ankane commented Feb 25, 2025

Hi @kwent, it looks like the database isn't being set up (the output is missing the following):

Setting up postgresql-15 (15.12-1.pgdg24.04+1) ...
Creating new PostgreSQL cluster 15/main ...
/usr/lib/postgresql/15/bin/initdb -D /var/lib/postgresql/15/main --auth-local peer --auth-host scram-sha-256 --no-instructions
The files belonging to this database system will be owned by user "postgres".

However, I'm not sure how to reproduce (CI logs).

@ankane
Copy link
Owner

ankane commented Feb 25, 2025

It looks like something with the latest runner image, as it passes with 20250209.1.0 but fails with 20250223.1.0.

@ddh
Copy link

ddh commented Feb 26, 2025

@kwent If possible, try specifying Ubuntu 22.04 instead of the latest (24.04). Not sure what 20250223.1.1 broke but Ubuntu 22.04 works fine with postgresql 15. If keeping to ubuntu-latest, try bumping postgresql to 16.

@ankane
Copy link
Owner

ankane commented Mar 6, 2025

Ref: actions/runner-images#11721

@fizyk
Copy link

fizyk commented Mar 6, 2025

Got same issue with postgres 13,
and even downgrading to ubuntu-20.04 would not help

@enescakir
Copy link

PostgreSQL post scripts have changed recently. https://salsa.debian.org/postgresql/postgresql-common/-/commit/d9139f7777a42a39b5b6fabbffc9f020fad4dce5

The new database won't be initialized if any other database already exists. Since the runner image comes with PostgreSQL 14 by default, the new version won't automatically trigger pg_createcluster for the newly installed version.

You can delete the PostgreSQL 14 cluster just before installing the new version.

pg_dropcluster 14 main --stop

It will initialize a new database when you install the new version.

@ankane
Copy link
Owner

ankane commented Mar 6, 2025

Great find, big thanks @enescakir!

The setup script already drops the cluster, but looks like this change is causing it:

    # Skip if this isn't the newest major installed (assumes other packages are
    # unpacked first before this one is configured)
    [ "$(ls -v /usr/lib/postgresql/*/bin/postgres | tail -n1)" = "/usr/lib/postgresql/$VERSION/bin/postgres" ] || return 0

Seems like we need to completely remove the previous installation (or set up the new cluster manually).

@ankane ankane closed this as completed in fcd6aa3 Mar 6, 2025
@ankane
Copy link
Owner

ankane commented Mar 6, 2025

Pushed a fix in the commit above. Thanks everyone!

@ddh
Copy link

ddh commented Mar 6, 2025

@ankane @enescakir Thank you! Works great.

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

No branches or pull requests

5 participants