diff options
author | Googler <noreply@google.com> | 2018-04-20 07:38:48 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-20 07:40:23 -0700 |
commit | 633ca68d71e8fa7086b9d57945ecd42f48bdf57c (patch) | |
tree | 28f183333c1228d6684a9a451dc4728e419fb37b /src/tools/remote | |
parent | 97132c0925031e1b1fb8e9e5dde2233daef9d97b (diff) |
Don't add -u flag to local remote worker docker command on Windows.
-u doesn't currently make sense for Windows: https://github.com/docker/for-win/issues/636#issuecomment-293653788
The local remote worker happens to sometimes work on Windows because we would frequently (always?) hit the timeout here (but recently this hasn't been the case for me): https://github.com/bazelbuild/bazel/blob/fa36d2f48965b127e8fd397348d16e991135bfb6/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/ExecutionServer.java#L323
When we don't hit the timeout (so "id -u" succeeds, and the "-u" flag is passed to docker), we get an error like this:
```
Error response from daemon: container 06851b64e09bab5a930bfb706892785b24c7538c1a7be826fef315ab8e62c117 encountered an error during CreateProcess: failure in a Windows system call: The user name or password is incorrect. (0x52e)
```
The method for detecting Windows is the best I could find, similar to other isWindows functions in Bazel.
RELNOTES: None.
PiperOrigin-RevId: 193666199
Diffstat (limited to 'src/tools/remote')
-rw-r--r-- | src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/ExecutionServer.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/ExecutionServer.java b/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/ExecutionServer.java index 098b4adf4b..e9ea69df1d 100644 --- a/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/ExecutionServer.java +++ b/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/ExecutionServer.java @@ -288,6 +288,11 @@ final class ExecutionServer extends ExecutionImplBase { return finalResult; } + // Returns true if the OS being run on is Windows (or some close approximation thereof). + private boolean isWindows() { + return System.getProperty("os.name").startsWith("Windows"); + } + private boolean wasTimeout(long timeoutMillis, long wallTimeMillis) { return timeoutMillis > 0 && wallTimeMillis > timeoutMillis; } @@ -370,10 +375,14 @@ final class ExecutionServer extends ExecutionImplBase { newCommandLineElements.add("docker"); newCommandLineElements.add("run"); - long uid = getUid(); - if (uid >= 0) { - newCommandLineElements.add("-u"); - newCommandLineElements.add(Long.toString(uid)); + // -u doesn't currently make sense for Windows: + // https://github.com/docker/for-win/issues/636#issuecomment-293653788 + if (!isWindows()) { + long uid = getUid(); + if (uid >= 0) { + newCommandLineElements.add("-u"); + newCommandLineElements.add(Long.toString(uid)); + } } String dockerPathString = pathString + "-docker"; |