canonical / maas-ansible-playbook

An Ansible playbook for installing and configuring MAAS
Apache License 2.0
48 stars 37 forks source link

Race conditions with multiple maas hosts #59

Closed samuelallan72 closed 1 year ago

samuelallan72 commented 1 year ago

Similar to #58 , but defining as a more general issue throughout the maas installation/update process. Either race conditions or tasks that should only be run on a single host. In these cases, adding run_once: true to the task fixes the issue.

Tasks that have this issue:

TASK [maas_region_controller : Initialise MAAS Controller - Snap] **************
fatal: [192.168.122.186]: FAILED! => {"changed": true, "cmd": ["maas", "init", "region+rack", "--maas-url=http://192.168.122.12:5240/MAAS", "--database-uri", "postgres://maas:mypassword@192.168.122.12:5432/maasdb"], "delta": "0:00:05.727410", "end": "2022-12-11 22:26:35.112344", "msg": "non-zero return code", "rc": 1, "start": "2022-12-11 22:26:29.384934", "stderr": "Traceback (most recent call last):\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 82, in _execute\n    return self.cursor.execute(sql)\npsycopg2.errors.DuplicateTable: relation \"django_content_type\" already exists\n\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/snap/maas/23947/bin/maas-region\", line 8, in <module>\n    sys.exit(run())\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/region_script.py\", line 77, in run\n    run_django(is_snap, is_devenv)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/region_script.py\", line 66, in run_django\n    management.execute_from_command_line()\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line\n    utility.execute()\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 375, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 323, in run_from_argv\n    self.execute(*args, **cmd_options)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 364, in execute\n    output = self.handle(*args, **options)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/management/commands/dbupgrade.py\", line 125, in handle\n    call_command(\"migrate\", interactive=False)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 148, in call_command\n    return command.execute(*args, **defaults)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 364, in execute\n    output = self.handle(*args, **options)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 83, in wrapped\n    res = handle_func(*args, **kwargs)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py\", line 232, in handle\n    post_migrate_state = executor.migrate(\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/executor.py\", line 117, in migrate\n    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/executor.py\", line 147, in _migrate_all_forwards\n    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/executor.py\", line 245, in apply_migration\n    state = migration.apply(state, schema_editor)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/migration.py\", line 124, in apply\n    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/operations/models.py\", line 92, in database_forwards\n    schema_editor.create_model(model)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/base/schema.py\", line 307, in create_model\n    self.execute(sql, params or None)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/base/schema.py\", line 137, in execute\n    cursor.execute(sql, params)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 67, in execute\n    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 76, in _execute_with_wrappers\n    return executor(sql, params, many, context)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 84, in _execute\n    return self.cursor.execute(sql, params)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/utils.py\", line 89, in __exit__\n    raise dj_exc_value.with_traceback(traceback) from exc_value\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 82, in _execute\n    return self.cursor.execute(sql)\ndjango.db.utils.ProgrammingError: relation \"django_content_type\" already exists\n\nTraceback (most recent call last):\n  File \"/snap/maas/23947/bin/maas\", line 8, in <module>\n    sys.exit(main())\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/__init__.py\", line 39, in main\n    options.execute(options)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 448, in __call__\n    raise exc\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 445, in __call__\n    self.handle(options)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 649, in handle\n    self._finalize_init(mode, options)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 666, in _finalize_init\n    perform_work(\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 378, in perform_work\n    return cmd(*args, **kwargs)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 353, in migrate_db\n    subprocess.check_call(\n  File \"/usr/lib/python3.8/subprocess.py\", line 364, in check_call\n    raise CalledProcessError(retcode, cmd)\nsubprocess.CalledProcessError: Command '['/snap/maas/23947/bin/maas-region', 'dbupgrade']' returned non-zero exit status 1.", "stderr_lines": ["Traceback (most recent call last):", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 82, in _execute", "    return self.cursor.execute(sql)", "psycopg2.errors.DuplicateTable: relation \"django_content_type\" already exists", "", "", "The above exception was the direct cause of the following exception:", "", "Traceback (most recent call last):", "  File \"/snap/maas/23947/bin/maas-region\", line 8, in <module>", "    sys.exit(run())", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/region_script.py\", line 77, in run", "    run_django(is_snap, is_devenv)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/region_script.py\", line 66, in run_django", "    management.execute_from_command_line()", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line", "    utility.execute()", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 375, in execute", "    self.fetch_command(subcommand).run_from_argv(self.argv)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 323, in run_from_argv", "    self.execute(*args, **cmd_options)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 364, in execute", "    output = self.handle(*args, **options)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/management/commands/dbupgrade.py\", line 125, in handle", "    call_command(\"migrate\", interactive=False)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 148, in call_command", "    return command.execute(*args, **defaults)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 364, in execute", "    output = self.handle(*args, **options)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 83, in wrapped", "    res = handle_func(*args, **kwargs)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py\", line 232, in handle", "    post_migrate_state = executor.migrate(", "  File \"/snap/maas/23947/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 \"/snap/maas/23947/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 \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/executor.py\", line 245, in apply_migration", "    state = migration.apply(state, schema_editor)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/migration.py\", line 124, in apply", "    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/operations/models.py\", line 92, in database_forwards", "    schema_editor.create_model(model)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/base/schema.py\", line 307, in create_model", "    self.execute(sql, params or None)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/base/schema.py\", line 137, in execute", "    cursor.execute(sql, params)", "  File \"/snap/maas/23947/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 \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 76, in _execute_with_wrappers", "    return executor(sql, params, many, context)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 84, in _execute", "    return self.cursor.execute(sql, params)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/utils.py\", line 89, in __exit__", "    raise dj_exc_value.with_traceback(traceback) from exc_value", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 82, in _execute", "    return self.cursor.execute(sql)", "django.db.utils.ProgrammingError: relation \"django_content_type\" already exists", "", "Traceback (most recent call last):", "  File \"/snap/maas/23947/bin/maas\", line 8, in <module>", "    sys.exit(main())", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/__init__.py\", line 39, in main", "    options.execute(options)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 448, in __call__", "    raise exc", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 445, in __call__", "    self.handle(options)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 649, in handle", "    self._finalize_init(mode, options)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 666, in _finalize_init", "    perform_work(", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 378, in perform_work", "    return cmd(*args, **kwargs)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 353, in migrate_db", "    subprocess.check_call(", "  File \"/usr/lib/python3.8/subprocess.py\", line 364, in check_call", "    raise CalledProcessError(retcode, cmd)", "subprocess.CalledProcessError: Command '['/snap/maas/23947/bin/maas-region', 'dbupgrade']' returned non-zero exit status 1."], "stdout": "Starting services\nPerforming database migrations\nOperations to perform:\n  Apply all migrations: auth, contenttypes, maasserver, metadataserver, piston3, sessions, sites\nRunning migrations:\n  Applying contenttypes.0001_initial...", "stdout_lines": ["Starting services", "Performing database migrations", "Operations to perform:", "  Apply all migrations: auth, contenttypes, maasserver, metadataserver, piston3, sessions, sites", "Running migrations:", "  Applying contenttypes.0001_initial..."]}
fatal: [192.168.122.12]: FAILED! => {"changed": true, "cmd": ["maas", "init", "region+rack", "--maas-url=http://192.168.122.12:5240/MAAS", "--database-uri", "postgres://maas:mypassword@192.168.122.12:5432/maasdb"], "delta": "0:00:15.487025", "end": "2022-12-11 22:26:44.868810", "msg": "non-zero return code", "rc": 1, "start": "2022-12-11 22:26:29.381785", "stderr": "Traceback (most recent call last):\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 82, in _execute\n    return self.cursor.execute(sql)\npsycopg2.errors.DuplicateTable: relation \"maasserver_podhints\" already exists\n\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/snap/maas/23947/bin/maas-region\", line 8, in <module>\n    sys.exit(run())\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/region_script.py\", line 77, in run\n    run_django(is_snap, is_devenv)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/region_script.py\", line 66, in run_django\n    management.execute_from_command_line()\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line\n    utility.execute()\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 375, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 323, in run_from_argv\n    self.execute(*args, **cmd_options)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 364, in execute\n    output = self.handle(*args, **options)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/management/commands/dbupgrade.py\", line 125, in handle\n    call_command(\"migrate\", interactive=False)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 148, in call_command\n    return command.execute(*args, **defaults)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 364, in execute\n    output = self.handle(*args, **options)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 83, in wrapped\n    res = handle_func(*args, **kwargs)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py\", line 232, in handle\n    post_migrate_state = executor.migrate(\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/executor.py\", line 117, in migrate\n    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/executor.py\", line 147, in _migrate_all_forwards\n    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/executor.py\", line 245, in apply_migration\n    state = migration.apply(state, schema_editor)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/migration.py\", line 124, in apply\n    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/operations/models.py\", line 92, in database_forwards\n    schema_editor.create_model(model)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/base/schema.py\", line 307, in create_model\n    self.execute(sql, params or None)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/base/schema.py\", line 137, in execute\n    cursor.execute(sql, params)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 67, in execute\n    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 76, in _execute_with_wrappers\n    return executor(sql, params, many, context)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 84, in _execute\n    return self.cursor.execute(sql, params)\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/utils.py\", line 89, in __exit__\n    raise dj_exc_value.with_traceback(traceback) from exc_value\n  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 82, in _execute\n    return self.cursor.execute(sql)\ndjango.db.utils.ProgrammingError: relation \"maasserver_podhints\" already exists\n\nTraceback (most recent call last):\n  File \"/snap/maas/23947/bin/maas\", line 8, in <module>\n    sys.exit(main())\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/__init__.py\", line 39, in main\n    options.execute(options)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 448, in __call__\n    raise exc\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 445, in __call__\n    self.handle(options)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 649, in handle\n    self._finalize_init(mode, options)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 666, in _finalize_init\n    perform_work(\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 378, in perform_work\n    return cmd(*args, **kwargs)\n  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 353, in migrate_db\n    subprocess.check_call(\n  File \"/usr/lib/python3.8/subprocess.py\", line 364, in check_call\n    raise CalledProcessError(retcode, cmd)\nsubprocess.CalledProcessError: Command '['/snap/maas/23947/bin/maas-region', 'dbupgrade']' returned non-zero exit status 1.", "stderr_lines": ["Traceback (most recent call last):", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 82, in _execute", "    return self.cursor.execute(sql)", "psycopg2.errors.DuplicateTable: relation \"maasserver_podhints\" already exists", "", "", "The above exception was the direct cause of the following exception:", "", "Traceback (most recent call last):", "  File \"/snap/maas/23947/bin/maas-region\", line 8, in <module>", "    sys.exit(run())", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/region_script.py\", line 77, in run", "    run_django(is_snap, is_devenv)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/region_script.py\", line 66, in run_django", "    management.execute_from_command_line()", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line", "    utility.execute()", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 375, in execute", "    self.fetch_command(subcommand).run_from_argv(self.argv)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 323, in run_from_argv", "    self.execute(*args, **cmd_options)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 364, in execute", "    output = self.handle(*args, **options)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maasserver/management/commands/dbupgrade.py\", line 125, in handle", "    call_command(\"migrate\", interactive=False)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/__init__.py\", line 148, in call_command", "    return command.execute(*args, **defaults)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 364, in execute", "    output = self.handle(*args, **options)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/base.py\", line 83, in wrapped", "    res = handle_func(*args, **kwargs)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py\", line 232, in handle", "    post_migrate_state = executor.migrate(", "  File \"/snap/maas/23947/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 \"/snap/maas/23947/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 \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/executor.py\", line 245, in apply_migration", "    state = migration.apply(state, schema_editor)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/migration.py\", line 124, in apply", "    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/migrations/operations/models.py\", line 92, in database_forwards", "    schema_editor.create_model(model)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/base/schema.py\", line 307, in create_model", "    self.execute(sql, params or None)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/base/schema.py\", line 137, in execute", "    cursor.execute(sql, params)", "  File \"/snap/maas/23947/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 \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 76, in _execute_with_wrappers", "    return executor(sql, params, many, context)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 84, in _execute", "    return self.cursor.execute(sql, params)", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/utils.py\", line 89, in __exit__", "    raise dj_exc_value.with_traceback(traceback) from exc_value", "  File \"/snap/maas/23947/usr/lib/python3/dist-packages/django/db/backends/utils.py\", line 82, in _execute", "    return self.cursor.execute(sql)", "django.db.utils.ProgrammingError: relation \"maasserver_podhints\" already exists", "", "Traceback (most recent call last):", "  File \"/snap/maas/23947/bin/maas\", line 8, in <module>", "    sys.exit(main())", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/__init__.py\", line 39, in main", "    options.execute(options)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 448, in __call__", "    raise exc", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 445, in __call__", "    self.handle(options)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 649, in handle", "    self._finalize_init(mode, options)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 666, in _finalize_init", "    perform_work(", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 378, in perform_work", "    return cmd(*args, **kwargs)", "  File \"/snap/maas/23947/lib/python3.8/site-packages/maascli/snap.py\", line 353, in migrate_db", "    subprocess.check_call(", "  File \"/usr/lib/python3.8/subprocess.py\", line 364, in check_call", "    raise CalledProcessError(retcode, cmd)", "subprocess.CalledProcessError: Command '['/snap/maas/23947/bin/maas-region', 'dbupgrade']' returned non-zero exit status 1."], "stdout": "Starting services\nPerforming database migrations\nOperations to perform:\n  Apply all migrations: auth, contenttypes, maasserver, metadataserver, piston3, sessions, sites\nRunning migrations:\n  Applying maasserver.0107_chassis_to_pods...", "stdout_lines": ["Starting services", "Performing database migrations", "Operations to perform:", "  Apply all migrations: auth, contenttypes, maasserver, metadataserver, piston3, sessions, sites", "Running migrations:", "  Applying maasserver.0107_chassis_to_pods..."]}
changed: [192.168.122.206]
TASK [maas_region_controller : Add an administrator to MAAS] *******************
fatal: [192.168.122.24]: FAILED! => {"changed": true, "cmd": ["maas", "createadmin", "--username=admin", "--password=admin", "--email=admin@email.com", "--ssh-import=admin"],
 "delta": "0:00:01.207001", "end": "2022-12-11 22:39:00.127391", "msg": "non-zero return code", "rc": 2, "start": "2022-12-11 22:38:58.920390", "stderr": "usage: maas [-h] CO
MMAND ...\n\noptional arguments:\n  -h, --help      show this help message and exit\n\ndrill down:\n  COMMAND\n    login         Log in to a remote API, and remember its desc
ription and\n                  credentials.\n    logout        Log out of a remote API, purging any stored credentials.\n    list          List remote APIs that have been log
ged-in to.\n    refresh       Refresh the API descriptions of all profiles.\n    init          Initialise MAAS in the specified run mode.\n    config        View or change co
ntroller configuration.\n    status        Status of controller services.\n    migrate       Perform migrations on connected database.\n    apikey        Used to manage a use
r's API keys. Shows existing keys unless\n                  --generate or --delete is passed.\n    configauth    Configure external authentication.\n    config-tls    Configu
re MAAS Region TLS.\n    createadmin   Create a MAAS administrator account.\n    changepassword\n                  Change a MAAS user's password.\n\nhttps://maas.io/\n\nfe_se
ndauth: no password supplied", "stderr_lines": ["usage: maas [-h] COMMAND ...", "", "optional arguments:", "  -h, --help      show this help message and exit", "", "drill dow
n:", "  COMMAND", "    login         Log in to a remote API, and remember its description and", "                  credentials.", "    logout        Log out of a remote API,
purging any stored credentials.", "    list          List remote APIs that have been logged-in to.", "    refresh       Refresh the API descriptions of all profiles.", "    i
nit          Initialise MAAS in the specified run mode.", "    config        View or change controller configuration.", "    status        Status of controller services.", "
   migrate       Perform migrations on connected database.", "    apikey        Used to manage a user's API keys. Shows existing keys unless", "                  --generate o
r --delete is passed.", "    configauth    Configure external authentication.", "    config-tls    Configure MAAS Region TLS.", "    createadmin   Create a MAAS administrator
 account.", "    changepassword", "                  Change a MAAS user's password.", "", "https://maas.io/", "", "fe_sendauth: no password supplied"], "stdout": "", "stdout_
lines": []}
fatal: [192.168.122.71]: FAILED! => {"changed": true, "cmd": ["maas", "createadmin", "--username=admin", "--password=admin", "--email=admin@email.com", "--ssh-import=admin"],
 "delta": "0:00:01.205140", "end": "2022-12-11 22:39:00.128276", "msg": "non-zero return code", "rc": 2, "start": "2022-12-11 22:38:58.923136", "stderr": "usage: maas [-h] CO
MMAND ...\n\noptional arguments:\n  -h, --help      show this help message and exit\n\ndrill down:\n  COMMAND\n    login         Log in to a remote API, and remember its desc
ription and\n                  credentials.\n    logout        Log out of a remote API, purging any stored credentials.\n    list          List remote APIs that have been log
ged-in to.\n    refresh       Refresh the API descriptions of all profiles.\n    init          Initialise MAAS in the specified run mode.\n    config        View or change co
ntroller configuration.\n    status        Status of controller services.\n    migrate       Perform migrations on connected database.\n    apikey        Used to manage a use
r's API keys. Shows existing keys unless\n                  --generate or --delete is passed.\n    configauth    Configure external authentication.\n    config-tls    Configu
re MAAS Region TLS.\n    createadmin   Create a MAAS administrator account.\n    changepassword\n                  Change a MAAS user's password.\n\nhttps://maas.io/\n\nfe_se
ndauth: no password supplied", "stderr_lines": ["usage: maas [-h] COMMAND ...", "", "optional arguments:", "  -h, --help      show this help message and exit", "", "drill dow
n:", "  COMMAND", "    login         Log in to a remote API, and remember its description and", "                  credentials.", "    logout        Log out of a remote API,
purging any stored credentials.", "    list          List remote APIs that have been logged-in to.", "    refresh       Refresh the API descriptions of all profiles.", "    i
nit          Initialise MAAS in the specified run mode.", "    config        View or change controller configuration.", "    status        Status of controller services.", "
   migrate       Perform migrations on connected database.", "    apikey        Used to manage a user's API keys. Shows existing keys unless", "                  --generate o
r --delete is passed.", "    configauth    Configure external authentication.", "    config-tls    Configure MAAS Region TLS.", "    createadmin   Create a MAAS administrator
 account.", "    changepassword", "                  Change a MAAS user's password.", "", "https://maas.io/", "", "fe_sendauth: no password supplied"], "stdout": "", "stdout_
lines": []}
changed: [192.168.122.237]
TASK [maas_region_controller : Wait For MAAS To Create Secret File] ************
ok: [192.168.122.237]
fatal: [192.168.122.71]: FAILED! => {"changed": false, "elapsed": 300, "msg": "Timeout when waiting for file /var/snap/maas/common/maas/secret"}
fatal: [192.168.122.24]: FAILED! => {"changed": false, "elapsed": 300, "msg": "Timeout when waiting for file /var/snap/maas/common/maas/secret"}
ElineMaaikedeWeerd commented 1 year ago

82 should have fixed all of these race conditions