metalbear-co / mirrord

Connect your local process and your cloud environment, and run local code in cloud conditions.
https://mirrord.dev
MIT License
3.84k stars 107 forks source link

Issue connecting to gradle daemon #2320

Open atatadev opened 8 months ago

atatadev commented 8 months ago

Bug Description

If I use mirrord cmd line with gradle, sometimes I face issue that it can’t communicate between its processes, examples:

Steps to Reproduce

The issue is flaky and not always reproducible. But technically, it's just execute gradle tasks with mirrord

Backtrace

No response

Relevant Logs

To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.3/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.

FAILURE: Build failed with an exception.

* What went wrong:
Could not connect to the Gradle daemon.
Daemon uid: d79a09f6-fe9e-4d3f-a8f9-e364edd89c5c with diagnostics:
Daemon pid: 60119
  log file: /Users/odankov/.gradle/daemon/8.3/daemon-60119.out.log
----- Last  20 lines from daemon log file - daemon-60119.out.log -----
2024-03-21T10:54:45.602+0700 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /10.121.180.51
2024-03-21T10:54:45.602+0700 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface en0
2024-03-21T10:54:45.602+0700 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
2024-03-21T10:54:45.602+0700 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /192.168.1.114
2024-03-21T10:54:45.602+0700 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface lo0
2024-03-21T10:54:45.603+0700 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? true
2024-03-21T10:54:45.603+0700 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding loopback address /127.0.0.1
2024-03-21T10:54:45.604+0700 [DEBUG] [org.gradle.internal.remote.internal.inet.TcpIncomingConnector] Listening on [478efa5e-ba1e-44c4-bf89-266f7f711ae9 port:60641, addresses:[localhost/127.0.0.1]].
2024-03-21T10:54:45.608+0700 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] Daemon starting at: Thu Mar 21 10:54:45 ICT 2024, with address: [478efa5e-ba1e-44c4-bf89-266f7f711ae9 port:60641, addresses:[localhost/127.0.0.1]]
2024-03-21T10:54:45.608+0700 [INFO] [org.gradle.launcher.daemon.server.DaemonRegistryUpdater] Advertising the daemon address to the clients: [478efa5e-ba1e-44c4-bf89-266f7f711ae9 port:60641, addresses:[localhost/127.0.0.1]]
2024-03-21T10:54:45.608+0700 [DEBUG] [org.gradle.launcher.daemon.server.DaemonRegistryUpdater] Advertised daemon context: DefaultDaemonContext[uid=d79a09f6-fe9e-4d3f-a8f9-e364edd89c5c,javaHome=/Users/odankov/.sdkman/candidates/java/17.0.7-zulu/zulu-17.jdk/Contents/Home,daemonRegistryDir=/Users/odankov/.gradle/daemon,pid=60119,idleTimeout=120000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx16G,-Dfile.encoding=UTF-8,-Duser.country=TH,-Duser.language=en,-Duser.variant]
2024-03-21T10:54:45.609+0700 [DEBUG] [org.gradle.launcher.daemon.registry.PersistentDaemonRegistry] Storing daemon address: [478efa5e-ba1e-44c4-bf89-266f7f711ae9 port:60641, addresses:[localhost/127.0.0.1]], context: DefaultDaemonContext[uid=d79a09f6-fe9e-4d3f-a8f9-e364edd89c5c,javaHome=/Users/odankov/.sdkman/candidates/java/17.0.7-zulu/zulu-17.jdk/Contents/Home,daemonRegistryDir=/Users/odankov/.gradle/daemon,pid=60119,idleTimeout=120000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx16G,-Dfile.encoding=UTF-8,-Duser.country=TH,-Duser.language=en,-Duser.variant]
2024-03-21T10:54:45.616+0700 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on daemon addresses registry.
2024-03-21T10:54:45.617+0700 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
2024-03-21T10:54:45.620+0700 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
2024-03-21T10:54:45.620+0700 [LIFECYCLE] [org.gradle.launcher.daemon.server.Daemon] Daemon server started.
2024-03-21T10:54:45.620+0700 [DEBUG] [org.gradle.launcher.daemon.bootstrap.DaemonStartupCommunication] Completed writing the daemon greeting. Closing streams...
2024-03-21T10:54:45.623+0700 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] stopOnExpiration() called on daemon
2024-03-21T10:54:45.623+0700 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] awaitExpiration() called on daemon
2024-03-21T10:54:45.623+0700 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] daemon is running. Sleeping until state changes.
----- End of the daemon log -----

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
10:54:46 error failed starting a tunnel service ktor-server-template with error: failed executing binary exit status 1

Your operating system and version

Mac OS 14.3

Local process

gradlew (java)

Local process version

OpenJDK 64-Bit Server VM Zulu17.42+19-CA (build 17.0.7+7-LTS, mixed mode, sharing)

Additional Info

Config and logs: mirrord 3.92.1

mirrord.json agent-logs.txt gradle-daemon-connection-issue-log.txt gradle-fork-executor-issue-log.txt

aviramha commented 8 months ago

Thanks for reporting this. Is it possible to check if this happens on an example you can share? for example, take a sample project that uses same JDK, Gradle and framework/libraries that doesn't contain your company code/data, and see if it happens on that as well? This way we can try to reproduce it on our end in a better way.

eyalb181 commented 5 months ago

Hey @atatadev , is this still happening to you?

plukanek commented 3 weeks ago

The same issue happens here aswell with different gradle and java versions e.g OpenJDK 64-Bit Server VM Temurin-21.0.4+7 (build 21.0.4+7-LTS, mixed mode) + Gradle 8.6

aviramha commented 3 weeks ago

The same issue happens here aswell with different gradle and java versions e.g OpenJDK 64-Bit Server VM Temurin-21.0.4+7 (build 21.0.4+7-LTS, mixed mode) + Gradle 8.6

Can you try adding this to your config please?

{
  "feature": {
    "network": {
      "outgoing": {
        "ignore_localhost": true
      }
    }
  }
}