> $ travis_setup_postgresql
Unrecognized operating system Starting PostgreSQL v Assertion failed on job for postgresql@-main.service. sudo systemctl start postgresql@-main
This is a Bionic issue
> $ travis_setup_postgresql
Unrecognized operating system Starting PostgreSQL v Assertion failed on job for postgresql@-main.service. sudo systemctl start postgresql@-main
This is a Bionic issue
I’m also experiencing this problem. This is something that did work at some point in the past, I have found a build from June 1 that successfully used PostgreSQL on Bionic: https://travis-ci.com/joppich/brick_id/builds/113954484
@pfrenssen The build you linked to actually uses Xenial (this was an early issue with Bionic support).
In any case, please link to an affected build – otherwise, we have incomplete information.
Here is a failing build exhibiting the same problem reported in the OP: https://travis-ci.org/pfrenssen/firetrack/jobs/602177059
$ travis_setup_postgresql
Unrecognized operating system.
Starting PostgreSQL v
Failed to stop postgresql.service: Unit postgresql.service not loaded.
Failed to start postgresql@-main.service: Unit postgresql@-main.service not found.
sudo systemctl start postgresql@-main
.travis.yml
for this build: https://github.com/pfrenssen/firetrack/blob/f1516b22cbe69d49ec7f9de1fcbfa370c64ad36b/.travis.yml
The reason is there’s no default version set for Bionic: https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_setup_postgresql.bash#L5-L20
So you need
addons:
postgresql: <version>
to set it manually.
See http://apt.postgresql.org/pub/repos/apt/dists/bionic-pgdg/ for versions available for Bionic in the official Apt repo (where Travis requests the specified version from).
Thanks for pointing me here!
I have tried setting the version in the addons
section but it is still failing.
Build: https://travis-ci.org/pfrenssen/firetrack/jobs/602514416
.travis.yml
: https://github.com/pfrenssen/firetrack/blob/3d91207d05e896bc34131173419a1bda533ecc6b/.travis.yml
$ travis_setup_postgresql 11
Starting PostgreSQL v11
Failed to stop postgresql.service: Unit postgresql.service not loaded.
Failed to start postgresql@11-main.service: Unit postgresql@11-main.service not found.
sudo systemctl start postgresql@11-main
The message unrecognized operating system
is no longer shown, but the service does not appear to exist:
$ psql -c 'create database firetrack;' -U postgres
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Thanks for the help!
I’m getting close to a working solution now, but it seems there are still some bugs left in the PostgreSQL support on Bionic.
When I use the configuration exactly as described in the documentation the errors in the travis_setup_postgresql
step are now gone, but the service is not honoring the port that is set with the PGPORT=5433
environment variable.
Failing build: https://travis-ci.org/pfrenssen/firetrack/jobs/602714616
.travis.yml: https://github.com/pfrenssen/firetrack/blob/d153ac7850173e75f1f7bc08fa4efce0528a5484/.travis.yml
The travis_setup_postgresql
step looks good now:
$ travis_setup_postgresql 11
Starting PostgreSQL v11
sudo systemctl start postgresql@11-main
And I can see that the service is up and running:
$ sudo systemctl status postgresql@11-main -l || true
● postgresql@11-main.service - PostgreSQL Cluster 11-main
Loaded: loaded (/lib/systemd/system/postgresql@.service; indirect; vendor preset: enabled)
Active: active (running) since Fri 2019-10-25 09:12:30 UTC; 23s ago
However when I try to create a database as described in the documentation this fails:
$ psql -c 'create database firetrack;' -U postgres
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"?
And this is because the server is started on the default port 5432
instead of port 5433
as specified in the PGPORT=5433
environment variable:
$ sudo netstat -ltnp | grep postgres
tcp 0 0 127.0.1.1:5432 0.0.0.0:* LISTEN 6959/postgres
I think this is probably caused by the fact that the environment variable is set after the postgres service is started. I can possibly shut down and restart the service myself to work around this, but it is probably a bug that is worth fixing.
There is another problem, I am now using the default ports and the psql
command can now connect to it, but it cannot authenticate using the postgres
user:
$ psql -c 'create database firetrack;' -U postgres
psql: FATAL: Peer authentication failed for user "postgres"
Build: https://travis-ci.org/pfrenssen/firetrack/builds/602730957
.travis.yml
: https://github.com/pfrenssen/firetrack/blob/40cdcc3f1f7de55a91ec9eadfeea2d1d27a67e24/.travis.yml
Here are some other things I tried but none were successful:
createdb firetrack
instead of using psql
sudo -u postgres createdb firetrack
psql -c 'create database firetrack;' -U postgres --host=localhost
travis
database that I see is being created in https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_setup_postgresql.bash#L47-L48
No luck so far.
The user and database travis
that the code you linked to creates should allow you to run psql
as yourself, without any extraneous parameters. AFAICS in https://travis-ci.org/pfrenssen/firetrack/builds/602754466, you do create the database successfully.
That is possible, but in that build the 3rd test fails, and this is the first test that connects to the database. I can try to get more debugging information in the test output, but at the moment I have switched back to Xenial.
I tried to find a build by searching for filename:.travis.yml bionic postgresql
on Github, but I can’t find any builds that are working using the normal approach as described in the documentation.
On Xenial everything works fine.
I was finally able to solve it by applying the workaround posted in Postgresql broken on Focal - #7 by y-yagi by @mustafa .