Skip to content
Closed
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
26 changes: 14 additions & 12 deletions airflow/models/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2044,38 +2044,40 @@ def generate_command(

@property
def log_url(self) -> str:
"""Log URL for TaskInstance."""
"""Log URL for TaskInstance in Airflow 3."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should specify the version since the main branch is already v3

run_id = quote(self.run_id)
base_url = conf.get_mandatory_value("webserver", "BASE_URL")
map_index = f"&map_index={self.map_index}" if self.map_index >= 0 else ""

_log_uri = (
f"{base_url}"
f"/dags"
f"/{self.dag_id}"
f"/grid"
f"/dags/{self.dag_id}"
f"/taskInstances/{self.task_id}"
f"/logs"
f"?dag_run_id={run_id}"
f"&task_id={self.task_id}"
f"{map_index}"
"&tab=logs"
)

if self.logical_date:
base_date = quote(self.logical_date.strftime("%Y-%m-%dT%H:%M:%S%z"))
_log_uri = f"{_log_uri}&base_date={base_date}"

return _log_uri

@property
def mark_success_url(self) -> str:
"""URL to mark TI success."""
"""URL to mark TaskInstance success in Airflow 3."""
base_url = conf.get_mandatory_value("webserver", "BASE_URL")

return (
f"{base_url}"
"/confirm"
f"?task_id={self.task_id}"
f"&dag_id={self.dag_id}"
f"&dag_run_id={quote(self.run_id)}"
f"/dags/{self.dag_id}"
f"/dagRuns/{quote(self.run_id)}"
f"/taskInstances/{self.task_id}"
f"/setState"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think setState is a valid URL. Please test the generated URLs to be working in the frontend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me check again

"?state=success"
"&upstream=false"
"&downstream=false"
"&state=success"
)

@provide_session
Expand Down