-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Handle left-over termination logs from previous runs with same cache #35252
Conversation
(Real error this time) It was found when I optimized tests by using caching. cc: @jens-scheffler-bosch :).. Very interesting side-effect - I think you should check in your implementation in Bosch if you have similar issue. |
When PythonVirtualEnv and friends use cached venv, script and termination logs are stored in the venv. While this was fine for scripts because the env is locked and scripts were overwritten every time venv started - it was not the same for termination log. The termination log remains in venv after venv completes (which is good for diagnostics) however when subsequent task failed without raising regular exception but just by sys.exit(), the termination log from previous task was found and such task would return AirflowException instead of CalledProcessError with the message coming from the previous task. This PR fixes it by deleting the termination log at the start of PythonVirtualenv task, when such termination log is present in the venv.
fd53b11
to
b0ec5c9
Compare
Sorry, I was off during the day and just now this PR jumped into my eyes. Reading the fix description and looking through the code I fear we have a more severe problem that we urgently need to fix. So I propose (to have a few minutes for me) and revert this PR and change the location where the temporary script, input, output and termination log is generated in general. Every call should have its own temp for the volatile script data and we need to prevent having (static) files as temp files in the venv. |
Yes. When I looked at this todya, I thought the lock we have is for the whole execution, but yeah. I just checked, we do it only for venv creation time. Which makes much more time.
I don't think there is a need or desire to revert this one - it's still useful to at least get the new test harness working #35160. Reverting it now makes no sense - it at least solves "some" edge case for now. I'd say we need a new PR to fix this indeed. The scripts and output shoudl be all generated in a tmp direcrtory |
That concurrency thing was one important detail. The lock is only being made during creation of the venv. Once the cached venv is available of course we want and need to be able to execute tasks in the venv concurrently. Same like with external python. |
Absolutely. As if "replace with generated dir which makes it unnecessary" rather than "revert the commit :D" |
Revert #35252 and ensure venv cache files are created in a dedicated tmp folder
When PythonVirtualEnv and friends use cached venv, script and termination logs are stored in the venv. While this was fine for scripts because the env is locked and scripts were overwritten every time venv started - it was not the same for termination log.
The termination log remains in venv after venv completes (which is good for diagnostics) however when subsequent task failed without raising regular exception but just by sys.exit(), the termination log from previous task was found and such task would return AirflowException instead of CalledProcessError with the message coming from the previous task.
This PR fixes it by deleting the termination log at the start of PythonVirtualenv task, when such termination log is present in the venv.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.