-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix reproducability of builds against Java EA versions #132847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Pinging @elastic/es-delivery (Team:Delivery) |
| import static org.gradle.platform.Architecture.X86_64 | ||
| import static org.gradle.platform.OperatingSystem.* | ||
|
|
||
| class EarlyAccessCatalogJdkToolchainResolverSpec extends AbstractToolchainResolverSpec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not set active for now.
|
|
||
| classpath = sourceSets.main.runtimeClasspath | ||
| mainClass = 'org.elasticsearch.jdk.patch.ImmutableCollectionsPatcher' | ||
| if (buildParams.getIsRuntimeJavaHomeSet()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should not use the runtime jdk but whatever we use for compiling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we use the runtime jdk because it's trying to match what we will actually run with (it's just for use with tests after all).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one issue I faced with this was that the asm patcher failed due to unexpected class file version 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the patcher relies on looking at implementation class details within the jdk itself. So I think the runtime jdk is correct, the classes we patch won't necessarily be the same with the compile jdk, we want to actually patch the classes that we are about to run with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it back. I guess we need an asm update here? https://gradle-enterprise.elastic.co/s/biwfet3luxnxe/console-log/task/:test:immutable-collections-patch:generatePatch?anchor=5&page=1
|
|
||
| To test an unreleased development version of a third party dependency you have several options. | ||
|
|
||
| ### How do I test against java early access (ea) versions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try maintaining a good FAQ here :D
67b1e66 to
8cfd01c
Compare
rjernst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good. I just wonder why we are adding a toolchain resolver if we aren't actually using it.
| Integer runtimeJavaProperty = Integer.getInteger("runtime.java"); | ||
| if (runtimeJavaProperty != null) { | ||
| return resolveJavaHomeFromToolChainService(runtimeJavaProperty); | ||
| if (runtimeJavaProperty > Integer.parseInt(VersionProperties.getBundledJdkMajorVersion())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't necessarily true, eg right now we want to try to run with JDK 25 RC builds, this version is grearter than the bundled, but it's not an EA.
Could we instead have runtime.java take in eg 26-ea and we detect and parse out the -ea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah interesting. yeah we could do something like that. I'll take a look. Are there RCs of upcoming java versions available already we can test against the behavior of resolving RCs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java 25 has RCs available right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| NamedDomainObjectContainer<Jdk> container = project.getPlugins().apply(JdkDownloadPlugin.class).getContainer(project); | ||
| Integer buildNumber = Integer.getInteger("runtime.java.build"); | ||
| if (buildNumber == null) { | ||
| buildNumber = Integer.getInteger("runtime.java." + runtimeJavaProperty + ".build"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we would have multiple simultaneous build numbers? Could we get by with just runtime.java.build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, lets decide on a single convention here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
gradle/verification-metadata.xml
Outdated
| <trust group="beats" name="metricbeat-fips"/> | ||
| <trust group="elasticsearch-distribution" name="elasticsearch"/> | ||
| <trust group="openjdk_25"/> | ||
| <trust group="openjdk_26"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will we need to add this for every new major version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so atm. I don't see regex working here. I'm hopeful gradle has a better solution by reaching 27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the docs say regex is supported like so:
<trust group="^com[.]mycompany($|([.].*))" regex="true" reason="We trust all mycompany artifacts"/>https://docs.gradle.org/current/userguide/dependency_verification.html#sec:trusting-artifacts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah. fixed.
|
|
||
| classpath = sourceSets.main.runtimeClasspath | ||
| mainClass = 'org.elasticsearch.jdk.patch.ImmutableCollectionsPatcher' | ||
| if (buildParams.getIsRuntimeJavaHomeSet()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we use the runtime jdk because it's trying to match what we will actually run with (it's just for use with tests after all).
| * this only supports resolving the latest early access build for a given language version. | ||
| * <p> | ||
| */ | ||
| public abstract class EarlyAccessCatalogJdkToolchainResolver extends AbstractCustomJavaToolchainResolver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here if we aren't going to use the toolchains?
it resolves the latest availble EA version. I wanted to keep it and have it tested as we come back to this. also I removed the EA support from the default oracle provider. we test this one though we don't use it so it should keep working. |
8fce476 to
14255a2
Compare
| } | ||
|
|
||
| private Provider<File> resolveEarlyAccessJavaHome(Integer runtimeJavaProperty) { | ||
| NamedDomainObjectContainer<Jdk> container = project.getPlugins().apply(JdkDownloadPlugin.class).getContainer(project); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applying the plugin like this seems wrong but maybe my spidey sense is tingling here for no good reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah feeling dirty. fixed it :D
| NamedDomainObjectContainer<Jdk> container = project.getPlugins().apply(JdkDownloadPlugin.class).getContainer(project); | ||
| Integer buildNumber = Integer.getInteger("runtime.java.build"); | ||
| if (buildNumber == null) { | ||
| buildNumber = Integer.getInteger("runtime.java." + runtimeJavaProperty + ".build"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, lets decide on a single convention here.
gradle/verification-metadata.xml
Outdated
| <trust group="beats" name="metricbeat-fips"/> | ||
| <trust group="elasticsearch-distribution" name="elasticsearch"/> | ||
| <trust group="openjdk_25"/> | ||
| <trust group="openjdk_26"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the docs say regex is supported like so:
<trust group="^com[.]mycompany($|([.].*))" regex="true" reason="We trust all mycompany artifacts"/>https://docs.gradle.org/current/userguide/dependency_verification.html#sec:trusting-artifacts
d241b51 to
1a0cd1c
Compare
This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin.
explicitly requires to add a ea postfix to the runtime sys property
1a0cd1c to
487a053
Compare
💔 Backport failed
You can use sqren/backport to manually backport by running |
* Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup
* Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup (cherry picked from commit 16fe7db) # Conflicts: # BUILDING.md
* Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup (cherry picked from commit 16fe7db) # Conflicts: # BUILDING.md # build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/JdkDownloadPluginFuncTest.groovy
* Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup (cherry picked from commit 16fe7db) # Conflicts: # BUILDING.md # build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/JdkDownloadPluginFuncTest.groovy
…2974) * Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup
* Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup (cherry picked from commit 16fe7db) # Conflicts: # BUILDING.md # build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/JdkDownloadPluginFuncTest.groovy # build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/toolchain/OracleOpenJdkToolchainResolver.java # build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/toolchain/OracleOpenJdkToolchainResolverSpec.groovy # test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
…-stats * upstream/main: (36 commits) Fix reproducability of builds against Java EA versions (elastic#132847) Speed up loading keyword fields with index sorts (elastic#132950) Mute org.elasticsearch.index.mapper.LongFieldMapperTests testSyntheticSourceWithTranslogSnapshot elastic#132964 Simplify EsqlSession (elastic#132848) Implement WriteLoadConstraintDecider#canAllocate (elastic#132041) Mute org.elasticsearch.test.rest.yaml.CcsCommonYamlTestSuiteIT test {p0=search/400_synthetic_source/_doc_count} elastic#132965 Switch to PR-based benchmark pipeline defined in ES repo (elastic#132941) Breakdown undesired allocations by shard routing role (elastic#132235) Implement v_magnitude function (elastic#132765) Introduce execution location marker for better handling of remote/local compatibility (elastic#132205) Mute org.elasticsearch.cluster.ClusterInfoServiceIT testMaxQueueLatenciesInClusterInfo elastic#132957 Unmuting simulate index data stream mapping overrides yaml rest test (elastic#132946) Remove CrossClusterCancellationIT.createLocalIndex() (elastic#132952) Mute org.elasticsearch.index.mapper.LongFieldMapperTests testFetch elastic#132956 Fix failing UT by adding a required capability (elastic#132947) Precompute the BitsetCacheKey hashCode (elastic#132875) Adding simulate ingest effective mapping (elastic#132833) Mute org.elasticsearch.index.mapper.LongFieldMapperTests testFetchMany elastic#132948 Rename skipping logic to remove hard link to skip_unavailable (elastic#132861) Store ignored source in unique stored fields per entry (elastic#132142) ...
…2975) * Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup (cherry picked from commit 16fe7db) # Conflicts: # BUILDING.md
… (#132978) * Fix reproducability of builds against Java EA versions (#132847) * Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup (cherry picked from commit 16fe7db) # Conflicts: # BUILDING.md # build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/JdkDownloadPluginFuncTest.groovy * Fix jdkdownload tests
… (#132979) * Fix reproducability of builds against Java EA versions (#132847) * Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup (cherry picked from commit 16fe7db) # Conflicts: # BUILDING.md # build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/JdkDownloadPluginFuncTest.groovy # build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/toolchain/OracleOpenJdkToolchainResolver.java # build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/toolchain/OracleOpenJdkToolchainResolverSpec.groovy # test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java * Fix merge issues
… (#132977) * Fix reproducability of builds against Java EA versions (#132847) * Introduce dedicated toolchain resolver for EA java versions * Fix reproducability of builds against Java EA versions This fixes a reproducability issue when using the gradle javaToolChain api. There is no way to test toolchain candidates reliable against the build number in use. This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection does not detect the difference between certain builds (or even ea vs. released version) Therefore we fallback to rely on our custom JDKDownloadPlugin for now here. Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution ones something is available. Ultimately we want to get rid of usages of the JDK download plugin. * Minor cleanup and fixing non set distribution type in jdk * Fix ea jdk selection not just based on major version explicitly requires to add a ea postfix to the runtime sys property * Fix test reproduce linies when using java ea version * Apply review feedback * Use runtime jdk when patching * More cleanup (cherry picked from commit 16fe7db) # Conflicts: # BUILDING.md # build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/JdkDownloadPluginFuncTest.groovy * Fix jdkdownload tests
This fixes a reproducability issue when using the gradle javaToolChain api.
There is no way to test toolchain candidates reliable against the build number in use.
This meant that ones you e.g. have resolved some version of java 25, gradle toolchain detection
does not detect the difference between certain builds (or even ea vs. released version)
Therefore we fallback to rely on our custom JDKDownloadPlugin for now here.
Syncing with the gradle team, they want to fix this somewhen in 9.x. We will revisit our solution
ones something is available. Ultimately we want to get rid of usages of the JDK download plugin.