Ejemplo n.º 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)
Ejemplo n.º 2
0
def handle_runner_event(event, **_):
    if event['type'] == 'DELETED':
        AnarchyRunner.unregister(event['object']['metadata']['name'])
    elif event['type'] in ['ADDED', 'MODIFIED', None]:
        runner = AnarchyRunner.register(event['object'])
        runner.manage_runner_deployment(runtime)
        runner.refresh_runner_pods(runtime)
Ejemplo n.º 3
0
def start_runner_process():
    '''
    Start anarchy-runner process for running in all-in-one pod.
    '''
    operator_logger.info('Starting all-in-one runner')
    default_runner = AnarchyRunner.get('default')
    if not default_runner:
        default_runner = AnarchyRunner.register(AnarchyRunner.default_runner_definition(runtime))
    env = os.environ.copy()
    env['ANARCHY_COMPONENT'] = 'runner'
    env['ANARCHY_URL'] = 'http://{}:5000'.format(runtime.anarchy_service_name)
    env['RUNNER_NAME'] = 'default'
    env['RUNNER_TOKEN'] = default_runner.runner_token
    subprocess.Popen(['/opt/app-root/src/.s2i/bin/run'], env=env)