MAAS 3.4 Region Controller Won't start " missing maasserver_secret"

Hello,

I am upgrading from 3.2 to 3.4, I was running postgres 12, so i exported the data to a file.

Created a new postgres version 14 server, imported the data and created the same username and password.

My 3.2 Region can connect to postgres 14 without problems.

I created a 3.4 region controller and this is the error i’m getting.

psycopg2.errors.UndefinedTable: relation "maasserver_secret" does not exist
LINE 1: ..._secret"."path", "maasserver_secret"."value" FROM "maasserve...
                                                             ^

Any dev help would be appreciated, thanks!

Hi @mk4umha

That sounds like a database migrations issue.

Are you using deb package or snap?
Did you go directly from 3.2 straight to 3.4?

In case of deb, can you please run:

maas-region migrate

For snap that will be:

sudo maas migrate

Hi Troy,

I’m using deb package. This is the output.

Operations to perform:
  Apply all migrations: auth, contenttypes, maasserver, metadataserver, piston3, sessions, sites
Running migrations:
  Applying auth.0006_default_auto_field... OK
  Applying metadataserver.0031_id_field_bigint...Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.FeatureNotSupported: cannot alter type of a column used in a trigger definition
DETAIL:  trigger node_device_update_notify on table maasserver_node depends on column "current_commissioning_script_set_id"


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/sbin/maas-region", line 33, in <module>
    sys.exit(load_entry_point('maas==3.4.1', 'console_scripts', 'maas-region')())
  File "/usr/lib/python3/dist-packages/maasserver/region_script.py", line 81, in run
    run_django(is_snap, is_devenv)
  File "/usr/lib/python3/dist-packages/maasserver/region_script.py", line 70, in run_django
    management.execute_from_command_line()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/lib/python3/dist-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/lib/python3/dist-packages/django/db/migrations/operations/fields.py", line 244, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/usr/lib/python3/dist-packages/django/db/backends/base/schema.py", line 608, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type,
  File "/usr/lib/python3/dist-packages/django/db/backends/postgresql/schema.py", line 196, in _alter_field
    super()._alter_field(
  File "/usr/lib/python3/dist-packages/django/db/backends/base/schema.py", line 830, in _alter_field
    self.execute(
  File "/usr/lib/python3/dist-packages/django/db/backends/base/schema.py", line 145, in execute
    cursor.execute(sql, params)
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 79, in _execute
    with self.db.wrap_database_errors:
  File "/usr/lib/python3/dist-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.NotSupportedError: cannot alter type of a column used in a trigger definition
DETAIL:  trigger node_device_update_notify on table maasserver_node depends on column "current_commissioning_script_set_id"

I just did a quick check with snaps (updating from --channel 3.2 to --channel 3.4 and had no issues.

Can you please share all the steps you made so I can try to reproduce it on my end?
How did you create your DB back and how did you restore it?

Sure!

Existing Deployment
LXC Ubuntu 20.04.4 region 3.2.10
LXC Ubuntu 20.04.4 rack 3.2.10
LXC Ubuntu 20.04.4 Postgres version 12

New Deployment
LXC Ubuntu 22.04 region 3.4
LXC Ubuntu 22.04 rack 3.4
LXC Ubuntu 22.04 Postgres with 14

I’m using the packages install method for all LXC containers, no Snap packages.

  1. I exported the maas db from LXC Postgres 12
  2. Imported maas db dump into LXC Postgres 14
  3. pointed LXC Region 3.4 to LXC Postgres 14
  4. pointed LXC Region 3.2 to LXC Postgres 14
  5. pointed LXC Rrack 3.2 to LXC Postgres 14
  6. LXC MaaS 3.2 continues to work with out issues
  7. LXC Region 3.4 won’t connect to Postgres 14

I had to do all that because postgres 14 wouldn’t install for whatever package reasons. So i created a new postgres with latest.

Export

pg_dump dbname > outfile

Postgres 14
installed postgres14

Create User

sudo -i -u postgres psql -c "CREATE USER \"$MAAS_DBUSER\" WITH ENCRYPTED PASSWORD '$MAAS_DBPASS'"

Create MAAS DB

sudo -i -u postgres createdb -O "$MAAS_DBUSER" "$MAAS_DBNAME"

Imported

psql DB_NAME < INPUT_FILE

Hi @troyanov , do you have any updates? Thanks!

Hi @mk4umha
Sorry for my late response, I had a small vacation and decided not to take my laptop with me :slight_smile:

I cannot reproduce the error with the steps you’ve mentioned.
Can you please check that database settings for MAAS 3.4 are correct? /etc/maas/regiond.conf

Can you also provide output for the following query for your old MAAS database:

select * from django_migrations;

Could it be that you did some database modifications?