Skip to content
Open
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
1 change: 1 addition & 0 deletions airflow-ctl/RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Significant Changes
Bug Fixes
^^^^^^^^^

- Fix ``airflowctl backfill pause``, ``unpause``, and ``cancel`` API methods
- Declare ``pyyaml`` as a runtime dependency so ``airflowctl`` starts without crashing on ``ModuleNotFoundError``
- Prevent path traversal via AIRFLOW_CLI_ENVIRONMENT in airflowctl (#64618)
- Fix ``is_alive`` default in ``airflowctl jobs list`` to show all jobs (#65065)
Expand Down
6 changes: 3 additions & 3 deletions airflow-ctl/src/airflowctl/api/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,23 +386,23 @@ def list(self, dag_id: str) -> BackfillCollectionResponse | ServerResponseError:
def pause(self, backfill_id: str) -> BackfillResponse | ServerResponseError:
"""Pause a backfill."""
try:
self.response = self.client.post(f"backfills/{backfill_id}/pause")
self.response = self.client.put(f"backfills/{backfill_id}/pause")
return BackfillResponse.model_validate_json(self.response.content)
except ServerResponseError as e:
raise e

def unpause(self, backfill_id: str) -> BackfillResponse | ServerResponseError:
"""Unpause a backfill."""
try:
self.response = self.client.post(f"backfills/{backfill_id}/unpause")
self.response = self.client.put(f"backfills/{backfill_id}/unpause")
return BackfillResponse.model_validate_json(self.response.content)
except ServerResponseError as e:
raise e

def cancel(self, backfill_id: str) -> BackfillResponse | ServerResponseError:
"""Cancel a backfill."""
try:
self.response = self.client.post(f"backfills/{backfill_id}/cancel")
self.response = self.client.put(f"backfills/{backfill_id}/cancel")
return BackfillResponse.model_validate_json(self.response.content)
except ServerResponseError as e:
raise e
Expand Down
7 changes: 7 additions & 0 deletions airflow-ctl/tests/airflow_ctl/api/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ def test_create(self):
expected_body = self.backfill_body.model_dump(mode="json", exclude_none=True)

def handle_request(request: httpx.Request) -> httpx.Response:
assert request.method == "POST"
assert request.url.path == "/api/v2/backfills"
assert request.headers.get("content-type", "").startswith("application/json")
assert json.loads(request.content.decode()) == expected_body
Expand All @@ -479,6 +480,7 @@ def test_create_dry_run(self):
expected_body = self.backfill_body.model_dump(mode="json", exclude_none=True)

def handle_request(request: httpx.Request) -> httpx.Response:
assert request.method == "POST"
assert request.url.path == "/api/v2/backfills/dry_run"
assert request.headers.get("content-type", "").startswith("application/json")
assert json.loads(request.content.decode()) == expected_body
Expand All @@ -490,6 +492,7 @@ def handle_request(request: httpx.Request) -> httpx.Response:

def test_get(self):
def handle_request(request: httpx.Request) -> httpx.Response:
assert request.method == "GET"
assert request.url.path == f"/api/v2/backfills/{self.backfill_id}"
return httpx.Response(200, json=json.loads(self.backfill_response.model_dump_json()))

Expand All @@ -499,6 +502,7 @@ def handle_request(request: httpx.Request) -> httpx.Response:

def test_list(self):
def handle_request(request: httpx.Request) -> httpx.Response:
assert request.method == "GET"
assert request.url.path == "/api/v2/backfills"
return httpx.Response(200, json=json.loads(self.backfills_collection_response.model_dump_json()))

Expand All @@ -508,6 +512,7 @@ def handle_request(request: httpx.Request) -> httpx.Response:

def test_pause(self):
def handle_request(request: httpx.Request) -> httpx.Response:
assert request.method == "PUT"
assert request.url.path == f"/api/v2/backfills/{self.backfill_id}/pause"
return httpx.Response(200, json=json.loads(self.backfill_response.model_dump_json()))

Expand All @@ -517,6 +522,7 @@ def handle_request(request: httpx.Request) -> httpx.Response:

def test_unpause(self):
def handle_request(request: httpx.Request) -> httpx.Response:
assert request.method == "PUT"
assert request.url.path == f"/api/v2/backfills/{self.backfill_id}/unpause"
return httpx.Response(200, json=json.loads(self.backfill_response.model_dump_json()))

Expand All @@ -526,6 +532,7 @@ def handle_request(request: httpx.Request) -> httpx.Response:

def test_cancel(self):
def handle_request(request: httpx.Request) -> httpx.Response:
assert request.method == "PUT"
assert request.url.path == f"/api/v2/backfills/{self.backfill_id}/cancel"
return httpx.Response(200, json=json.loads(self.backfill_response.model_dump_json()))

Expand Down
Loading