o-nikolas commented on code in PR #30727: URL: https://github.com/apache/airflow/pull/30727#discussion_r1181957211
########## airflow/executors/kubernetes_executor_utils.py: ########## @@ -0,0 +1,466 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +import json +import multiprocessing +import time +from queue import Empty, Queue +from typing import TYPE_CHECKING, Any + +from kubernetes import client, watch +from kubernetes.client import Configuration, models as k8s +from kubernetes.client.rest import ApiException +from urllib3.exceptions import ReadTimeoutError + +from airflow.exceptions import AirflowException +from airflow.kubernetes.kube_client import get_kube_client +from airflow.kubernetes.kubernetes_helper_functions import annotations_to_key, create_pod_id +from airflow.kubernetes.pod_generator import PodGenerator +from airflow.utils.log.logging_mixin import LoggingMixin +from airflow.utils.state import State + +if TYPE_CHECKING: + from airflow.executors.kubernetes_executor_types import ( + KubernetesJobType, + KubernetesResultsType, + KubernetesWatchType, + ) + + +from airflow.executors.kubernetes_executor_types import ALL_NAMESPACES, POD_EXECUTOR_DONE_KEY + + +class ResourceVersion: + """Singleton for tracking resourceVersion from Kubernetes.""" + + _instance: ResourceVersion | None = None + resource_version: dict[str, str] = {} + + def __new__(cls): + if cls._instance is None: + cls._instance = super().__new__(cls) + return cls._instance + + +class KubernetesJobWatcher(multiprocessing.Process, LoggingMixin): Review Comment: That to me felt a bit invasive, especially since executors are public-ish (people modify them with plugins or base new executors off of them). We plan to move the executors to their own provider packages very soon so module names/locations will all be shuffled then. Can we agree to defer this piece of feedback until that time? I've already gotten feedback that this PR is too large, so if I could keep the two decoupled that'd be awesome! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
