예제 #1
0
def init_runners():
    """Get initial list of AnarchyRunners"""
    for resource in runtime.custom_objects_api.list_namespaced_custom_object(
        runtime.operator_domain, 'v1', runtime.operator_namespace, 'anarchyrunners'
    ).get('items', []):
        runner = AnarchyRunner.register(resource)
    AnarchyRunner.refresh_all_runner_pods(runtime)
예제 #2
0
def main_loop():
    last_runner_check = 0
    while True:
        try:
            action_cache_lock.acquire()
            AnarchyAction.start_actions(runtime)
        except Exception as e:
            operator_logger.exception("Error in start_actions!")
        finally:
            action_cache_lock.release()

        try:
            AnarchySubject.retry_failures(runtime)
        except Exception as e:
            operator_logger.exception("Error in retry_failures!")

        if runner_check_interval < time.time() - last_runner_check:
            try:
                AnarchyRunner.refresh_all_runner_pods(runtime)
                last_runner_check = time.time()
            except:
                operator_logger.exception(
                    'Error checking runner pods in main loop')

        time.sleep(1)