# postgres-0 status is CrashLoopBackOff

**URL:** <https://forum.ansible.com/t/postgres-0-status-is-crashloopbackoff/35687>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [August 30, 2021, 8:35am UTC](https://forum.ansible.com/t/postgres-0-status-is-crashloopbackoff/35687 "2021-08-30T08:35:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasu](https://avatars.discourse-cdn.com/v4/letter/y/958977/32.png) [@Yasu](https://forum.ansible.com/u/Yasu)\
**Post date:** [August 30, 2021, 8:35am UTC](https://forum.ansible.com/t/postgres-0-status-is-crashloopbackoff/35687/1 "2021-08-30T08:35:44Z")

</div>

Hi,

I’ve been using AWX 19.3.0 / AWX operator 0.13.0 on minikube.  
After deploying AWX, I was able to access it without any problems. But, I have lost access to AWX today.

The status of postgres-0 pod was CrashLoopBackOff.  
The log output was “initdb: error: directory “/var/lib/postgresql/data/pgdata” exists but is not empty”.

Is there any way to recover?  
I would be grateful if anyone could comment.

The following is the status of the pod and the output of describe and log.

[root@centos-tools ~]# kubectl get pods  
NAME READY STATUS RESTARTS AGE  
awx-demo-7bbb564887-m7t5n 4/4 Running 8 13d  
awx-demo-postgres-0 0/1 CrashLoopBackOff 834 13d  
awx-operator-69c646c48f-cbf5k 1/1 Running 1 13d

---

<div class="post-metadata">

**Author:** ![Abhinit\_Mallick](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Abhinit\_Mallick](https://forum.ansible.com/u/Abhinit_Mallick)\
**Post date:** [August 31, 2021, 4:20pm UTC](https://forum.ansible.com/t/postgres-0-status-is-crashloopbackoff/35687/2 "2021-08-31T16:20:45Z")

</div>

Hi Yasu

Few rhetorical queries

1. Are you using an external postgres DB for AWX ??  
if external then where does “/var/lib/postgresql/data/pgdata” map to

2. Is it a fresh installation or are you trying to migrate things ???

3. please share the yamls which you are using to start the AWX

Regards  
Abhinit

---

<div class="post-metadata">

**Author:** ![Yasu](https://avatars.discourse-cdn.com/v4/letter/y/958977/32.png) [@Yasu](https://forum.ansible.com/u/Yasu)\
**Post date:** [September 2, 2021, 7:23am UTC](https://forum.ansible.com/t/postgres-0-status-is-crashloopbackoff/35687/3 "2021-09-02T07:23:16Z")

</div>

Hi Abhinit,

Thank you for your reply.

1. Are you using an external postgres DB for AWX ??  
No, I using internal postgres DB.

2. Is it a fresh installation or are you trying to migrate things ???  
It is the fresh installation.

3. please share the yamls which you are using to start the AWX  
I used the following YAML.

kubectl apply -f [https://raw.githubusercontent.com/ansible/awx-operator/0.13.0/deploy/awx-operator.yaml](https://raw.githubusercontent.com/ansible/awx-operator/0.13.0/deploy/awx-operator.yaml)  
kubectl apply -f awx-demo.yml

> > > > >

# cat awx-demo.yml

---

<div class="post-metadata">

**Author:** ![Abhinit\_Mallick](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Abhinit\_Mallick](https://forum.ansible.com/u/Abhinit_Mallick)\
**Post date:** [September 5, 2021, 5:08pm UTC](https://forum.ansible.com/t/postgres-0-status-is-crashloopbackoff/35687/4 "2021-09-05T17:08:47Z")

</div>

Hi Yasu

As it’s is fresh setup I would rather request you to use an external postgres database which will be hosted on your minikube where the postgres database will store the data in your local minikube host ( in that way if you backup the filesystem your postgres is getting backed up)  
Your awx will basically access the external postgres and will keep running.  
If you are fine with the solution  
I can share the configuration with you .

Regards  
Abhinit

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [September 5, 2021, 9:12pm UTC](https://forum.ansible.com/t/postgres-0-status-is-crashloopbackoff/35687/5 "2021-09-05T21:12:34Z")

</div>

Hi,

Looking at postgres:12 image, the docker-entry.sh has the following:

|
| |
| 

docker\_setup\_env() {

 |
| | 

file\_env ‘POSTGRES\_PASSWORD’

 |
| | |
| | 

file\_env ‘POSTGRES\_USER’ ‘postgres’

 |
| | 

file\_env ‘POSTGRES\_DB’ “$POSTGRES\_USER”

 |
| | 

file\_env ‘POSTGRES\_INITDB\_ARGS’

 |
| | 
# default authentication method is md5
 |
| | 

: “${POSTGRES\_HOST\_AUTH\_METHOD:=md5}”

 |
| | |
| | 

**declare -g DATABASE\_ALREADY\_EXISTS**

 |
| | 
# look specifically for PG\_VERSION, as it is expected in the DB dir
 |
| | 

**if [-s “$PGDATA/PG\_VERSION”]; then**

 |
| | 

**DATABASE\_ALREADY\_EXISTS=‘true’**

 |
| | 

**fi**

 |
| | 

}

 |
| |

This docker\_setup\_env() function gets called at the beginning of the \_main() and the postgres goes to a initdb path since DATABASE\_ALREADY\_EXISTS is empty.

| 
# only run initialization on an empty data directory
 |
| | 

if [**-z “$DATABASE\_ALREADY\_EXISTS”**]; then

 |
| | 

docker\_verify\_minimum\_env

 |
| | |
| | 
# check dir permissions to reduce likelihood of half-initialized database
 |
| | 

ls /docker-entrypoint-initdb.d/ \> /dev/null

 |
| | |
| | 

**docker\_init\_database\_dir**

 |
| | 

pg\_setup\_hba\_conf

 |

Looks like in your case your PGDATA path exists, but the PG\_VERSION file is not there or empty. I think your postgres db is corrupt. You need to rebuild the DB, and restore from a backup.

HTH,

---

<div class="post-metadata">

**Author:** ![Yasu](https://avatars.discourse-cdn.com/v4/letter/y/958977/32.png) [@Yasu](https://forum.ansible.com/u/Yasu)\
**Post date:** [September 6, 2021, 12:24am UTC](https://forum.ansible.com/t/postgres-0-status-is-crashloopbackoff/35687/6 "2021-09-06T00:24:13Z")

</div>

Hi Abhinit,

Thank you for your reply.

I understand it.  
Could you please share the configuration?

Best Regard,  
Yasu

2021年9月6日月曜日 2:08:47 UTC+9 Abhinit Mallick:
