MAAS 2.8 snap test-db install fails when running as (default) root in a container

Bug #1882145 reported by Bill Wear
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Björn Tillenius

Bug Description

I created a lxd container by copying my MAAS template container (which already has the KVM bridge and postgres running locally, but no MAAS).

I ran snap install maas --channel=2.8/candidate -- seemed to complete with no issues.

I ran snap install maas-test-db -- again, seemed to complete with no issue.

Attempted to double-check with maas-test-db.psql, got the following error:

psql: could not connect to server: No such file or directory
 Is the server running locally and accepting
 connections on Unix domain socket "/var/snap/maas-test-db/common/postgres/sockets/.s.PGSQL.5432"?

Did an su - postgres, attempted maas-test-db.psql again, got the following error:

psql: could not connect to server: No such file or directory
 Is the server running locally and accepting
 connections on Unix domain socket "/var/snap/maas-test db/common/postgres/sockets/.s.PGSQL.5432"?

This may be related to how I'm running the commands (as root in a container), rather than an actual bug, but in any case, at the very least, the documentation may need to be updated to explain the correct conditions for installation to succeed.

Revision history for this message
Alberto Donato (ack) wrote :

Can you please post the output of `journalctl -ef -u snap.maas-test-db.postgres` where this is happening?

FTR, running maas-test-db.psql as root is correct.

I tried to reproduce the issue in a clean bionic container, installing maas-test-db from 2.8/stable worked for me

Changed in maas:
status: New → Incomplete
Revision history for this message
Bill Wear (billwear) wrote :
Download full text (9.1 KiB)

-- Logs begin at Sun 2019-12-08 15:49:19 CST. --
Jun 08 13:11:58 wintermute systemd[1]: Started Service for snap application maas-test-db.postgres.
Jun 08 13:11:59 wintermute maas-test-db.postgres[185490]: postgres: could not access directory "/var/snap/maas-test-db/common/postgres/data": No such file or directory
Jun 08 13:11:59 wintermute maas-test-db.postgres[185490]: Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
Jun 08 13:11:59 wintermute systemd[1]: snap.maas-test-db.postgres.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jun 08 13:11:59 wintermute systemd[1]: snap.maas-test-db.postgres.service: Failed with result 'exit-code'.
Jun 08 13:11:59 wintermute systemd[1]: snap.maas-test-db.postgres.service: Scheduled restart job, restart counter is at 1.
Jun 08 13:11:59 wintermute systemd[1]: Stopped Service for snap application maas-test-db.postgres.
Jun 08 13:11:59 wintermute systemd[1]: Started Service for snap application maas-test-db.postgres.
Jun 08 13:11:59 wintermute maas-test-db.postgres[185520]: postgres: could not access directory "/var/snap/maas-test-db/common/postgres/data": No such file or directory
Jun 08 13:11:59 wintermute maas-test-db.postgres[185520]: Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
Jun 08 13:11:59 wintermute systemd[1]: snap.maas-test-db.postgres.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jun 08 13:11:59 wintermute systemd[1]: snap.maas-test-db.postgres.service: Failed with result 'exit-code'.
Jun 08 13:11:59 wintermute systemd[1]: snap.maas-test-db.postgres.service: Scheduled restart job, restart counter is at 2.
Jun 08 13:11:59 wintermute systemd[1]: Stopped Service for snap application maas-test-db.postgres.
Jun 08 13:11:59 wintermute systemd[1]: Started Service for snap application maas-test-db.postgres.
Jun 08 13:11:59 wintermute maas-test-db.postgres[185546]: postgres: could not access directory "/var/snap/maas-test-db/common/postgres/data": No such file or directory
Jun 08 13:11:59 wintermute maas-test-db.postgres[185546]: Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
Jun 08 13:11:59 wintermute systemd[1]: snap.maas-test-db.postgres.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jun 08 13:11:59 wintermute systemd[1]: snap.maas-test-db.postgres.service: Failed with result 'exit-code'.
Jun 08 13:12:00 wintermute systemd[1]: snap.maas-test-db.postgres.service: Scheduled restart job, restart counter is at 3.
Jun 08 13:12:00 wintermute systemd[1]: Stopped Service for snap application maas-test-db.postgres.
Jun 08 13:12:00 wintermute systemd[1]: Started Service for snap application maas-test-db.postgres.
Jun 08 13:12:00 wintermute maas-test-db.postgres[185571]: postgres: could not access directory "/var/snap/maas-test-db/common/postgres/data": No such file or directory
Jun 08 13:12:00 wintermute maas-test-db.postgres[185571]: Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
Jun 08 13:12:00 wintermute systemd[1]: snap.maas-test-db.postgres.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jun 08 13:12:00 wintermute systemd[1]: snap....

Read more...

Revision history for this message
Bill Wear (billwear) wrote :

Note that I have the same result for "maas-test-db.psql" whether running the snap in a container or not, running on 19.10 or 20.04, makes no difference to the result.

Revision history for this message
Alberto Donato (ack) wrote :

What does

 find /var/snap/maas-test-db/common/postgres/

show?

Revision history for this message
Alberto Donato (ack) wrote :

Also, could this be related to the disk space you mentioned before? Can you reproduce the issue consistently?

Revision history for this message
Bill Wear (billwear) wrote : Re: [Bug 1882145] Re: MAAS 2.8 snap test-db install fails when running as (default) root in a container

I can reproduce the issue with or without containers, on 19.10 or 20.04.

On Tue, Jun 9, 2020 at 3:40 AM Alberto Donato <email address hidden>
wrote:

> Also, could this be related to the disk space you mentioned before? Can
> you reproduce the issue consistently?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1882145
>
> Title:
> MAAS 2.8 snap test-db install fails when running as (default) root in
> a container
>
> Status in MAAS:
> Incomplete
>
> Bug description:
> I created a lxd container by copying my MAAS template container (which
> already has the KVM bridge and postgres running locally, but no MAAS).
>
> I ran snap install maas --channel=2.8/candidate -- seemed to complete
> with no issues.
>
> I ran snap install maas-test-db -- again, seemed to complete with no
> issue.
>
> Attempted to double-check with maas-test-db.psql, got the following
> error:
>
> psql: could not connect to server: No such file or directory
> Is the server running locally and accepting
> connections on Unix domain socket
> "/var/snap/maas-test-db/common/postgres/sockets/.s.PGSQL.5432"?
>
> Did an su - postgres, attempted maas-test-db.psql again, got the
> following error:
>
> psql: could not connect to server: No such file or directory
> Is the server running locally and accepting
> connections on Unix domain socket "/var/snap/maas-test
> db/common/postgres/sockets/.s.PGSQL.5432"?
>
> This may be related to how I'm running the commands (as root in a
> container), rather than an actual bug, but in any case, at the very
> least, the documentation may need to be updated to explain the correct
> conditions for installation to succeed.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/maas/+bug/1882145/+subscriptions
>

--
Bill Wear, MAAS Developer Advocate

Revision history for this message
Bill Wear (billwear) wrote :

On two different brands / configs of laptops.

On Tue, Jun 9, 2020 at 8:06 AM Bill Wear <email address hidden> wrote:

> I can reproduce the issue with or without containers, on 19.10 or 20.04.
>
> On Tue, Jun 9, 2020 at 3:40 AM Alberto Donato <email address hidden>
> wrote:
>
>> Also, could this be related to the disk space you mentioned before? Can
>> you reproduce the issue consistently?
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1882145
>>
>> Title:
>> MAAS 2.8 snap test-db install fails when running as (default) root in
>> a container
>>
>> Status in MAAS:
>> Incomplete
>>
>> Bug description:
>> I created a lxd container by copying my MAAS template container (which
>> already has the KVM bridge and postgres running locally, but no MAAS).
>>
>> I ran snap install maas --channel=2.8/candidate -- seemed to complete
>> with no issues.
>>
>> I ran snap install maas-test-db -- again, seemed to complete with no
>> issue.
>>
>> Attempted to double-check with maas-test-db.psql, got the following
>> error:
>>
>> psql: could not connect to server: No such file or directory
>> Is the server running locally and accepting
>> connections on Unix domain socket
>> "/var/snap/maas-test-db/common/postgres/sockets/.s.PGSQL.5432"?
>>
>> Did an su - postgres, attempted maas-test-db.psql again, got the
>> following error:
>>
>> psql: could not connect to server: No such file or directory
>> Is the server running locally and accepting
>> connections on Unix domain socket "/var/snap/maas-test
>> db/common/postgres/sockets/.s.PGSQL.5432"?
>>
>> This may be related to how I'm running the commands (as root in a
>> container), rather than an actual bug, but in any case, at the very
>> least, the documentation may need to be updated to explain the correct
>> conditions for installation to succeed.
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/maas/+bug/1882145/+subscriptions
>>
>
>
> --
> Bill Wear, MAAS Developer Advocate
>

--
Bill Wear, MAAS Developer Advocate

Revision history for this message
Bill Wear (billwear) wrote :

stormrider@wintermute:~$ find /var/snap/maas-test-db/common/postgres
/var/snap/maas-test-db/common/postgres
/var/snap/maas-test-db/common/postgres/sockets

Revision history for this message
Bill Wear (billwear) wrote :

stormrider@wintermute:~$ snap version
snap 2.45
snapd 2.45
series 16
ubuntu 20.04
kernel 5.4.0-18-generic

Revision history for this message
Bill Wear (billwear) wrote :

stormrider@wintermute:~$ snap changes maas-test-db
ID Status Spawn Ready Summary
102 Done yesterday at 13:11 CDT yesterday at 13:11 CDT Install "maas-test-db" snap
103 Done yesterday at 13:13 CDT yesterday at 13:13 CDT Remove "maas-test-db" snap
104 Done yesterday at 13:45 CDT yesterday at 13:45 CDT Install "maas-test-db" snap

Revision history for this message
Ponnuvel Palaniyappan (pponnuvel) wrote :

I have the same problem with Ubuntu 20.04 but running on a KVM.

Following the doc at: https://maas.io/docs/install-from-a-snap

And installed with:
sudo snap install maas --channel=2.8/candidate
sudo snap install maas-test-db --channel=2.8

Error:

user@focal:~$ maas-test-db.psql
psql: could not connect to server: No such file or directory
 Is the server running locally and accepting
 connections on Unix domain socket "/var/snap/maas-test-db/common/postgres/sockets/.s.PGSQL.5432"?

Attached `logs.txt` contains relevant system info.
There are no errors from `dmesg` or `journalctl -ef`.

Revision history for this message
Björn Tillenius (bjornt) wrote :

There's a problem with the maas-test-db snap when MAAS is already installed. We'll fix that.

In the meantime, you can workaround it by reversing the install steps:

  sudo snap install maas-test-db --channel=2.8
  sudo snap install maas --channel=2.8/candidate

Revision history for this message
Ponnuvel Palaniyappan (pponnuvel) wrote :

I confirm that the reversing the install step works (as noted in #12). Thanks.

Revision history for this message
Björn Tillenius (bjornt) wrote :

I fix is in progress. It should be available later today or tomorrow.

Changed in maas:
status: Incomplete → In Progress
assignee: nobody → Björn Tillenius (bjornt)
importance: Undecided → Critical
Revision history for this message
Björn Tillenius (bjornt) wrote :

I've released a fixed version of maas-test-db to 2.8/stable now. The 'maas' snap doesn't need to be updated.

Changed in maas:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.