def run_loop( run_once, include_resources, exclude_resources, include_namespaces, exclude_namespaces, rules, interval, delete_notification, deployment_time_annotation: Optional[str], resource_context_hook: Optional[Callable], dry_run: bool, ): handler = shutdown.GracefulShutdown() while True: try: api = get_kube_api() clean_up( api, include_resources=frozenset(include_resources.split(",")), exclude_resources=frozenset(exclude_resources.split(",")), include_namespaces=frozenset(include_namespaces.split(",")), exclude_namespaces=frozenset(exclude_namespaces.split(",")), rules=rules, delete_notification=delete_notification, deployment_time_annotation=deployment_time_annotation, resource_context_hook=resource_context_hook, dry_run=dry_run, ) except Exception as e: logger.exception("Failed to clean up: %s", e) if run_once or handler.shutdown_now: return with handler.safe_exit(): time.sleep(interval)
def run_loop(run_once, include_resources, exclude_resources, include_namespaces, exclude_namespaces, rules, interval, dry_run): handler = shutdown.GracefulShutdown() while True: try: api = get_kube_api() clean_up( api, include_resources=frozenset(include_resources.split(',')), exclude_resources=frozenset(exclude_resources.split(',')), include_namespaces=frozenset(include_namespaces.split(',')), exclude_namespaces=frozenset(exclude_namespaces.split(',')), rules=rules, dry_run=dry_run) except Exception as e: logger.exception('Failed to clean up: %s', e) if run_once or handler.shutdown_now: return with handler.safe_exit(): time.sleep(interval)