Repository navigation
Conversation
Note for the internal (google3) buildThis PR, and #547 underneath it, only change the Maven build. The GitHub repo has no Bazel
Without these, the internal runtime fails the same way as before #547: |
|
not sure if this is helping to reduce jar sizes. Investigate more @gajjarc |
15e9a3f to
73920f3
Compare
The Cloud Tasks client bundled in runtime_impl_jetty12/121 only needs a gRPC transport found through the ManagedChannelProvider SPI; nothing in gax, gax-grpc, grpc-auth or the Cloud Tasks stubs references netty directly. Replace grpc-netty-shaded (about 4 MB compressed in each jar) with grpc-okhttp. grpc-okhttp depends on okio 3.x, which is written in Kotlin and pulls in kotlin-stdlib (another 1.5 MB). Exclude it and use okio 1.17.6 (pure Java, 92 KB) instead: every okio method and field referenced by grpc-okhttp 1.85.0 exists in okio 1.17.6, which also has the fix for CVE-2023-3635. runtime-impl-jetty121.jar: 33.7 MB with netty -> 29.3 MB.
The runtime jars bundle grpc-okhttp with the pure Java okio 1.17.6. okio 2+ is written in Kotlin and needs kotlin-stdlib, which the runtime jars don't bundle (the shade artifactSet is an allowlist), so an okio upgrade would break the Cloud Tasks client at runtime. - Move the okio version to an okio.version property in the root pom. - Add a maven-enforcer requireProperty rule to the runtime_impl poms that fails the build, with an explanation, unless okio.version is 1.x. - Tell Dependabot to ignore okio >= 2.0.0. Majors are already ignored globally; this makes the okio case explicit. Mirror it in the (disabled) renovate.json.
73920f3 to
e8f9158
Compare
Stacked on #547 (base branch
cloudtasks-runtime-jar-session-test). Only the last commit is new; retarget tomainonce #547 is merged.Change
#547 bundles the Cloud Tasks client into
runtime_impl_jetty12/runtime_impl_jetty121, which grows each jar by about 10.4 MB.grpc-netty-shadedalone is about 4 MB compressed of that.Nothing in gax, gax-grpc, grpc-auth or the Cloud Tasks stubs references netty directly: the transport is found through the
io.grpc.ManagedChannelProviderSPI. So this PR:io.grpc:grpc-okhttp(version fromgrpc-bom) instead ofio.grpc:grpc-netty-shaded.META-INF/services/io.grpc.ManagedChannelProvidernow lists onlyio.grpc.okhttp.OkHttpChannelProvider.grpc-okhttp. okio 3 is written in Kotlin and pulls inkotlin-stdlib, about 1.5 MB compressed. Instead it usescom.squareup.okio:okio:1.17.6(pure Java, 92 KB, managed in the root pom).grpc-netty-shadedMETA-INF/native/**filter.okio 1.17.6 compatibility
grpc-java upstream builds
grpc-okhttpagainst okio 3, so this is an unsupported combination. I checked it at the bytecode level: every okio method and field referenced bygrpc-okhttp-1.85.0.jar(61 members ofBuffer,BufferedSink,BufferedSource,ByteString,Okio,Sink,Source,Timeout) exists in okio 1.17.6. okio 1.17.6 includes the fix for CVE-2023-3635. A futuregrpc-okhttpupgrade could start using an okio 3-only API;CloudTasksSessionTestwould then fail with a class loading error. This is guarded so an automatic update can't bring Kotlin back (see Keeping okio on 1.x below).Keeping okio on 1.x
okio.version(root pom) holds the pinned version. Amaven-enforcerrequirePropertyrule in both runtime_impl poms fails the build unless it is 1.x, with a message explaining why. Withokio.version=3.4.0the build fails: okio.version must stay 1.x: the runtime jar bundles grpc-okhttp with the pure Java okio 1.x, while okio 2+ is written in Kotlin and needs kotlin-stdlib, which this jar does not bundle..github/dependabot.ymlignorescom.squareup.okio:okio>= 2.0.0. Majors are already ignored globally; this entry makes the okio case explicit and survives a change to that global rule. The same is mirrored in the (disabled)renovate.json.bannedDependencieswas not used: maven-enforcer's dependency collection skips optional dependencies, and all dependencies of the runtime_impl poms are optional, so it never saw okio or Kotlin.Size (
mvn package, JDK 25)runtime-impl-jetty121.jarmainmainruntime-impl-jetty12.jar: 23.1 → 33.5 (#547) → 29.1 MB. The increase overmaindrops by about 43%, saving about 4.4 MB per jar and about 8.9 MB across the runtime deployment.Testing
JDK 25, Jetty 12.1 EE8/EE11:
CloudTasksSessionTest2/2 andJavaRuntimeAllInOneTest12/12 pass. NoClassNotFoundException/NoClassDefFoundErrorappears. All Cloud Tasks calls from the runtime receivedPERMISSION_DENIED: Permission denied on resource project 1fromcloudtasks.googleapis.com, so TLS and HTTP/2 over okhttp work. Netty is no longer in the jars.