Skip to content

SparkKubernetesSensor Cannot Attach Log When There Are Sidecars in the Driver Pod #23114

@joshuayeung

Description

@joshuayeung

Apache Airflow Provider(s)

cncf-kubernetes

Versions of Apache Airflow Providers

apache-airflow-providers-cncf-kubernetes==3.0.0

Apache Airflow version

2.2.5 (latest released)

Operating System

Debian GNU/Linux 10 (buster)

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

What happened

When using SparkKubernetesSensor with attach_log=True, it cannot get the log correctly with the below error:

 Make sure timeToLiveSeconds is set on your SparkApplication spec.
 underlying exception: (400)
 Reason: Bad Request
 HTTP response headers: HTTPHeaderDict({'Audit-Id': '29ac5abb-452d-4411-a420-8d74155e187d', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'Date': 'Wed, 20 Apr 2022 08:42:04 GMT', 'Content-Length': '259'})
 HTTP response body: b'{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"a container name must be specified for pod spark-pi-0.4753748373914717-1-driver, choose one of: [istio-init istio-proxy spark-kubernetes-driver]","reason":"BadRequest","code":400}\n'

It is because no container is specified when calling kubernetes hook.get_pod_logs

for line in self.hook.get_pod_logs(driver_pod_name, namespace=namespace):

What you think should happen instead

It should get the log of container spark-kubernetes-driver

How to reproduce

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions