cuddly-jelly-27016
03/22/2025, 1:35 PMinvalid TaskSpecification, container [driver-primary] not defined is raised.
[image](https://private-user-images.githubusercontent.com/60069744/425740856-7bcbad11-1a1d-46a1-8573-302eec59686c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDI3MzczMTAsIm5iZiI6MTc0MjczNzAxMCwicGF0aCI6Ii82MDA2OTc0NC80MjU3NDA4NTYtN2JjYmFkMTEtMWExZC00NmExLTg1NzMtMzAyZWVjNTk2ODZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAzMjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMzIzVDEzMzY1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRkZGM4NzgwYmFmM2RiZjMxMzYxMGEwY2QzN2U5OTJiYTdiNDZjZDc0MThhMWJkYjIyNzA0ZmI2NjUyNmVhNWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.dKlcyNGVkEc9_ltHiXWFMZ_Wi8HCgwDJp50f01RffyY)
## What changes were proposed in this pull request?
Use MergeBasePodSpecOntoTemplate that enables setting primaryContainerName and primaryInitContainerName.
## How was this patch tested?
Unittest is added to check if setting primary container name that's not "primary" in driver and executor, spark can perform as expected.
### Labels
Please add one or more of the following labels to categorize your PR:
• added: For new features.
• changed: For changes in existing functionality.
• deprecated: For soon-to-be-removed features.
• removed: For features being removed.
• fixed: For any bug fixed.
• security: In case of vulnerabilities
This is important to improve the readability of release notes.
### Setup process
### Screenshots
## Check all the applicable boxes
• I updated the documentation accordingly.
• All new and existing tests passed.
• All commits are signed-off.
## Related PRs
## Docs link
### Summary by Bito
This PR fixes a critical bug related to different primary container names in Spark driver and executor pods causing 'container not defined' errors. It refactors MergeBasePodSpecOntoTemplate to improve conditional logic, adds an else branch for container name comparisons, and consolidates init container merging procedures.
Unit tests added: True
Estimated effort to review (1-5, lower is better): 2
flyteorg/flyte