amirshabanics opened a new issue, #41562:
URL: https://github.com/apache/airflow/issues/41562

   ### Apache Airflow Provider(s)
   
   cncf-kubernetes
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-cncf-kubernetes==8.3.1
   
   ### Apache Airflow version
   
   2.9.2
   
   ### Operating System
   
   Ubuntu 24.04 LTS
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   I want to create a SparkKubernetesOperator task. So I make a manifest and 
pass it from params. My manifest:
   
   ```yaml
   spark:
   # spark spec
   kubernetes:
     env_vars: []
   # other kubernetes spec
   ```
   
   If I don't set `env_vars`, it raises an error:
   ```
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.11/site-packages/airflow/models/taskinstance.py",
 line 465, in _execute_task
       result = _execute_callable(context=context, **execute_callable_kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.11/site-packages/airflow/models/taskinstance.py",
 line 432, in _execute_callable
       return execute_callable(context=context, **execute_callable_kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.11/site-packages/airflow/models/baseoperator.py",
 line 401, in wrapper
       return func(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.11/site-packages/airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py",
 line 283, in execute
       self.launcher = CustomObjectLauncher(
                       ^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.11/site-packages/airflow/providers/cncf/kubernetes/operators/custom_object_launcher.py",
 line 221, in __init__
       self.body: dict = self.get_body()
                         ^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.11/site-packages/airflow/providers/cncf/kubernetes/operators/custom_object_launcher.py",
 line 242, in get_body
       k8s_spec: dict = KubernetesSpec(**self.template_body["kubernetes"])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.11/site-packages/airflow/providers/cncf/kubernetes/operators/custom_object_launcher.py",
 line 84, in __init__
       self.set_attribute()
     File 
"/home/airflow/.local/lib/python3.11/site-packages/airflow/providers/cncf/kubernetes/operators/custom_object_launcher.py",
 line 87, in set_attribute
       self.env_vars = convert_env_vars(self.env_vars) if self.env_vars else []
                                                          ^^^^^^^^^^^^^
   AttributeError: 'KubernetesSpec' object has no attribute 'env_vars'
   ```
   
   It can be happened for all variables in `kubernetes` spec.
   
   ### What you think should happen instead
   
   This variable has a default value.
   
   ### How to reproduce
   
   Just remove the line that `env_vars` exists.
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to