示例#1
0
def handle_action_activity(body, logger, **_):
    action = AnarchyAction(body)
    if not action.has_owner:
        action.set_owner(runtime)
    elif not action.has_started:
        if action.after_datetime <= datetime.utcnow():
            action.start(runtime)
        else:
            AnarchyAction.cache_put(action)
示例#2
0
def handle_action_event(event, logger, **_):
    obj = event.get('object')
    if obj and obj.get('apiVersion') == runtime.api_group_version:
        if event['type'] == 'DELETED':
            AnarchyAction.cache_remove(obj['metadata']['name'])
        else:
            action = AnarchyAction(obj)
            if not action.has_owner:
                action.set_owner(runtime)
            elif not action.has_started:
                AnarchyAction.cache_put(action)
示例#3
0
def handle_action_event(event, **_):
    wait_for_init()
    try:
        action_cache_lock.acquire()
        action = AnarchyAction(event['object'])
        if event['type'] == 'DELETED':
            AnarchyAction.cache_remove(action)
        elif event['type'] in ['ADDED', 'MODIFIED', None]:
            if not action.has_started:
                AnarchyAction.cache_put(action)
        else:
            operator_logger.warning('Unknown event for AnarchyAction %s', event)
    finally:
        action_cache_lock.release()