# Database migration fails when deploying on kubernetes

**URL:** <https://forum.ansible.com/t/database-migration-fails-when-deploying-on-kubernetes/30102>\
**Category:** AWX Project\
**Tags:** kubernetes, awx\
**Created:** [April 12, 2019, 9:46am UTC](https://forum.ansible.com/t/database-migration-fails-when-deploying-on-kubernetes/30102 "2019-04-12T09:46:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alancivita](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@alancivita](https://forum.ansible.com/u/alancivita)\
**Post date:** [April 12, 2019, 9:46am UTC](https://forum.ansible.com/t/database-migration-fails-when-deploying-on-kubernetes/30102/1 "2019-04-12T09:46:06Z")

</div>

Hi,  
i’m trying to install awx on Kubernetes.  
the playbook fails on Migrate database task with the following error:

TASK [kubernetes : Migrate database] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“changed”: true, “cmd”: “kubectl -n awx exec ansible-tower-management – bash -c "awx-manage migrate --noinput"”, “delta”: “0:00:28.141537”, “end”: “2019-04-12 10:31:15.798689”, “msg”: “non-zero return code”, “rc”: 137, “start”: “2019-04-12 10:30:47.657152”, “stderr”: “command terminated with exit code 137”, “stderr\_lines”: [“command terminated with exit code 137”], “stdout”: “Operations to perform:\n Apply all migrations: auth, conf, contenttypes, main, oauth2\_provider, sessions, sites, social\_django, sso, taggit\nRunning migrations:\n Applying main.0002\_squashed\_v300\_release…”, “stdout\_lines”: [“Operations to perform:”, " Apply all migrations: auth, conf, contenttypes, main, oauth2\_provider, sessions, sites, social\_django, sso, taggit", “Running migrations:”, " Applying main.0002\_squashed\_v300\_release…"]}

If i run the awx-manage migrate --noinput manually from the management container, it fails wiht the following error:

bash-4.2$ awx-manage migrate --noinput  
Operations to perform:  
Apply all migrations: auth, conf, contenttypes, main, oauth2\_provider, sessions, sites, social\_django, sso, taggit  
Running migrations:  
Applying main.0002\_squashed\_v300\_release…Killed  
bash-4.2$

The postgres pod shows these errors

2019-04-12 09:17:48.166 GMT [65] LOG: listening on IPv4 address “127.0.0.1”, port 5432  
2019-04-12 09:17:48.166 GMT [65] LOG: could not bind IPv6 address “::1”: Cannot assign requested address  
2019-04-12 09:17:48.166 GMT [65] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.  
2019-04-12 09:17:48.170 GMT [65] LOG: listening on Unix socket “/tmp/.s.PGSQL.5432”  
2019-04-12 09:17:48.179 GMT [66] LOG: database system was shut down at 2019-04-12 09:17:47 GMT  
2019-04-12 09:17:48.183 GMT [65] LOG: database system is ready to accept connections  
2019-04-12 09:17:51.452 GMT [65] LOG: received fast shutdown request  
2019-04-12 09:17:51.455 GMT [65] LOG: aborting any active transactions  
2019-04-12 09:17:51.458 GMT [65] LOG: worker process: logical replication launcher (PID 72) exited with exit code 1  
2019-04-12 09:17:51.459 GMT [67] LOG: shutting down  
2019-04-12 09:17:51.479 GMT [65] LOG: database system is shut down  
2019-04-12 09:17:58.255 GMT [118] LOG: listening on IPv4 address “0.0.0.0”, port 5432  
2019-04-12 09:17:58.255 GMT [118] LOG: listening on IPv6 address “::”, port 5432  
2019-04-12 09:17:58.258 GMT [118] LOG: listening on Unix socket “/tmp/.s.PGSQL.5432”  
2019-04-12 09:17:58.268 GMT [119] LOG: database system was shut down at 2019-04-12 09:17:51 GMT  
2019-04-12 09:17:58.272 GMT [118] LOG: database system is ready to accept connections  
2019-04-12 09:18:36.691 GMT [182] LOG: incomplete startup packet  
2019-04-12 09:18:38.069 GMT [183] LOG: incomplete startup packet  
2019-04-12 09:18:55.671 GMT [204] ERROR: relation “conf\_setting” does not exist at character 158

…

2019-04-12 09:18:55.757 GMT [204] ERROR: relation “django\_migrations” does not exist at character 124  
2019-04-12 09:18:55.757 GMT [204] STATEMENT: SELECT “django\_migrations”.“id”, “django\_migrations”.“app”, “django\_migrations”.“name”, “django\_migrations”.“applied” FROM “django\_migrations” WHERE (“django\_migrations”."  
app" = ‘main’ AND NOT (“django\_migrations”.“name”::text LIKE ‘%squashed%’)) ORDER BY “django\_migrations”.“id” DESC LIMIT 1  
2019-04-12 09:18:55.758 GMT [204] ERROR: relation “django\_migrations” does not exist at character 124  
2019-04-12 09:18:55.758 GMT [204] STATEMENT: SELECT “django\_migrations”.“id”, “django\_migrations”.“app”, “django\_migrations”.“name”, “django\_migrations”.“applied” FROM “django\_migrations” WHERE (“django\_migrations”."  
app" = ‘main’ AND NOT (“django\_migrations”.“name”::text LIKE ‘%squashed%’)) ORDER BY “django\_migrations”.“id” DESC LIMIT 1  
2019-04-12 09:18:55.773 GMT [204] ERROR: relation “django\_migrations” does not exist at character 124  
2019-04-12 09:18:55.773 GMT [204] STATEMENT: SELECT “django\_migrations”.“id”, “django\_migrations”.“app”, “django\_migrations”.“name”, “django\_migrations”.“applied” FROM “django\_migrations” WHERE (“django\_migrations”."  
app" = ‘main’ AND “django\_migrations”.“name” IN (‘0005a\_squashed\_v310\_v313\_updates’, ‘0005b\_squashed\_v310\_v313\_updates’))  
2019-04-12 09:18:55.846 GMT [204] ERROR: relation “django\_migrations” does not exist at character 124  
2019-04-12 09:18:55.846 GMT [204] STATEMENT: SELECT “django\_migrations”.“id”, “django\_migrations”.“app”, “django\_migrations”.“name”, “django\_migrations”.“applied” FROM “django\_migrations” WHERE (“django\_migrations”."  
app" = ‘main’ AND NOT (“django\_migrations”.“name”::text LIKE ‘%squashed%’)) ORDER BY “django\_migrations”.“id” DESC LIMIT 1  
2019-04-12 09:18:55.849 GMT [204] ERROR: relation “django\_migrations” does not exist at character 124  
2019-04-12 09:18:55.849 GMT [204] STATEMENT: SELECT “django\_migrations”.“id”, “django\_migrations”.“app”, “django\_migrations”.“name”, “django\_migrations”.“applied” FROM “django\_migrations” WHERE (“django\_migrations”."  
app" = ‘main’ AND NOT (“django\_migrations”.“name”::text LIKE ‘%squashed%’)) ORDER BY “django\_migrations”.“id” DESC LIMIT 1  
2019-04-12 09:18:55.859 GMT [204] ERROR: relation “django\_migrations” does not exist at character 124  
2019-04-12 09:18:55.859 GMT [204] STATEMENT: SELECT “django\_migrations”.“id”, “django\_migrations”.“app”, “django\_migrations”.“name”, “django\_migrations”.“applied” FROM “django\_migrations” WHERE (“django\_migrations”."  
app" = ‘main’ AND NOT (“django\_migrations”.“name”::text LIKE ‘%squashed%’)) ORDER BY “django\_migrations”.“id” DESC LIMIT 1  
2019-04-12 09:18:55.860 GMT [204] ERROR: relation “django\_migrations” does not exist at character 124  
2019-04-12 09:18:55.860 GMT [204] STATEMENT: SELECT “django\_migrations”.“id”, “django\_migrations”.“app”, “django\_migrations”.“name”, “django\_migrations”.“applied” FROM “django\_migrations” WHERE (“django\_migrations”."  
app" = ‘main’ AND NOT (“django\_migrations”.“name”::text LIKE ‘%squashed%’)) ORDER BY “django\_migrations”.“id” DESC LIMIT 1  
2019-04-12 09:19:14.889 GMT [232] ERROR: must be owner of database awx  
2019-04-12 09:19:14.889 GMT [232] STATEMENT: ALTER DATABASE “awx” OWNER TO “awx”  
2019-04-12 09:19:16.852 GMT [239] ERROR: null value in column “last\_login” violates not-null constraint  
2019-04-12 09:19:16.852 GMT [239] DETAIL: Failing row contains (1, pbkdf2\_sha256$36000$SNsseCGyWasm$dVcUZtNs0Av7aKV2lMTZKEBks69US0F…, null, t, admin, , , root@localhost, t, t, 2019-04-12 09:19:16.79675+00).  
2019-04-12 09:19:16.852 GMT [239] STATEMENT: INSERT INTO “auth\_user” (“password”, “last\_login”, “is\_superuser”, “username”, “first\_name”, “last\_name”, “email”, “is\_staff”, “is\_active”, “date\_joined”) VALUES (‘pbkdf2\_  
sha256$36000$SNsseCGyWasm$dVcUZtNs0Av7aKV2lMTZKEBks69US0FMbdzaAIquU5Y=’, NULL, true, ‘admin’, ‘’, ‘’, ‘root@localhost’, true, true, ‘2019-04-12T09:19:16.796750+00:00’::timestamptz) RETURNING “auth\_user”.“id”  
2019-04-12 09:19:17.546 GMT [240] ERROR: must be owner of database awx  
2019-04-12 09:19:17.546 GMT [240] STATEMENT: ALTER DATABASE “awx” OWNER TO “awx”  
2019-04-12 09:19:19.348 GMT [248] ERROR: relation “conf\_setting” does not exist at character 158

any tips?

---

<div class="post-metadata">

**Author:** ![Uriel](https://avatars.discourse-cdn.com/v4/letter/u/53a042/32.png) [@Uriel](https://forum.ansible.com/u/Uriel)\
**Post date:** [April 16, 2019, 4:17pm UTC](https://forum.ansible.com/t/database-migration-fails-when-deploying-on-kubernetes/30102/2 "2019-04-16T16:17:40Z")

</div>

Your error message is giving you a lot of information right there. Start off by making sure that the AWX db’s owner is actually awx
