Skip to content

Commit 2b7cda9

Browse files
authored
Merge branch 'main' into test-assertions
2 parents 3ea67d3 + a3313a3 commit 2b7cda9

File tree

432 files changed

+12814
-6536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+12814
-6536
lines changed

.buildkite/pipelines/intake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ steps:
7676
ES_VERSION:
7777
- "9.0.0"
7878
ES_COMMIT:
79-
- "b2cc9d9b8f00ee621f93ddca07ea9c671aab1578" # update to match last commit before lucene bump
79+
- "10352e57d85505984582616e1e38530d3ec6ca59" # update to match last commit before lucene bump / head of combat-lucene-10-0-0
8080
agents:
8181
provider: gcp
8282
image: family/elasticsearch-ubuntu-2004

.buildkite/scripts/dra-update-staging.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ for BRANCH in "${BRANCHES[@]}"; do
3737

3838
if [[ "$SHOULD_TRIGGER" == "true" ]]; then
3939
if [[ "$BRANCH" == "9.0" ]]; then
40-
export VERSION_QUALIFIER="beta1"
40+
export VERSION_QUALIFIER="rc1"
4141
fi
4242
echo "Triggering DRA staging workflow for $BRANCH"
4343
cat << EOF | buildkite-agent pipeline upload

.buildkite/scripts/dra-workflow.trigger.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source .buildkite/scripts/branches.sh
88

99
for BRANCH in "${BRANCHES[@]}"; do
1010
if [[ "$BRANCH" == "9.0" ]]; then
11-
export VERSION_QUALIFIER="beta1"
11+
export VERSION_QUALIFIER="rc1"
1212
fi
1313

1414
INTAKE_PIPELINE_SLUG="elasticsearch-intake"

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DockerBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public enum DockerBase {
2222
// Chainguard based wolfi image with latest jdk
2323
// This is usually updated via renovatebot
2424
// spotless:off
25-
WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:ecd940be9f342ee6173397c48f3df5bb410e95000f8726fd01759b6c39b0beda",
25+
WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:d74b1fda6b7fee2c90b410df258e005c049e0672fe16d79d00e58f14fb69f90b",
2626
"-wolfi",
2727
"apk"
2828
),
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.gradle.internal.dependencies.patches.hdfs;
11+
12+
import org.gradle.api.artifacts.transform.CacheableTransform;
13+
import org.gradle.api.artifacts.transform.InputArtifact;
14+
import org.gradle.api.artifacts.transform.TransformAction;
15+
import org.gradle.api.artifacts.transform.TransformOutputs;
16+
import org.gradle.api.artifacts.transform.TransformParameters;
17+
import org.gradle.api.file.FileSystemLocation;
18+
import org.gradle.api.provider.Provider;
19+
import org.gradle.api.tasks.Classpath;
20+
import org.gradle.api.tasks.Input;
21+
import org.gradle.api.tasks.Optional;
22+
import org.jetbrains.annotations.NotNull;
23+
import org.objectweb.asm.ClassReader;
24+
import org.objectweb.asm.ClassVisitor;
25+
import org.objectweb.asm.ClassWriter;
26+
27+
import java.io.File;
28+
import java.io.FileOutputStream;
29+
import java.io.IOException;
30+
import java.io.InputStream;
31+
import java.util.Enumeration;
32+
import java.util.HashMap;
33+
import java.util.List;
34+
import java.util.Locale;
35+
import java.util.Map;
36+
import java.util.function.Function;
37+
import java.util.jar.JarEntry;
38+
import java.util.jar.JarFile;
39+
import java.util.jar.JarOutputStream;
40+
import java.util.regex.Pattern;
41+
42+
import static java.util.Map.entry;
43+
import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES;
44+
import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS;
45+
46+
@CacheableTransform
47+
public abstract class HdfsClassPatcher implements TransformAction<HdfsClassPatcher.Parameters> {
48+
49+
record JarPatchers(String artifactTag, Pattern artifactPattern, Map<String, Function<ClassWriter, ClassVisitor>> jarPatchers) {}
50+
51+
static final List<JarPatchers> allPatchers = List.of(
52+
new JarPatchers(
53+
"hadoop-common",
54+
Pattern.compile("hadoop-common-(?!.*tests)"),
55+
Map.ofEntries(
56+
entry("org/apache/hadoop/util/ShutdownHookManager.class", ShutdownHookManagerPatcher::new),
57+
entry("org/apache/hadoop/util/Shell.class", ShellPatcher::new),
58+
entry("org/apache/hadoop/security/UserGroupInformation.class", SubjectGetSubjectPatcher::new)
59+
)
60+
),
61+
new JarPatchers(
62+
"hadoop-client-api",
63+
Pattern.compile("hadoop-client-api.*"),
64+
Map.ofEntries(
65+
entry("org/apache/hadoop/util/ShutdownHookManager.class", ShutdownHookManagerPatcher::new),
66+
entry("org/apache/hadoop/util/Shell.class", ShellPatcher::new),
67+
entry("org/apache/hadoop/security/UserGroupInformation.class", SubjectGetSubjectPatcher::new),
68+
entry("org/apache/hadoop/security/authentication/client/KerberosAuthenticator.class", SubjectGetSubjectPatcher::new)
69+
)
70+
)
71+
);
72+
73+
interface Parameters extends TransformParameters {
74+
@Input
75+
@Optional
76+
List<String> getMatchingArtifacts();
77+
78+
void setMatchingArtifacts(List<String> matchingArtifacts);
79+
}
80+
81+
@Classpath
82+
@InputArtifact
83+
public abstract Provider<FileSystemLocation> getInputArtifact();
84+
85+
@Override
86+
public void transform(@NotNull TransformOutputs outputs) {
87+
File inputFile = getInputArtifact().get().getAsFile();
88+
89+
List<String> matchingArtifacts = getParameters().getMatchingArtifacts();
90+
List<JarPatchers> patchersToApply = allPatchers.stream()
91+
.filter(jp -> matchingArtifacts.contains(jp.artifactTag()) && jp.artifactPattern().matcher(inputFile.getName()).find())
92+
.toList();
93+
if (patchersToApply.isEmpty()) {
94+
outputs.file(getInputArtifact());
95+
} else {
96+
patchersToApply.forEach(patchers -> {
97+
System.out.println("Patching " + inputFile.getName());
98+
99+
Map<String, Function<ClassWriter, ClassVisitor>> jarPatchers = new HashMap<>(patchers.jarPatchers());
100+
File outputFile = outputs.file(inputFile.getName().replace(".jar", "-patched.jar"));
101+
102+
patchJar(inputFile, outputFile, jarPatchers);
103+
104+
if (jarPatchers.isEmpty() == false) {
105+
throw new IllegalArgumentException(
106+
String.format(
107+
Locale.ROOT,
108+
"error patching [%s] with [%s]: the jar does not contain [%s]",
109+
inputFile.getName(),
110+
patchers.artifactPattern().toString(),
111+
String.join(", ", jarPatchers.keySet())
112+
)
113+
);
114+
}
115+
});
116+
}
117+
}
118+
119+
private static void patchJar(File inputFile, File outputFile, Map<String, Function<ClassWriter, ClassVisitor>> jarPatchers) {
120+
try (JarFile jarFile = new JarFile(inputFile); JarOutputStream jos = new JarOutputStream(new FileOutputStream(outputFile))) {
121+
Enumeration<JarEntry> entries = jarFile.entries();
122+
while (entries.hasMoreElements()) {
123+
JarEntry entry = entries.nextElement();
124+
String entryName = entry.getName();
125+
// Add the entry to the new JAR file
126+
jos.putNextEntry(new JarEntry(entryName));
127+
128+
Function<ClassWriter, ClassVisitor> classPatcher = jarPatchers.remove(entryName);
129+
if (classPatcher != null) {
130+
byte[] classToPatch = jarFile.getInputStream(entry).readAllBytes();
131+
132+
ClassReader classReader = new ClassReader(classToPatch);
133+
ClassWriter classWriter = new ClassWriter(classReader, COMPUTE_FRAMES | COMPUTE_MAXS);
134+
classReader.accept(classPatcher.apply(classWriter), 0);
135+
136+
jos.write(classWriter.toByteArray());
137+
} else {
138+
// Read the entry's data and write it to the new JAR
139+
try (InputStream is = jarFile.getInputStream(entry)) {
140+
is.transferTo(jos);
141+
}
142+
}
143+
jos.closeEntry();
144+
}
145+
} catch (IOException ex) {
146+
throw new RuntimeException(ex);
147+
}
148+
}
149+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
package org.elasticsearch.hdfs.patch;
10+
package org.elasticsearch.gradle.internal.dependencies.patches.hdfs;
1111

1212
import org.objectweb.asm.MethodVisitor;
1313
import org.objectweb.asm.Opcodes;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
package org.elasticsearch.hdfs.patch;
10+
package org.elasticsearch.gradle.internal.dependencies.patches.hdfs;
1111

1212
import org.objectweb.asm.ClassVisitor;
1313
import org.objectweb.asm.ClassWriter;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
package org.elasticsearch.hdfs.patch;
10+
package org.elasticsearch.gradle.internal.dependencies.patches.hdfs;
1111

1212
import org.objectweb.asm.ClassVisitor;
1313
import org.objectweb.asm.ClassWriter;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
package org.elasticsearch.hdfs.patch;
10+
package org.elasticsearch.gradle.internal.dependencies.patches.hdfs;
1111

1212
import org.objectweb.asm.ClassVisitor;
1313
import org.objectweb.asm.ClassWriter;

build-tools-internal/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jna = 5.12.1
1717
netty = 4.1.115.Final
1818
commons_lang3 = 3.9
1919
google_oauth_client = 1.34.1
20-
awsv1sdk = 1.12.270
20+
awsv1sdk = 1.12.746
2121
awsv2sdk = 2.28.13
2222
reactive_streams = 1.0.4
2323

0 commit comments

Comments
 (0)