<#6523 refactor: Adjust CoPilot init and Pod statu...
# flyte-github
c
#6523 refactor: Adjust CoPilot init and Pod status logic Pull request opened by pingsutw ## Why are the changes needed? Containers task sometimes fails because 1. Propeller fails to read the output because it tries to get the output before the sidecar completes. 2. The sidecar is terminated before it can upload the file because the main container finishes before the signal watcher is created. As a result, the sidecar doesn’t handle the SIGTERM signal properly and gets killed by Kubernetes ## What changes were proposed in this pull request? • Modified
AddCoPilotToPod
to prepend the sidecar container to the list of init containers, ensuring the sidecar starts before the downloader. This guarantees the signal watcher is active before the main container completes. • Updated
DemystifyPodStatus
to check the status of init containers in addition to regular containers. This ensures that tasks are only marked as succeeded when both containers and sidecars have completed successfully. • Adjusted
assertPodHasCoPilot
to include init containers in the validation loop, ensuring volume mounts are correctly asserted for all containers. • Added assertions in
TestAddCoPilotToPod
to verify the order and naming of init containers, ensuring the sidecar and downloader are correctly configured. ## How was this patch tested? from flytekit import ContainerTask, kwtypes greeting_task = ContainerTask( name="test", image="alpine:latest", input_data_dir="/var/inputs", output_data_dir="/var/outputs", inputs=kwtypes(name=str), outputs=kwtypes(greeting=str), command=["/bin/sh", "-c", "sleep 100 | echo 'Hello, my name is {{.inputs.name}}.' | tee -a /var/outputs/greeting"], ) ### Screenshots [Screenshot 2025-07-03 at 5 01 46 PM](https://private-user-images.githubusercontent.com/37936015/462246787-e9cf0be7-f718-44fc-8ce7-cd203e52efdd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTE5Mjk1MzMsIm5iZiI6MTc1MTkyOTIzMywicGF0aCI6Ii8zNzkzNjAxNS80NjIyNDY3ODctZTljZjBiZTctZjcxOC00NGZjLThjZTctY2QyMDNlNTJlZmRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA3MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNzA3VDIzMDAzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk1YjE0N2YyOTRiOTRiOTIyNmQ2Y2ZiODUxMTIyZjNkNGVlN2E1MTBhMDU0MDdhNjNlOGY3ODgzN2I1ZTgzMTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.eOEpjghR25SAjbTgxVjS4TaNJChAQ1iqFS2W-zcMtkQ) flyteorg/flyte