Skip to content

Commit

Permalink
Add check_instance_ready management command (#15238)
Browse files Browse the repository at this point in the history
- throw exception and return 1 if instance not ready
- return 0 if ready
  • Loading branch information
TheRealHaoLiu authored May 31, 2024
1 parent ceafa14 commit d0fe0ed
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions awx/main/management/commands/check_instance_ready.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d0fe0ed

Please sign in to comment.