MAAS Region Controller DB Connection Issue from 3.1.0 to 3.2.0

I’m running HA Mode with separate DB.

I created a new MAAS Region server installing from the 3.2 PPA Debian install.

Updated the config file to connect to the existing DB, but it fails with this.

I’m not sure if DB Table needs to be updated to match 3.2 or not.

/var/log/maas/regiond.log

2022-08-27 15:04:05 maasserver.start_up: [error] Database error during start-up
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.UndefinedTable: relation "maasserver_nodeconfig" does not exist
LINE 1: ...last_sync" FROM "maasserver_node" LEFT OUTER JOIN "maasserve...
                                                             ^


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

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/maasserver/start_up.py", line 65, in start_up
    yield deferToDatabase(inner_start_up, master=master)
  File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 250, in inContext
    result = inContext.theWork()
  File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 266, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
  File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 856, in callInContext
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 202, in wrapper
    result = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 711, in call_with_connection
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/__init__.py", line 197, in call_with_lock
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 756, in call_within_transaction
    return func_outside_txn(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 559, in retrier
    return func(*args, **kwargs)
  File "/usr/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3/dist-packages/maasserver/start_up.py", line 118, in inner_start_up
    node = RegionController.objects.get_or_create_running_controller()
  File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 748, in get_or_create_running_controller
    node = self._find_or_create_running_controller()
  File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 785, in _find_or_create_running_controller
    node = self._find_running_node()
  File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 807, in _find_running_node
    return get_one(nodes.distinct())
  File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 117, in get_one
    retrieved_items = tuple(islice(items, 0, 2))
  File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 274, in __iter__
    self._fetch_all()
  File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 1242, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 55, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/usr/lib/python3/dist-packages/django/db/models/sql/compiler.py", line 1140, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 67, 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 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python3/dist-packages/django/db/utils.py", line 89, 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.ProgrammingError: relation "maasserver_nodeconfig" does not exist
LINE 1: ...last_sync" FROM "maasserver_node" LEFT OUTER JOIN "maasserve...

Could you please provide the exact steps you took to install/configure the new controller?

Setup new LXC Container using latest Ubuntu with the following cloud INIT, then copy over the regiond.conf with DB settings to connect.

config:

user.user-data: |
#cloud-config
apt:
sources:
maas-ppa:
source: ppa:maas/3.2
package_upgrade: true
package_update: true
package_reboot_if_required: true
packages:
- maas-region-api
- vim

Is this new region the only one running 3.2?

If that’s the case, I’d suggest to first upgrade existing controllers to 3.2, as that will also perform database schema upgrades.
Those can also be performed by manually running maas-region dbupgrade.

Note however that older controllers might have issues once the database has been upgrade to the 3.2 schema (hence you should upgrade those).

Yea, I am currently on 3.1 in HA Mode with seperate Postgres DB.

I created a new 3.2 region to connect to the current DB. There were no instructions on how to upgrade to 3.2 if I was in HA Mode.

Let me try that and let you know if that worked.

That worked! Thanks!