Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion providers/edge3/src/airflow/providers/edge3/cli/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ async def start(self):
logger.error(str(e))
raise SystemExit(str(e))
except ClientResponseError as e:
if e.status == HTTPStatus.NOT_FOUND:
# Note: Method not allowed is raised by FastAPI if the API is not enabled (not 404)
if e.status in {HTTPStatus.NOT_FOUND, HTTPStatus.METHOD_NOT_ALLOWED}:
raise SystemExit(
"Error: API endpoint is not ready, please set [edge] api_enabled=True. Or check if the URL is correct to your deployment."
)
Expand Down
15 changes: 12 additions & 3 deletions providers/edge3/tests/unit/edge3/cli/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,21 @@ async def test_version_mismatch(self, mock_set_state, worker_with_job):
await worker_with_job.heartbeat()
assert worker_with_job.drain

@pytest.mark.parametrize(
"http_error",
[
pytest.param(404, id="HTTP 404 Not Found"),
pytest.param(405, id="HTTP 405 Method Not Allowed"),
],
)
@patch("airflow.providers.edge3.cli.worker.worker_register")
async def test_start_missing_apiserver(self, mock_register_worker, worker_with_job: EdgeWorker):
async def test_start_missing_apiserver(
self, mock_register_worker, http_error, worker_with_job: EdgeWorker
):
mock_register_worker.side_effect = ClientResponseError(
request_info=RequestInfo(url=URL("mock.com"), method="GET", headers=None), # type:ignore[arg-type]
message="Something with 404:NOT FOUND means API is not active",
status=404,
message=f"Something with {http_error}: Means API is not active",
status=http_error,
history=(),
)
with pytest.raises(SystemExit, match=r"API endpoint is not ready"):
Expand Down