dennismdejong commented on code in PR #13664:
URL: https://github.com/apache/gravitino/pull/13664#discussion_r4215893187
##########
build.gradle.kts:
##########
@@ -1710,53 +1710,63 @@ fun checkMacDockerConnector() {
return
}
- try {
- val processName = "docker-connector"
- val command = "pgrep -x -q $processName"
-
- val execResult = project.exec {
- commandLine("bash", "-c", command)
- }
- if (execResult.exitValue == 0) {
- project.extra["macDockerConnector"] = true
+ // `pgrep` exits with 0 when at least one process matches the given name and
with 1 when no
+ // process matches, so exit code 1 only tells us that `docker-connector` is
not running.
+ val exitCode =
+ try {
+ ProcessBuilder("pgrep", "-x", "-q", "docker-connector").start().waitFor()
+ } catch (e: IOException) {
+ println("checkMacDockerConnector failed: unable to run `pgrep`:
${e.message}")
+ return
}
- } catch (e: Exception) {
- println("checkContainerRunning failed: ${e.message}")
+
+ if (exitCode == 0) {
+ project.extra["macDockerConnector"] = true
+ } else if (exitCode != 1) {
+ println(
+ "checkMacDockerConnector failed: `pgrep -x -q docker-connector` exited
with code $exitCode"
+ )
}
}
fun checkDockerStatus() {
- try {
- val process = ProcessBuilder("docker", "info").start()
- val exitCode = process.waitFor()
-
- if (exitCode == 0) {
- project.extra["dockerRunning"] = true
- } else {
- println("checkDockerStatus failed with exit code $exitCode")
+ val exitCode =
+ try {
+ ProcessBuilder("docker", "info").start().waitFor()
+ } catch (e: IOException) {
+ // The `docker` command is not installed or not on the PATH. The status
summary and the tips
Review Comment:
Good catch, thanks @yuqi1129. I've updated the catch block so it no longer
assumes every `IOException` means "not installed".
`checkDockerStatus` and `checkOrbStackStatus` now check whether the `docker`
command actually exists on the `PATH` before deciding to stay quiet:
```kotlin
fun isCommandOnPath(command: String): Boolean {
val path = System.getenv("PATH") ?: return false
return path.split(File.pathSeparator).any { directory -> File(directory,
command).isFile }
}
```
- Docker genuinely not installed -> no file found -> keep silent (the status
summary and tips already cover this case, which is the point of #7203).
- Docker exists but `start()` still fails (e.g. the current user has no
permission to run it) -> print the underlying `e.message`.
I couldn't run `:spotlessKotlinGradleCheck` in my sandbox (no JDK
available), so I'd appreciate it if you could re-run CI.
--
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]