This is an automated email from the ASF dual-hosted git repository.
dstandish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new f4be70aa74 No multiline log entry for bash env vars (#28881)
f4be70aa74 is described below
commit f4be70aa74885671d16557795f694ada98769caa
Author: Daniel Standish <[email protected]>
AuthorDate: Fri Jan 13 21:53:03 2023 -0800
No multiline log entry for bash env vars (#28881)
Most of the time you don't care what they are. If you need to inspect them,
you can copy to text editor for better viewing. Makes log more readable
overall.
---
airflow/models/taskinstance.py | 4 ++--
airflow/operators/bash.py | 4 ++--
airflow/www/static/js/dag/details/taskInstance/Logs/index.test.tsx | 4 +---
airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx | 4 +---
tests/cli/commands/test_task_command.py | 6 +++---
5 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index fe382155ec..e8d9fe8cee 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -1515,8 +1515,8 @@ class TaskInstance(Base, LoggingMixin):
# case there's no need to log these again).
if not self.next_method:
self.log.info(
- "Exporting the following env vars:\n%s",
- "\n".join(f"{k}={v}" for k, v in
airflow_context_vars.items()),
+ "Exporting env vars: %s",
+ " ".join(f"{k}={v!r}" for k, v in
airflow_context_vars.items()),
)
# Run pre_execute callback
diff --git a/airflow/operators/bash.py b/airflow/operators/bash.py
index 24a66a167b..8450b1802d 100644
--- a/airflow/operators/bash.py
+++ b/airflow/operators/bash.py
@@ -170,8 +170,8 @@ class BashOperator(BaseOperator):
airflow_context_vars = context_to_airflow_vars(context,
in_env_var_format=True)
self.log.debug(
- "Exporting the following env vars:\n%s",
- "\n".join(f"{k}={v}" for k, v in airflow_context_vars.items()),
+ "Exporting env vars: %s",
+ " ".join(f"{k}={v!r}" for k, v in airflow_context_vars.items()),
)
env.update(airflow_context_vars)
return env
diff --git a/airflow/www/static/js/dag/details/taskInstance/Logs/index.test.tsx
b/airflow/www/static/js/dag/details/taskInstance/Logs/index.test.tsx
index 7a94fd64fc..10d1c48863 100644
--- a/airflow/www/static/js/dag/details/taskInstance/Logs/index.test.tsx
+++ b/airflow/www/static/js/dag/details/taskInstance/Logs/index.test.tsx
@@ -44,9 +44,7 @@ const mockTaskLog = `
[2022-06-04 00:00:01,921] {standard_task_runner.py:81} INFO - Job 1626:
Subtask section_1.get_entry_group
[2022-06-04 00:00:01,921] {dagbag.py:507} INFO - Filling up the DagBag from
/files/dags/test_ui_grid.py
[2022-06-04 00:00:01,964] {task_command.py:377} INFO - Running <TaskInstance:
test_ui_grid.section_1.get_entry_group scheduled__2022-06-03T00:00:00+00:00
[running]> on host 5d28cfda3219
-[2022-06-04 00:00:02,010] {taskinstance.py:1548} WARNING - Exporting the
following env vars:
-AIRFLOW_CTX_DAG_OWNER=***
-AIRFLOW_CTX_DAG_ID=test_ui_grid
+[2022-06-04 00:00:02,010] {taskinstance.py:1548} WARNING - Exporting env vars:
AIRFLOW_CTX_DAG_OWNER=*** AIRFLOW_CTX_DAG_ID=test_ui_grid
`;
let useTaskLogMock: jest.SpyInstance;
diff --git a/airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx
b/airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx
index d47e5992eb..c822f5ee2e 100644
--- a/airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx
+++ b/airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx
@@ -37,9 +37,7 @@ const mockTaskLog = `
[2022-06-04 00:00:01,921] {standard_task_runner.py:81} INFO - Job 1626:
Subtask section_1.get_entry_group
[2022-06-04 00:00:01,921] {dagbag.py:507} INFO - Filling up the DagBag from
/files/dags/test_ui_grid.py
[2022-06-04 00:00:01,964] {task_command.py:377} INFO - Running <TaskInstance:
test_ui_grid.section_1.get_entry_group scheduled__2022-06-03T00:00:00+00:00
[running]> on host 5d28cfda3219
-[2022-06-04 00:00:02,010] {taskinstance.py:1548} WARNING - Exporting the
following env vars:
-AIRFLOW_CTX_DAG_OWNER=***
-AIRFLOW_CTX_DAG_ID=test_ui_grid
+[2022-06-04 00:00:02,010] {taskinstance.py:1548} WARNING - Exporting env vars:
AIRFLOW_CTX_DAG_OWNER=*** AIRFLOW_CTX_DAG_ID=test_ui_grid
`;
describe('Test Logs Utils.', () => {
diff --git a/tests/cli/commands/test_task_command.py
b/tests/cli/commands/test_task_command.py
index 180e012e49..7e10ad21a1 100644
--- a/tests/cli/commands/test_task_command.py
+++ b/tests/cli/commands/test_task_command.py
@@ -694,10 +694,10 @@ class TestLogsfromTaskRunCommand:
if found_start:
lines.append(line)
if is_k8s:
- # 20 is arbitrary, but, with enough padding to hopefully not be
flakey
- assert len(lines) > 20
+ # 10 is arbitrary, but, with enough padding to hopefully not be
flakey
+ assert len(lines) > 10
self.assert_log_line("Starting attempt 1 of 1", lines)
- self.assert_log_line("Exporting the following env vars", lines)
+ self.assert_log_line("Exporting env vars", lines)
self.assert_log_line("Log from DAG Logger", lines)
self.assert_log_line("Log from TI Logger", lines)
self.assert_log_line("Log from Print statement", lines,
expect_from_logging_mixin=True)