davsclaus opened a new pull request, #29940: URL: https://github.com/apache/camel/pull/29940
Item 9 of [CAMEL-26931](https://issues.apache.org/jira/browse/CAMEL-26931): `camel infra stop --kill` could kill an unrelated process. ## Problem `InfraBaseCommand.findRunningServices` took every live pid with an `infra-<service>-<pid>.json` file as the service. A service that was killed hard (or a machine that went down) leaves its pid file behind, and the pid may be taken by another process later. `camel infra stop --kill` then killed that process with `destroyForcibly`, and `infra ps`, `infra log` and `infra get` reported it as the service. This is the pid-reuse problem of CAMEL-26911 item 1, on the code path of the infra services. ## Change A pid file that was last written before the process with its pid started is left over: it is pruned with its log file, as for a pid whose process is gone, and the service is not running. The check is `ProcessHelper.isStale`, which CAMEL-26911 added for the files of an integration, with its 10 seconds of slack. A pid file is written by the service itself, after its process started, so a running service is never taken for a left-over one. ## Tests - `InfraStopTest.aPidFileOlderThanTheProcessOfItsPidIsNotTheService` (new): a pid file with the pid of the test JVM, dated an hour before the JVM started, is not found (exit 3), nothing is shut down, and its pid and log files are removed. It fails without the change. The test runs without `--kill`, so it cannot kill the JVM when the check is missing. - `InfraStopTest.aPidFileWrittenByTheProcessIsTheService` (new): the same pid with a new pid file is stopped. - The `Infra*Test` tests pass. camel-jbang-run: 303. camel-jbang-core: 3004 + 259 pass (`DependencyUpdateTest` failed once and passed on the rerun, as on other branches). _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
