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:
Hao Liu 2024-05-31 09:29:40 -04:00 committed by GitHub
parent ceafa14c9d
commit d0fe0ed796
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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