vincbeck commented on code in PR #35412:
URL: https://github.com/apache/airflow/pull/35412#discussion_r1382014839
##########
airflow/providers/amazon/aws/executors/ecs/__init__.py:
##########
@@ -94,11 +97,67 @@ def __init__(self, *args, **kwargs):
fallback=CONFIG_DEFAULTS[AllEcsConfigKeys.AWS_CONN_ID],
)
region_name = conf.get(CONFIG_GROUP_NAME, AllEcsConfigKeys.REGION_NAME)
+
from airflow.providers.amazon.aws.hooks.ecs import EcsHook
self.ecs = EcsHook(aws_conn_id=aws_conn_id,
region_name=region_name).conn
+
self.run_task_kwargs = self._load_run_kwargs()
+ def start(self):
+ """
+ Make a test API call to check the health of the ECS Executor.
+
+ Deliberately use an invalid taskID, some potential outcomes in order:
+ 1. "AccessDeniedException" is raised if there are insufficient
permissions.
+ 2. "ClusterNotFoundException" is raised if permissions exist but the
cluster does not.
+ 3. The API responds with a failure message if the cluster is found
and there
+ are permissions, but the cluster itself has issues.
+ 4. "InvalidParameterException" is raised if the permissions and
cluster exist but the task does not.
+
+ The last one is considered a success state for the purposes of this
check.
+ """
+ check_health = conf.getboolean(
+ CONFIG_GROUP_NAME, AllEcsConfigKeys.CHECK_HEALTH_ON_STARTUP,
fallback=False
+ )
+
+ if not check_health:
+ return
+
+ self.log.info("Starting ECS Executor and determining health...")
+
+ success_status = "succeeded."
+ status = success_status
+
+ try:
+ invalid_task_id = "a" * 32
+ self.ecs.stop_task(cluster=self.cluster, task=invalid_task_id)
+
+ # If it got this far, something is wrong. stop_task() called with
an
+ # invalid taskID should have thrown a ClientError. All known
reasons are
+ # covered in the ``except`` block below, and this should never be
reached.
+ status = "failed for an unknown reason."
Review Comment:
Super mini tiny micro nit:
```suggestion
status = "failed for an unknown reason. "
```
--
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]