jedcunningham commented on a change in pull request #15263: URL: https://github.com/apache/airflow/pull/15263#discussion_r609131008
########## File path: airflow/utils/event_scheduler.py ########## @@ -0,0 +1,42 @@ +# +# 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. + +import sched +from typing import Callable + + +class EventScheduler(sched.scheduler): Review comment: If we are happy with moving this into util, I'll add tests 👍 Also happy to entertain better names. ########## File path: airflow/executors/kubernetes_executor.py ########## @@ -589,6 +598,44 @@ def sync(self) -> None: break # pylint: enable=too-many-nested-blocks + # Run any pending timed events + next_event = self.event_scheduler.run(blocking=False) + self.log.debug("Next timed event is in %f", next_event) + + def _check_worker_pods_pending_timeout(self): + """Check if any pending worker pods have timed out""" + timeout = self.kube_config.worker_pods_pending_timeout + self.log.debug('Looking for pending worker pods older than %d seconds', timeout) + + kwargs = { + 'limit': self.kube_config.worker_pods_pending_timeout_batch_size, + 'field_selector': 'status.phase=Pending', + 'label_selector': f'airflow-worker={self.scheduler_job_id}', Review comment: I've limited it only pending pods from this scheduler, but it could easily be expanded to do any with `kubernetes_executor=True` instead (though, seems this could be a race between schedulers). -- 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. For queries about this service, please contact Infrastructure at: [email protected]
