def run_until_number_tasks(context, number): for _ in xrange(20): run_setup_marathon_job(context) sleep(0.5) if marathon_tools.app_has_tasks(context.marathon_client, context.app_id, number, exact_matches_only=True): return assert marathon_tools.app_has_tasks(context.marathon_client, context.app_id, number, exact_matches_only=True)
def wait_for_app_to_launch_tasks(client, app_id, expected_tasks, exact_matches_only=False): """ Wait for an app to have num_tasks tasks launched. If the app isn't found, then this will swallow the exception and retry. Times out after 30 seconds. :param client: The marathon client :param app_id: The app id to which the tasks belong :param expected_tasks: The number of tasks to wait for :param exact_matches_only: a boolean indicating whether we require exactly expected_tasks to be running """ found = False with requests_cache.disabled(): while not found: try: found = app_has_tasks(client, app_id, expected_tasks, exact_matches_only) except NotFoundError: pass if found: time.sleep(3) # Give it a bit more time to actually launch return else: paasta_print("waiting for app %s to have %d tasks. retrying" % (app_id, expected_tasks)) time.sleep(0.5)
def run_until_number_tasks(context, number): for _ in xrange(20): if marathon_tools.app_has_tasks(context.marathon_client, context.app_id, number, exact_matches_only=True): return else: sleep(0.5) create_complete_app(context)