kimyen opened a new pull request #18272:
URL: https://github.com/apache/airflow/pull/18272


   Problem:
   
   Clear and Run task instance via UI cause mushroom cloud error.
   
   Repro steps:
   - Using Helm 1.1.0 to deploy Airflow 1.10.15
   - From the UI, navigate to a DAG tree view
   - Select an existing task (small square on tree view) > Clear > Run
   
   Error:
   ```
   
-------------------------------------------------------------------------------
   Node: airflow-webserver-67bf9669bc-x6wcc
   
-------------------------------------------------------------------------------
   Traceback (most recent call last):
     File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in 
wsgi_app
       response = self.full_dispatch_request()
     ...
     File "/usr/local/lib/python3.7/site-packages/airflow/www/views.py", line 
1196, in run
       executor.start()
     File 
"/usr/local/lib/python3.7/site-packages/airflow/executors/kubernetes_executor.py",
 line 784, in start
       self.kube_client, self.worker_uuid
     File 
"/usr/local/lib/python3.7/site-packages/airflow/executors/kubernetes_executor.py",
 line 396, in __init__
       self.worker_configuration_pod = 
WorkerConfiguration(kube_config=self.kube_config).as_pod()
     File 
"/usr/local/lib/python3.7/site-packages/airflow/kubernetes/worker_configuration.py",
 line 437, in as_pod
       return 
PodGenerator(pod_template_file=self.kube_config.pod_template_file).gen_pod()
     File 
"/usr/local/lib/python3.7/site-packages/airflow/kubernetes/pod_generator.py", 
line 308, in gen_pod
       result.metadata.name = self.make_unique_pod_id(result.metadata.name)
   AttributeError: 'NoneType' object has no attribute 'name'
   ```
   
   How does this PR fix the problem above:
   
   - From the stack trace above, this line here shows that the name is read 
from the kube_config.pod_template_file: 
https://github.com/apache/airflow/blob/db720743c5f5828fabed9dd88384c86a41e2f997/airflow/kubernetes/worker_configuration.py#L437
 
   - In the Airflow Helm chart 1.1.0, only the scheduler has the 
pod_template_file mounted. So when this action was triggered, the webserver 
does not have the pod_template file mounted and couldn't fill in the values 
here. 
   - This PR patches the webserver K8s template to also mount the 
pod_template_file the same way the schedule does here: 
https://github.com/apache/airflow/blob/daa725b9f359c23a374a808ad53bbd7ecefce0d9/chart/templates/scheduler/scheduler-deployment.yaml#L141
 so that when the code path is exercised, `name` is filled in from the value 
read in the pod template file.
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code change, Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in 
[UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.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