awx icon indicating copy to clipboard operation
awx copied to clipboard

Postgres Container Exited Unexpectedly, Won't start again

Open rootameen opened this issue 9 years ago • 14 comments

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • Installer
SUMMARY

AWX Installation was completed, and the system was up and running. Suddenly a few days later, the Postgres DB Container Exited with the attached log messages when invoking docker logs -f postgres. Note that the messages between lines 229 - 243 are repeating over 60K times and I had to trim them down to reduce the log size. I tried starting the container manually again but it keeps failing for the same reason.

ENVIRONMENT
STEPS TO REPRODUCE

Unknown, but problem persists after trying to manually start the container

EXPECTED RESULTS

To have the container working

ACTUAL RESULTS

DB Not working, and Web is reporting internal server error.

awx_postgres docker log.txt awx_web docker log.txt

ADDITIONAL INFORMATION

rootameen avatar Sep 23 '17 21:09 rootameen

Something pretty catastrophic happened to your database container and/or the underlying files/filesystem.

I'm not sure what we could reasonably do about this... I'd imagine you'll need to start from scratch as I'm not sure how recoverable the data is going to be.

I'm going to close this issue because I'm not sure what we could do to mitigate this or recover from it. I can only speculate as to what caused it originally.

If running the database in a container is concerning to you, you may consider moving the database external to the AWX application itself, see this part of the inventory file used by the installer:

https://github.com/ansible/awx/blob/devel/installer/inventory#L44-L50

matburt avatar Sep 24 '17 04:09 matburt

Hi @matburt, if I wanted to redeploy using the same method / host, what would the steps be? clearly stopping / removing all containers and images and running installer again does not fix it.

I also found this in /var/log/messages:

kernel: device veth5ada685 entered promiscuous mode
kernel: IPv6: ADDRCONF(NETDEV_UP): veth5ada685: link is not ready
NetworkManager[669]: <info>  [1506244252.1530] manager: (veth98c7ddb): new Veth device (/org/freedesktop/NetworkManager/Devices/94)
NetworkManager[669]: <info>  [1506244252.1541] manager: (veth5ada685): new Veth device (/org/freedesktop/NetworkManager/Devices/95)
firewalld: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C DOCKER -p tcp -d 0/0 --dport 80 -j DNAT --to-destination 172.17.0.4:8052 ! -i docker0' failed:
firewalld: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.4 --dport 8052 -j ACCEPT' failed:
firewalld: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C POSTROUTING -p tcp -s 172.17.0.4 -d 172.17.0.4 --dport 8052 -j MASQUERADE' failed:
kernel: docker0: port 3(veth5ada685) entered disabled state
kernel: device veth5ada685 left promiscuous mode
kernel: docker0: port 3(veth5ada685) entered disabled state
NetworkManager[669]: <info>  [1506244252.2769] device (veth98c7ddb): driver 'veth' does not support carrier detection.

rootameen avatar Sep 24 '17 09:09 rootameen

I'm really not sure what is going on with docker on your system, I haven't seen this behavior before. You didn't mention what platform you are on, but it's possible your docker/kernel is out of date? Your platform/distro documentation or maintainers might be able to help you more.

matburt avatar Sep 25 '17 12:09 matburt

I'd like to add that we've had the same/similar behavior twice on our CentOs VM setup.

Everything work fine, and after a few days, the Postgres container fall into a restart loop. We had this behavior twice on vanilla setup. We are now planing on using an external Postgres server to see if this will resolve the issue.

AstralInternet avatar Oct 27 '17 14:10 AstralInternet

I would also like to add that I've had the same exact problem with the AWS AMI setup. I have an another AWX Container setup on Ubuntu in AWS and postgres has not failed there. For the AWS AMI, I had to reinstall everything from scratch, as the only fix. As this was a POC, I do not plan to use an external Postgres, but would definitely consider it if using the AWS AMI.

ardeshir avatar Oct 28 '17 21:10 ardeshir

Also now having this issue, All AWX data lost, I assume having an external database is the only way to safely use AWX if this is an issue? Not sure how that is done though

mkempster22 avatar Nov 07 '17 11:11 mkempster22

I suspect you are probably running into this: https://github.com/ansible/awx/pull/535

Which had to be fixed in order to allow the containers to behave properly after restart.

As far as using an external postgres, it's all right there in the documentation:

https://github.com/ansible/awx/blob/devel/INSTALL.md#postgresql-1

matburt avatar Nov 07 '17 14:11 matburt

Unfortunately due to the errors in shown in the logs above the postgres container exits immediately after starting so running the commands in #535 gives: Error response from daemon: Container postgres is not running

Luckily this has only happened to my test server so i'm making sure my main ansible server doesn't get restarted.

I will try an external postgres to try solve that issue, Is there a plan to be able to run AWX away from docker altogether like tower does?

mkempster22 avatar Nov 07 '17 15:11 mkempster22

Nope

matburt avatar Nov 07 '17 16:11 matburt

Am facing same issue, Postgresql container is going into restart mode and not starting. How to setup, external postgrepsql for AWX tower? Please suggest

karthikm57 avatar Mar 27 '18 05:03 karthikm57

Double-check that you are opening ports on your server / VM configuration for PostgreSQL database; this just happened to me because docker capsules use their names as hostnames to communicate locally, but odoo app and postgreSQL are (technically) not aware of such compartementalization.

So after reboot for some unknown (yet) reason containers cannot resolve hostnames locally wich is solved by resorting to next level of IP communication they can reach: open postgreSQL ports on VM/NAT, firewall, etc. 5432 usually, 5431 or whatever your database may apply. You still have external Firewall protection, so technically this is only "local". Another fix is to have application startup delayed a good 12 seconds behind database startup if your reboots are a bit slow.

And that's why so many "Tech Guys" believe the solution to this is renting external database hosting. At that point they configure external database ports and problem is magically solved! XD

On docker capsule-level seems ok, but on application-level you must double-check your server ports, that's one disadvantage of compartamentalization, remember those containers are totally isolated.

qi-teq avatar Apr 11 '18 13:04 qi-teq

it is bit worrying ... it happened now 3 -4 times ... the AWX is working fine and suddenly postgres docker keep restarting .. did anyone figured out the root cause please ?

ssaammoo avatar Jan 03 '19 08:01 ssaammoo

@ssaammoo the only workaround that's working for me is to set postgres_data_dir property in installer/inventory file to force it from setting up in tmp.

rootameen avatar Jan 03 '19 22:01 rootameen

The fact that this defaults to a location in /tmp for local docker install makes it really prone to lose data. Is there a reason that this is the default value rather than something like "{ docker_compose_dir }}/postgresql"?

Would this be something that could be switched to a safer default value, or would a preferred way to help this issue be a documentation PR to help guide new adopters towards the setting explicitly?

dbowling avatar Jan 14 '19 22:01 dbowling