mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
Add check_instance_ready management command (#15238)
- throw exception and return 1 if instance not ready - return 0 if ready
This commit is contained in:
parent
ceafa14c9d
commit
d0fe0ed796
12
awx/main/management/commands/check_instance_ready.py
Normal file
12
awx/main/management/commands/check_instance_ready.py
Normal file
@ -0,0 +1,12 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from awx.main.models.ha import Instance
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Check if the task manager instance is ready throw error if not ready, can be use as readiness probe for k8s.'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if Instance.objects.me().node_state != Instance.States.READY:
|
||||
raise CommandError('Instance is not ready') # so that return code is not 0
|
||||
|
||||
return
|
||||
Loading…
x
Reference in New Issue
Block a user