fix(PodCreate): ensure pod cleanup on failure with outputFiles #210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
After PR #208 fixed container exit code validation, a new issue emerged: when container failures are detected and an exception is thrown, pod deletion was skipped, leaving pods running indefinitely despite
delete: true
configuration.This is a resource leak issue - failed pods accumulate in the cluster and are never cleaned up, even though the task correctly reports the failure.
Solution
Main fix:
try-finally
block to ensure pod deletion always runs, even when exceptions occurCode improvements:
handleEnd()
to accepthasOutputFiles
parameter for clearer separation of concernshandleEnd()
to centralize log collection and failure validationPodService.checkContainerFailures()
to ensure errors are logged before exceptions are thrownTesting
Enhanced and added comprehensive test cases:
Enhanced existing test:
failedWithOutputFiles()
- Now verifies logs are collected AND pods are deletedNew test cases:
failedWithOutputFilesDeletesPod()
- Explicitly tests pod deletion with async monitoringsuccessWithOutputFiles()
- Verifies success path with outputFilesmultipleContainersOneFailsWithOutputFiles()
- Tests multi-container failure detection with log and deletion verificationlogCollectionTimingWithOutputFiles()
- Verifies waitForLogInterval is respected before failureAll failure tests now verify:
Note
Test execution time: ~8-9 minutes for full PodCreateTest suite. Duration slightly increased due to additional deletion verification and reliable log collection timing.