Skip to content

Commit

Permalink
Correctly fetch logs for mapped task instances (#22818)
Browse files Browse the repository at this point in the history
We weren't passing the map_index param down to the server

GitOrigin-RevId: 6f525e0a14e0da0992006b268865b58bad0959d2
  • Loading branch information
ashb authored and Cloud Composer Team committed Sep 12, 2024
1 parent ce8f917 commit dcf6284
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions airflow/www/static/js/ti_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { formatDateTime } from './datetime_utils';
const executionDate = getMetaValue('execution_date');
const dagId = getMetaValue('dag_id');
const taskId = getMetaValue('task_id');
const mapIndex = getMetaValue('map_index');
const logsWithMetadataUrl = getMetaValue('logs_with_metadata_url');
const DELAY = parseInt(getMetaValue('delay'), 10);
const AUTO_TAILING_OFFSET = parseInt(getMetaValue('auto_tailing_offset'), 10);
Expand Down Expand Up @@ -60,15 +61,17 @@ window.scrollBottomLogs = scrollBottom;

// Streaming log with auto-tailing.
function autoTailingLog(tryNumber, metadata = null, autoTailing = false) {
console.debug(`Auto-tailing log for dag_id: ${dagId}, task_id: ${taskId}, \
execution_date: ${executionDate}, try_number: ${tryNumber}, metadata: ${JSON.stringify(metadata)}`);
console.debug(`Auto-tailing log for dag_id: ${dagId}, task_id: ${taskId}, `
+ `execution_date: ${executionDate}, map_index: ${mapIndex}, try_number: ${tryNumber}, `
+ `metadata: ${JSON.stringify(metadata)}`);

return Promise.resolve(
$.ajax({
url: logsWithMetadataUrl,
data: {
dag_id: dagId,
task_id: taskId,
map_index: mapIndex,
execution_date: executionDate,
try_number: tryNumber,
metadata: JSON.stringify(metadata),
Expand Down
1 change: 1 addition & 0 deletions airflow/www/templates/airflow/ti_log.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{% block head_meta %}
{{ super() }}
<meta name="task_id" content="{{ task_id }}">
<meta name="map_index" content="{{ map_index }}">
<meta name="execution_date" content="{{ execution_date }}">
<meta name="logs_with_metadata_url" content="{{ url_for('Airflow.get_logs_with_metadata') }}">
{# Time interval to wait before next log fetching. Default 2s. #}
Expand Down

0 comments on commit dcf6284

Please sign in to comment.