bazel-java-sdk icon indicating copy to clipboard operation
bazel-java-sdk copied to clipboard

Incompatibility with remote execution

Open SinOverCos opened this issue 1 year ago • 6 comments

Question: Is there any workaround to keep the bazel-java-sdk code compatible with remote execution?

I recently moved to a remote execution setup. I noticed now that the build event JSON looks a little different (note the uri field):

Before:

{
  ...,
  "namedSetOfFiles": {
    "files": [
      {
        "name": "main.py",
        "uri": "file:///home/tanwang/myproject/main.py",
        "digest": "4ff69b370de3d0c25f089d8d4519e9e3123d102b277557dbf11d297245b3cecb",
        "length": "14875"
      },
      {
        "name": "lint/lint",
        "uri": "file:///home/tanwang/.cache/bazel/_bazel_tanwang/18df9e177741fe13ade143008eeb6c37/execroot/myproject/bazel-out/k8-fastbuild/bin/lint/lint",
        "pathPrefix": [
          "bazel-out",
          "k8-fastbuild",
          "bin"
        ],
        "digest": "7c2409e1bfa139742ff574df0d1d7883357cf5da0d8001dc9e9796398f923b0c",
        "length": "22061"
      }
    ]
  }
}

Now:

{
  ...,
  "completed": {
    ...,
    "importantOutput": [
      {
        "name": "lint/lint",
        "uri": "bytestream://localhost:8980/blobs/7c2409e1bfa139742ff574df0d1d7883357cf5da0d8001dc9e9796398f923b0c/22061",
        "pathPrefix": [
          "bazel-out",
          "k8-fastbuild",
          "bin"
        ],
        "digest": "7c2409e1bfa139742ff574df0d1d7883357cf5da0d8001dc9e9796398f923b0c",
        "length": "22061"
      }
    ]
  }
}

The Problem

Based on this, only file:// URIs are allowed. With remote execution however, seems that they'll always be bytestreams.

I'm now getting this error:

java.lang.IllegalArgumentException: Expected a file:// uri for property lint/linters/checkstyle.jar, instead got bytestream://localhost:19193/blobs/8a1cb7e84ee859c1a01f5be789c0decd703f0ae323ec9a007a4b49effe1e5aae/325
        at com.salesforce.bazel.sdk.bep.event.BEPFileUri.<init>(BEPFileUri.java:96)
        at com.salesforce.bazel.sdk.bep.event.BEPEvent.decodeURIFromJsonObject(BEPEvent.java:335)
        at com.salesforce.bazel.sdk.bep.event.BEPNamedSetEvent.parseDetails(BEPNamedSetEvent.java:81)
        at com.salesforce.bazel.sdk.bep.event.BEPNamedSetEvent.<init>(BEPNamedSetEvent.java:57)
        at com.salesforce.bazel.sdk.bep.DefaultBazelBuildEventTypeResolver.createEvent(DefaultBazelBuildEventTypeResolver.java:88)
        at com.salesforce.bazel.sdk.bep.BazelBuildEventTypeManager.createEvent(BazelBuildEventTypeManager.java:156)
        at com.salesforce.bazel.sdk.bep.BazelBuildEventTypeManager.parseEvent(BazelBuildEventTypeManager.java:131)
        at com.salesforce.bazel.sdk.bep.file.BEPFileParser.readEvents(BEPFileParser.java:119)
        at com.salesforce.bazel.sdk.bep.BazelBuildEventsFileStream.processFile(BazelBuildEventsFileStream.java:119)
        at com.salesforce.bazel.sdk.bep.BazelBuildEventsPollingFileStream$FilePoller.run(BazelBuildEventsPollingFileStream.java:144)
        at java.lang.Thread.run(Thread.java:748)
ERROR [com.salesforce.bazel.sdk.bep.BazelBuildEventTypeManager] Error parsing json BEP event [java.lang.IllegalArgumentException: Expected a file:// uri for property lint/linters/checkstyle.jar, instead got bytestream://localhost:19193/blobs/8a1cb7e84ee859c1a01f5be789c0decd703f0ae323ec9a007a4b49effe1e5aae/325]

Is there any workaround to keep the bazel-java-sdk code compatible with remote execution?

SinOverCos avatar Aug 23 '23 14:08 SinOverCos

I think this needs an update to make the code compatible. However, we are no longer maintaining this project.

guw avatar Aug 23 '23 19:08 guw

I am hoping to continue work on this project, so re-opening just in case I have a chance to look at it. This project was a subset of the code in the bazel-eclipse project, which has since gone in a different direction.

plaird avatar Aug 28 '23 00:08 plaird

Hey @plaird, just wondering if you might be looking into this soon or if I should try to find another way. Thanks!

SinOverCos avatar Sep 14 '23 15:09 SinOverCos

@plaird @guw what kind of change would be needed to get past this error?

SinOverCos avatar Oct 03 '23 13:10 SinOverCos

It shouldn't be too hard, but setting up the test case will take some work. The main purpose of that class is to load lines of BEP:

https://github.com/salesforce/bazel-java-sdk/blob/master/sdk/bazel-java-sdk/src/main/java/com/salesforce/bazel/sdk/bep/event/BEPFileUri.java#L172

The project currently supports the local file paradigm for this, and not BEP via grpc.

plaird avatar Oct 04 '23 00:10 plaird

It seems like that class needs to be abstracted a bit, to load lines from either the local file, or the bytestream.

plaird avatar Oct 04 '23 00:10 plaird