Rebuilding MaaS snap : [Errno 111] Connection refused

Hello Everyone,

We may have to do light modifications about MaaS curtin generation.
For this purpose we may have to rebuild the snap.
So we have done this trial, for sure, modifying nothing at first, to see if it is doable:

On a fresh machine we do :

sudo unsquashfs maas_23947.snap
sudo snap pack ./squashfs-root

Then in place of doing:

sudo snap ack maas_23947.snap
sudo snap install maas_23947.snap

We do:

sudo snap install --dangerous maas_3.2.6-12016-g.19812b4da_amd64.snap

Then we follow the legit MaaS install region+rack and everything seems to work correctly.
But then we got [Errno 111] Connection refused trying to use the maas-cli.

Any advices on how to understand what we miss here?

Have a nice day,
Best Regards,
Mickaël.

1 Like

Hi @mkl1

Did you check logs, just to ensure that regiond was started successfully?

Hello troyanov,

I have checked the log and it contains lots of errors like this :

2023-02-22 15:26:51 maasserver.start_up: [error] Database error during start-up
Traceback (most recent call last):
  File "/snap/maas/x1/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "maasserver_config" does not exist
LINE 1: ..._config"."name", "maasserver_config"."value" FROM "maasserve...

But we dont understand why this shall happens by just repacking the snap without any modifications.

Any advices ?
Thanks!

This error indicates that your database doesn’t contain required tables.
Did you execute maas init? That command should apply DB migrations and create all the required schemas.

Also which database you are using, standalone PostgreSQL or the one from maas-test-db snap?

I rebuild the VM from scratch with cloud-init each time.
Everything is automated.
Yep, init has been executed and return no error.
Yep, stand alone PostgreSQL.
Works with original snaps.
Trials done ten times already…
I just exchange those lines under my cloud-init scripts :

sudo snap install maas_23947.snap
sudo snap install --dangerous maas_3.2.6-12016-g.19812b4da_amd64.snap

Logs are equal until it reach :

maas login provision http://mymaas.example.com:5240/MAAS $KEY

Then any maas command returns connection refused, cause the region is not starting, due to mentionned errors in previous com.

Could someone just have a try to unsquash, rebuild snap, on a fresh machine to ensure they are also seeing the issue with a standalone PostgreSQL ?

Hi @mkl1

Sorry for a late reply. Do you still have aforementioned issue?

Can you try a different approach by following development using the snap doc?

Hello Troyanov,

Thanks for your answer.
I will try to find the time to try that.

Still, why repacking the snap, doing no change, break something?
Did you try?

Have a nice day,
Mickaël.

Yes, I followed the steps you’ve mentioned and had no issues.

root@maas:/var/lib/snapd/snaps$ snap install maas
root@maas:/var/lib/snapd/snaps$ unsquashfs maas_26661.snap
root@maas:/var/lib/snapd/snaps$ snap pack ./squashfs-root
root@maas:/var/lib/snapd/snaps$ sudo snap install --dangerous maas_3.3.1-13169-g.94920eb1e_arm64.snap
root@maas:/var/lib/snapd/snaps$ sudo maas init region+rack --database-uri maas-test-db:///

And here is successful CLI execution

ubuntu@maas-cli:/tmp$ maas admin users read
Success.
Machine-readable output follows:
[
    {
        "is_superuser": false,
        "username": "MAAS",
        "email": "maas@localhost",
        "is_local": true,
        "resource_uri": "/MAAS/api/2.0/users/MAAS/"
    },
    {
        "is_superuser": true,
        "username": "admin",
        "email": "admin@localhost",
        "is_local": true,
        "resource_uri": "/MAAS/api/2.0/users/admin/"
    },
    {
        "is_superuser": false,
        "username": "maas-init-node",
        "email": "node-init-user@localhost",
        "is_local": true,
        "resource_uri": "/MAAS/api/2.0/users/maas-init-node/"
    }
]

I would suggest looking into PostgreSQL logs as well and look for connection errors there.

Thanks, so it’s surely something I miss somewhere…
I’ll try again and let you know.

Hello Troyanov,

No more luck…

I am isolated from the internet and so from the snap store; so I can’t do snap install maas.
So I am doing snap download maas to get the snap from another computer which have internet access. Same for other snap dependencies.
And I got 26658 not 26661…
And I am not installing firstly the original snap, why should this be required ?
And I am not using maas-test-db but a separated postgreSQL host.

I feel this conversation will never converge to an understanding of what is failing, and why it shall, or not, fail and for which reasons.

So forget it, I’ll try to accomplish what I need using .deb packages install.
If not possible, I’ll just drop this current experiment.
It is taking too much of efforts compare to the target.

Have a nice day,
Best Regards,
Mickaël.

Mickaël, I am out of ideas as well :frowning:

The only one Idea I got left, is to re-check snap connections.
By default snap connections maas on the re-packed MAAS will be disconnected (most of them)

root@maas-danger:~# snap connections maas
Interface              Plug                        Slot            Notes
avahi-observe          maas:avahi-observe          -               -
content                -                           maas:maas-logs  -
content                maas:test-db-socket         -               -
hardware-observe       maas:hardware-observe       -               -
home                   maas:home                   :home           -
kernel-module-observe  maas:kernel-module-observe  -               -
mount-observe          maas:mount-observe          -               -
network                maas:network                :network        -
network-bind           maas:network-bind           :network-bind   -
network-control        maas:network-control        -               -
network-observe        maas:network-observe        -               -
snap-refresh-control   maas:snap-refresh-control   -               -
system-observe         maas:system-observe         -               -
time-control           maas:time-control           -               -

Thats because when you install snap with --dangerous flag provided, autoconnect is not performed.

The easiest way to connect all required slots and plugs is to execute

snap connections maas | awk '$1 != "content" && $3 == "-" {print $2}' | xargs -r -n1 sudo snap connect

Then of course don’t forget to run:

sudo snap restart maas

With all plugs and slots connected it should look like his:

root@maas-danger:~# snap connections maas
Interface              Plug                        Slot                    Notes
avahi-observe          maas:avahi-observe          :avahi-observe          manual
content                -                           maas:maas-logs          -
content                maas:test-db-socket         -                       -
hardware-observe       maas:hardware-observe       :hardware-observe       manual
home                   maas:home                   :home                   -
kernel-module-observe  maas:kernel-module-observe  :kernel-module-observe  manual
mount-observe          maas:mount-observe          :mount-observe          manual
network                maas:network                :network                -
network-bind           maas:network-bind           :network-bind           -
network-control        maas:network-control        :network-control        manual
network-observe        maas:network-observe        :network-observe        manual
snap-refresh-control   maas:snap-refresh-control   :snap-refresh-control   manual
system-observe         maas:system-observe         :system-observe         manual
time-control           maas:time-control           :time-control           manual
1 Like

Hello Troyanov,

That seems to have solved the issue !
Very much Thanks !
So where is this documented :
“Thats because when you install snap with --dangerous flag provided, autoconnect is not performed.”

Have a nice day,
Best Regards,
Mickaël.

Glad that it worked.

I don’t exactly remember the place where it is mentioned, but thats basically related to snapd and how snaps work.

MAAS has this mentioned in HACKING.rst

Even with those info, I would not have been able to come with that :

snap connections maas | awk '$1 != "content" && $3 == "-" {print $2}' | xargs -r -n1 sudo snap connect

Still thanks for your support, problem solved ; - )

Thats just a bit of “automation” to avoid manual connection of all slots and plugs.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.