Add airflowctl tasks logs command for retrieving task instance logs - #71763
Open
BobSong-dev wants to merge 1 commit into
Open
Add airflowctl tasks logs command for retrieving task instance logs#71763BobSong-dev wants to merge 1 commit into
BobSong-dev wants to merge 1 commit into
Conversation
Without direct DB or webserver access, operators can list failed task instances, check their state and clear them for retry, but retrieving the logs needed to diagnose the failure still forced a fallback to the webserver UI or a hand-rolled REST client. This closes that gap by fetching task instance logs for a given try through the existing /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/logs/{try_number} endpoint, defaulting to the latest attempt.
BobSong-dev
requested review from
amoghrajesh,
ashb,
bugraoz93,
dheerajturaga,
gopidesupavan,
henry3260,
jason810496 and
potiuk
as code owners
August 18, 2026 10:23
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add the
airflowctl tasks logscommand to fetch a task instance's logs for a given try through the existing REST endpoint.Changes
TaskInstancesOperations.logs()callingGET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/logs/{try_number}.tasks logscommand:airflowctl tasks logs DAG_ID DAG_RUN_ID TASK_ID [--map-index N] [--try-number N];--try-numberdefaults to the latest attempt, matching the webserver UI.--dag-id/--dag-run-id/--task-idflag form was dropped to comply with that convention.externalLogUrlhandling is left for a follow-up.Testing
Added unit tests covering the command: default latest attempt, explicit try number and map index, structured and plain-text log output, 404 handling, and non-404 error propagation. All 35 tests in
test_task_command.pypass. Addedtasks logslines to the integration test command list.ruff formatandruff checkpass on all changed files.closes: #69947
Was generative AI tooling used to co-author this PR?
Generated-by: DeepSeek V4 Pro following the guidelines,I also conducted local testing, and no issues were found.
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.