def handle_subject_create(body, **_): try: subject = AnarchySubject(body) subject.handle_create(runtime) except AssertionError as e: operator_logger.warning('AnarchySubject %s invalid: %s', body['metadata']['name'], e)
def handle_subject_update(body, old, new, **_): try: subject = AnarchySubject(body) if old['spec'] != new['spec']: subject.handle_spec_update(runtime) except AssertionError as e: operator_logger.warning('AnarchySubject %s invalid: %s', body['metadata']['name'], e)
def handle_subject_event(event, logger, **_): ''' Anarchy uses on.event instead of on.delete because Anarchy needs custom for removing finalizers. The finalizer will be removed immediately if the AnarchyGovernor does not have a delete subject event handler. If there is a delete subject event handler then it is up to the governor logic to remove the finalizer. ''' obj = event.get('object') if obj and obj.get('apiVersion') == runtime.api_group_version: if event['type'] in ['ADDED', 'MODIFIED', None]: subject = AnarchySubject(obj) if subject.is_pending_delete: subject.handle_delete(runtime)
def handle_subject_timer(body, **_): subject = AnarchySubject(body) subject.set_active_run_to_pending_from_status(runtime)