jagath25 opened a new pull request, #29778:
URL: https://github.com/apache/flink/pull/29778

   ## What is the purpose of the change
   
   The program that `JarRunApplicationHandler` hands to its 
`PackagedProgramApplication` is never closed, so the nested `lib/` jars it 
extracted into `java.io.tmpdir` are only deleted on JVM exit. The same applies 
to programs built for applications recovered from HA.
   
   **Depends on #29473 (FLINK-35376)**; only the last commit belongs to this PR.
   
   ## Brief change log
   
     - `PackagedProgramApplication` closes a program it owns once it terminates 
or is disposed. It owns a program it builds from a `PackagedProgramDescriptor`, 
or one handed over with `ownsProgram` (HA recovery). A program that is just 
passed in stays owned by the caller: application mode hands the same program to 
a new application on every leadership grant and `ApplicationClusterEntryPoint` 
closes it on shutdown.
     - An owned program is set as the source of 
`pipeline.jars`/`pipeline.classpaths`, because the configuration may still 
refer to jars another program extracted.
     - `JarRunApplicationHandler` submits the descriptor and closes the program 
it validated the request with right away.
     - `PackagedProgramApplicationEntry` hands its rebuilt program over as 
owned.
   
   Trade-off: run-application extracts the jar twice (validation and execution).
   
   ## Verifying this change
   
     - `JarSubmissionITCase#testRunApplicationDeletesExtractedNestedLibraries` 
submits a jar with a nested `lib/` jar via run-application and checks 
`java.io.tmpdir`. It fails without this change.
     - `PackagedProgramApplicationTest`: a program built from a descriptor is 
closed when the application finishes and the jobs use its own jars; an owned 
program is closed on dispose; a program passed in is not closed on finish or 
dispose.
     - Existing `PackagedProgramApplicationITCase` (application mode with 
ZooKeeper HA) and `PackagedProgramApplicationEntryTest` pass.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: yes (cleanup of 
applications recovered from HA)
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 5.5)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to