Repository navigation
Closed
Labels
Description
ISSUE TYPE
- Bug Report
SUMMARY
Node can't join to cluster after lost network connection to a postgres database.
ENVIRONMENT
- AWX version: 3.0.1
But bug still preset at 6.0.0
STEPS TO REPRODUCE
- Setup HA AWX cluster with 3+ nodes and external Postgres database
- Shutdown network on one of nodes and wait 120 sec(
grace_period) - Look at work nodes log, you will see, that node without network was removed from cluster:
Jul 4 17:16:59 1.awx.node.dc2 dispatcher[207]: 2019-07-04 14:16:59,220 INFO awx.main.tasks Host 1.awx.node.dc1 Automatically Deprovisioned.
And from postgres database:
awx=> SELECT id FROM main_instance;
id
-----
543
550
(2 rows)
- Fix network on node and look at it logs:
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: 2019-07-04 14:20:39,433 ERROR awx.main.dispatch failed to write inbound message
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: Traceback (most recent call last):
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/dispatch/pool.py", line 388, in write
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: self.cleanup()
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/dispatch/pool.py", line 373, in cleanup
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: reaper.reap(excluded_uuids=running_uuids)
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/dispatch/reaper.py", line 35, in reap
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: me = instance or Instance.objects.me()
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/managers.py", line 88, in me
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: raise RuntimeError("No instance found with the current cluster host id")
Jul 4 17:20:39 1.awx.node.dc1 dispatcher[505]: RuntimeError: No instance found with the current cluster host id
EXPECTED RESULTS
After restoring network connection to the database, node successfully rejoins to cluster.
ACTUAL RESULTS
Node never rejoin to cluster without instance restarting
ADDITIONAL INFORMATION
Node can't return to cluster, because it calls function cleanup from pool.py on each heartbeat.
cleanup calls reaper.reap() and it fails, because can't get instance id(awx delete node from database at reproduce step 3):
me = instance or Instance.objects.me()
I created a pull request, with probably fix: #4268
Reacted by Dmitry Samsonov
Activity
YuriGrigorov commentedon Jul 9, 2019
The problem of
reapis that the function wants the working instance.awx/awx/main/dispatch/reaper.py
Lines 32 to 36 in 2aa32f6
But there may be cases when the instance, for some reason, is automatically deprovisioned. If that happens then the instance can't be provisioned back.
I found two places where
reapbreaks automatic node provisioning.awx/awx/main/dispatch/pool.py
Line 377 in 2aa32f6
We don't need to call
cleanupif instance is not in cluster.awx/awx/main/dispatch/pool.py
Lines 390 to 392 in 2aa32f6
The second place where
reapmay be called when instance is not in cluster (in case of automatic deprovisioning) is here:awx/awx/main/management/commands/run_dispatcher.py
Line 123 in 2aa32f6
so if you try to restart dispatcher it will not start.
megakoresh commentedon Jul 17, 2019
@byumov This is happening to me on a single-node setup as well:
Task container logs are full of this. And while I can navigate the UI, I cannot run any jobs.
bjmingyang commentedon Jul 26, 2019
@megakoresh Root cause is while doing a backup on a Tower instance, it is not excluding rabbitmq.py and hence while doing a restore on a different Ansible Tower instance it restores the original rabbitmq.py, which breaks the rabbitmq clustering.
use this command fix it
sudo -u awx scl enable rh-python36 rh-postgresql10 "awx-manage create_preload_data"
sudo -u awx scl enable rh-python36 rh-postgresql10 "awx-manage provision_instance --hostname=$(hostname)"
sudo -u awx scl enable rh-python36 rh-postgresql10 "awx-manage register_queue --queuename=tower --hostnames=$(hostname)"
systemctl restart awx-cbreceiver
systemctl restart awx-dispatcher
systemctl restart awx-channels-worker
systemctl restart awx-daphne
systemctl restart awx-web
megakoresh commentedon Jul 26, 2019
@bjmingyang Root cause is hardcoded hostnames in configuration files, namely
settings.py. Changingawx_task_hostnameinventory variable changes service discovery hostname, while settings still refer toawx. This breaks the installation. And any solution that involves poking around in a running container is not a solution at all. This must be fixed properly.tamirshaul commentedon Sep 17, 2019
I'm having the same problem on awx 6.1.0.
Running on Openshift, I need to restart pods in my awx cluster frequently because they can't rejoin the cluster themselves.
work around an esoteric bug re: the task reaper and k8s auto-deprovision
ryanpetrello commentedon Sep 27, 2019
At its core, this issue can be condensed down to a very simple reproduction:
Instancefrom the database (Instance.objects.first().delete()).The practical scenario where you'll see this (as described in this issue) is in a k8s/OpenShift deployment with multiple pods (in this environment,
settings.AWX_AUTO_DEPROVISION_INSTANCES = True). When a node goes missing (for any number of reasons) for (by default) 120s, the record for that node is removed from themain_instancestable:https://github.com/ansible/awx/blob/devel/awx/main/tasks.py#L444
At a later point in time, when its connectivity is restored, the dispatcher is still running, and so we see the
RuntimeError: No instance found with the current cluster host iderror. The appropriate change here would be to update the periodic cleanup/reaping process to detect a missing instance record and automatically re-perform auto-registration.grahamneville commentedon Sep 27, 2019
Thanks for fixing this @ryanpetrello, we've been running in to this a lot on our kubernetes cluster.
Any chance of baking and publishing a new awx image once your PR gets merged please?
ryanpetrello commentedon Sep 27, 2019
👋 @grahamneville thank @byumov, he figured out what was up and contributed the fix.
We have a few features landing in AWX soon, and we intend to cut a new release at some point after that (which will include this fix).
Merge pull request ansible#4294 from ansible/i18n_release_3.7.0_trans…
AlanCoding commentedon Jun 29, 2022
The specific traceback given here should have been fixed with #11955