You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fetching the driver logs using SparkKubernetesSensor fails when the driver pod has a sidecar #18468
I tried to run a simple Spark application using the SparkKubernetesOperator and SparkKubernetesSensor.
In the yaml file for the Spark Operator I added a sidecar container to the driver pod.
When the job runs in Airflow the SparkKubernetesSensor step will fail with the following error:
[2021-09-23 13:24:21,547] {spark_kubernetes.py:92} WARNING - Could not read logs for pod pyspark-pi-driver. It may have been disposed.
Make sure timeToLiveSeconds is set on your SparkApplication spec.
underlying exception: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'Date': 'Thu, 23 Sep 2021 13:24:21 GMT', 'Content-Length': '233'})
HTTP response body: b'{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"a container name must be specified for pod pyspark-pi-driver, choose one of: [spark-kubernetes-driver logging-sidecar]","reason":"BadRequest","code":400}\n'
In my yaml file I am not setting timeToLiveSeconds so the driver pod is still around at the end of the job execution, so there should be no issues fetching the logs.
I believe the error is due to the fact that in the call to get_pod_logs, from within SparkKubernetesSensor._log_driver, only the driver pod name is sent and not any container name. This syntax works fine if the driver container is alone in the pod, but it will throw an error if there are multiple containers inside the pod.
default_driver_container_name = "spark-kubernetes-driver"
# L88
for line in self.hook.get_pod_logs(driver_pod_name, namespace=namespace, container=self.default_driver_container_name):
Have made a simple MR over here, would some one be able to have a look? Thanks!
Activity
boring-cyborg commentedon Sep 23, 2021
Thanks for opening your first issue here! Be sure to follow the issue template!
mik-laj commentedon Sep 23, 2021
CC: @roitvt
potiuk commentedon Sep 25, 2021
@cristian-fatu - maybe you would like to stab on it and fix it?
billstark commentedon Sep 28, 2021
I think for this problem we can do something like
Have made a simple MR over here, would some one be able to have a look? Thanks!
hanna-liashchuk commentedon Oct 2, 2022
Hi, i've met this issue too and have prepared a PR here
Could please someone take a look? Thanks!