This is an automated email from the ASF dual-hosted git repository.
kaxilnaik 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 7808be7 Make Kubernetes job description fit on one log line (#18377)
7808be7 is described below
commit 7808be7ffb693de2e4ea73d0c1e6e2470cde9095
Author: Collin McNulty <[email protected]>
AuthorDate: Tue Sep 21 15:19:40 2021 -0500
Make Kubernetes job description fit on one log line (#18377)
Currently, when the Kubernetes executor creates a pod it prints a
dictionary description of the pod across many lines (can easily be 20+ lines).
This is fine if you're reading the log in a stream in a text file, but throws
off log search tools like Kibana. A better practice would be to print the whole
pod description on a single line. It is quite easy to prettify a dictionary if
one wants to see it back in a more human-friendly form with the newlines.
This update simply forces the log from this command into a single line.
---
airflow/executors/kubernetes_executor.py | 2 +-
airflow/providers/cncf/kubernetes/utils/pod_launcher.py | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/airflow/executors/kubernetes_executor.py
b/airflow/executors/kubernetes_executor.py
index 8caf3ba..6ab91a0 100644
--- a/airflow/executors/kubernetes_executor.py
+++ b/airflow/executors/kubernetes_executor.py
@@ -294,7 +294,7 @@ class AirflowKubernetesScheduler(LoggingMixin):
and store relevant info in the current_jobs map so we can track the
job's
status
"""
- self.log.info('Kubernetes job is %s', str(next_job))
+ self.log.info('Kubernetes job is %s', str(next_job).replace("\n", " "))
key, command, kube_executor_config, pod_template_file = next_job
dag_id, task_id, run_id, try_number = key
diff --git a/airflow/providers/cncf/kubernetes/utils/pod_launcher.py
b/airflow/providers/cncf/kubernetes/utils/pod_launcher.py
index 36c68b1..43bb513 100644
--- a/airflow/providers/cncf/kubernetes/utils/pod_launcher.py
+++ b/airflow/providers/cncf/kubernetes/utils/pod_launcher.py
@@ -92,7 +92,9 @@ class PodLauncher(LoggingMixin):
)
self.log.debug('Pod Creation Response: %s', resp)
except Exception as e:
- self.log.exception('Exception when attempting to create Namespaced
Pod: %s', json_pod)
+ self.log.exception(
+ 'Exception when attempting to create Namespaced Pod: %s',
str(json_pod).replace("\n", " ")
+ )
raise e
return resp