-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (#41211) #50803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (#41211) #50803
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
b7c6702 to
c7bf57b
Compare
|
Hi @hussein-awala @jedcunningham @eladkal, I've pushed the changes to address the raised issue and the previously failing test. When you have a moment, could you please review the updates? I'm new to the Airflow repository, and this is my first PR, so I really appreciate any feedback or suggestions you might have. Thanks for your time and support! |
|
Thanks for triggering tests @eladkal, Should I consider optimizing the tests for memory usage? I'd appreciate any suggestions on improving test reliability or adjusting the job configuration to reduce resource consumption. Thank you |
Yes - i think it's best you track down where it comes from. It's hard to say and we are not experts in all integrations, but yes indeed it looks like somewhere memory is leaked - but where and how - hard to say. Note that there are usually some logs uploaded as artifacts (you can scroll down summary page) - maybe they are helpful. I also added "debug ci resources" label that might help you to see if indeed memory is growing and when more easily - it will print resource stats in the periodic dump of your test run - you can trace it when you rebase and re-run the PR. |
eb2fb26 to
e495110
Compare
…ernetesOperator reattach_on_restart functionality (apache#41211)
…ernetesOperator reattach_on_restart functionality (apache#41211)
e495110 to
e105907
Compare
- Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing
- Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling
- Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation
Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211
78d8625 to
5b28c36
Compare
…ernetesOperator reattach_on_restart functionality (apache#41211)
Okay |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
…ernetesOperator reattach_on_restart functionality (apache#50803) * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix formatting in test_spark_kubernetes.py * Fix test assertions in SparkKubernetesOperator tests to handle task context labels * Fix whitespace issues in spark_kubernetes.py * fix format and resolves failing tests * Fix SparkKubernetesOperator test OOM issues * Fix: Add task context labels to driver and executor pods for SparkKubernetesOperator reattach_on_restart functionality (apache#41211) * Fix whitespace issues in spark_kubernetes.py * Clean up merge conflict markers in test_spark_kubernetes.py * Fix test assertions for SparkKubernetesOperator task context labels - Fixed test structure expectations in test_adds_task_context_labels_to_driver_and_executor - Changed assertion from created_body['spark']['spec'] to created_body['spec'] - This matches the actual structure passed to create_namespaced_custom_object after SparkJobSpec processing * Fix compatibility issue with parent_dag attribute access - Changed from checking is_subdag to parent_dag to match KubernetesPodOperator implementation - This ensures compatibility with older Airflow versions where is_subdag may not exist - Follows the same pattern used in the parent class for SubDAG handling * Align _get_ti_pod_labels implementation with KubernetesPodOperator - Use ti.map_index directly instead of getattr for consistency - Convert try_number to string to match parent class behavior - Convert map_index to string for label value consistency - This ensures full compatibility with the parent class implementation * feat: Add reattach functionality to SparkKubernetesOperator Add reattach_on_restart parameter (default: True) to automatically reattach to existing Spark applications on task restart, preventing duplicate job creation. - Implement find_spark_job method for existing job detection - Add task context labels for pod identification - Maintain 100% backward compatibility - Add comprehensive test coverage (2 new tests) Fixes apache#41211 * Fix SparkKubernetesOperator reattach with task context labels - Add task context labels to driver and executor pods when reattach_on_restart=True - Fix execution flow to maintain test compatibility - Preserve deferrable execution functionality - Add comprehensive reattach logic with proper pod finding Fixes apache#41211 * Fix code formatting for static checks - Remove extra blank line in SparkKubernetesOperator - Add required blank line in test file - Ensure compliance with ruff formatting standards * update tests
Closes: #41211 where the SparkKubernetesOperator's reattach_on_restart functionality doesn't work correctly.
Problem
When reattach_on_restart is enabled, the SparkKubernetesOperator tries to find the driver pod by looking for pods with specific task context labels (dag_id, task_id, run_id). However, these labels are not actually added to the driver and executor pods when creating them, causing the reattach functionality to fail.
Solution
This PR adds code to the execute method of the SparkKubernetesOperator class to add task context labels to both the driver and executor pods when reattach_on_restart is enabled. This allows the operator to find the existing driver pod if the scheduler restarts.
Testing
I've performed comprehensive testing to ensure the fix works correctly:
All tests passed, confirming that the fix works as expected.