exercism / kotlin-test-runner

GNU Affero General Public License v3.0
4 stars 11 forks source link

__out.log (No such file or directory) #19

Open dector opened 3 years ago

dector commented 3 years ago

@dector I'm running again with the latest fix, and the error is indeed fixed! Great. I do get another error though:

Parsed arguments: LaunchArguments(exerciseSlug=hello-world, solutionsDir=/solution, resultFile=/output/results.json)
Running gradle
Exception in thread "main" java.io.IOException: Cannot run program "./gradlew" (in directory "/tmp/kotlin-autotest-runnner16159523151937320801"): /tmp/kotlin-autotest-runnner16159523151937320801/__out.log (No such file or directory)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at exercism.kotlin.autotests.executor.ExecutorKt.runGradleProcess(executor.kt:64)
        at exercism.kotlin.autotests.executor.ExecutorKt.executeBuild(executor.kt:30)
        at exercism.kotlin.autotests.executor.ExecutorKt.executor(executor.kt:10)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt:28)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt)
        at exercism.kotlin.autotests.executor.EnvironmentKt.executeOnEnvironment(environment.kt:16)
        at exercism.kotlin.autotests.runner.MainKt.main(main.kt:28)
Caused by: java.io.FileNotFoundException: /tmp/kotlin-autotest-runnner16159523151937320801/__out.log (No such file or directory)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:250)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
        ... 8 more
erik@VELPIE:~/exercism/kotlin-test-runner$ ./bin/run-in-docker.sh hello-world /home/erik/exercism-repos/kotlin-test-runner/examples/full /home/erik/exercism-repos/kotlin-test-runner/examples/full
[+] Building 1.5s (19/19) FINISHED                                                                                                    
 => [internal] load build definition from Dockerfile                                                                             0.0s
 => => transferring dockerfile: 38B                                                                                              0.0s
 => [internal] load .dockerignore                                                                                                0.0s
 => => transferring context: 2B                                                                                                  0.0s
 => [internal] load metadata for docker.io/adoptopenjdk/openjdk11:jdk-11.0.5_10-alpine-slim                                      1.2s
 => [build  1/10] FROM docker.io/adoptopenjdk/openjdk11:jdk-11.0.5_10-alpine-slim@sha256:0036883df4894f853a6c8e6e1832c105f3026c  0.0s
 => [internal] load build context                                                                                                0.0s
 => => transferring context: 2.35kB                                                                                              0.0s
 => CACHED [stage-1 2/5] COPY bin/run.sh /opt/test-runner/bin/run.sh                                                             0.0s
 => CACHED [build  2/10] RUN apk add --no-cache tar bash procps                                                                  0.0s
 => CACHED [build  3/10] WORKDIR /home/builder                                                                                   0.0s
 => CACHED [build  4/10] RUN wget https://services.gradle.org/distributions/gradle-6.0.1-bin.zip                                 0.0s
 => CACHED [build  5/10] RUN unzip gradle-6.0.1-bin.zip                                                                          0.0s
 => CACHED [build  6/10] RUN mv gradle-6.0.1 /home/gradle                                                                        0.0s
 => CACHED [build  7/10] COPY src ./src                                                                                          0.0s
 => CACHED [build  8/10] COPY build.gradle.kts ./                                                                                0.0s
 => CACHED [build  9/10] RUN /home/gradle/bin/gradle -i shadowJar                                                                0.0s
 => CACHED [build 10/10] RUN cp build/libs/autotest-runner.jar .                                                                 0.0s
 => CACHED [stage-1 3/5] COPY --from=build                                                                                       0.0s
 => CACHED [stage-1 4/5] COPY --from=build /home/builder/autotest-runner.jar /opt/test-runner/bin/                               0.0s
 => CACHED [stage-1 5/5] WORKDIR /opt/test-runner                                                                                0.0s
 => exporting to image                                                                                                           0.1s
 => => exporting layers                                                                                                          0.0s
 => => writing image sha256:0f29eaac8a4f826d3898e5ec51ea9b5fe0720359f1e50bbefccdd5feb30ce973                                     0.0s
 => => naming to docker.io/exercism/test-runner                                                                                  0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Parsed arguments: LaunchArguments(exerciseSlug=hello-world, solutionsDir=/solution, resultFile=/output/results.json)
Running gradle
Exception in thread "main" java.io.IOException: Cannot run program "./gradlew" (in directory "/tmp/kotlin-autotest-runnner8757524361769826187"): /tmp/kotlin-autotest-runnner8757524361769826187/__out.log (No such file or directory)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at exercism.kotlin.autotests.executor.ExecutorKt.runGradleProcess(executor.kt:64)
        at exercism.kotlin.autotests.executor.ExecutorKt.executeBuild(executor.kt:30)
        at exercism.kotlin.autotests.executor.ExecutorKt.executor(executor.kt:10)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt:28)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt)
        at exercism.kotlin.autotests.executor.EnvironmentKt.executeOnEnvironment(environment.kt:16)
        at exercism.kotlin.autotests.runner.MainKt.main(main.kt:28)
Caused by: java.io.FileNotFoundException: /tmp/kotlin-autotest-runnner8757524361769826187/__out.log (No such file or directory)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:250)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
        ... 8 more

Any idea?

Originally posted by @ErikSchierboom in https://github.com/exercism/kotlin-test-runner/issues/14#issuecomment-837918541

dector commented 3 years ago

@ErikSchierboom I'm not sure, but this seems like different JVM/Docker behaviour. Do you use Mac? I don't have such issue on Linux.

My suggestion is that logfile isn't creating automatically before redirecting IO. Would be very grateful if you can you try this fix and tell me if it helps:

val ioRedirect = run {
    logFile.delete()
+    logFile.createNewFile()
    ProcessBuilder.Redirect.appendTo(logFile)
}

here: https://github.com/exercism/kotlin-test-runner/blob/main/src/main/kotlin/exercism/kotlin/autotests/executor/executor.kt#L52

ErikSchierboom commented 3 years ago

I'm running on WSL on Windows, which is a virtual machine with Ubuntu. Weirdly enough, re-running it now gets me a different error message:

Parsed arguments: LaunchArguments(exerciseSlug=hello-world, solutionsDir=/solution, resultFile=/output/results.json)
Running gradle
Gradle finished with exit code 1
=== Log START ===
Exception in thread "main" java.lang.RuntimeException: Could not create parent directory for lock file /root/.gradle/wrapper/dists/gradle-6.0.1-bin/1lxlpkiy24sb18odw96cp4ojv/gradle-6.0.1-bin.zip.lck
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:43)
        at org.gradle.wrapper.Install.createDist(Install.java:48)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

=== Log END ===

You don't get that error if you run ./bin/run-in-docker.sh hello-world /home/erik/exercism/kotlin-test-runner/examples/full /home/erik/exercism/kotlin-test-runner/examples/full?

dector commented 3 years ago

I reworked test runner's Dockerfile to use official Gradle images. And added Gradle cache into container. This will let us run build in offline mode (container size increased ofc).

However, there is major readonly containers. Gradle performs some locks during builds. I can do dirty hack and copy cache to tmpfs on every build. But is --readonly really necessary?

ErikSchierboom commented 3 years ago

But is --readonly really necessary?

Well, it helps improve security. We haven't yet enabled it in production, so for now you can ignore the readonly-ness.

dector commented 3 years ago

There is incubating feature in new Gradle versions that allows sharing lock-free build cache via separate container. I'll take a look at it when I'll have enough time.

ErikSchierboom commented 3 years ago

👍