Skip to content

Commit 8e75b89

Browse files
authored
Merge branch 'main' into exp-histo-topn
2 parents 6906c53 + c751961 commit 8e75b89

File tree

784 files changed

+22378
-8330
lines changed

Some content is hidden

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

784 files changed

+22378
-8330
lines changed

.buildkite/pipelines/periodic-packaging.template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ steps:
1818
- rocky-9
1919
- rhel-8
2020
- rhel-9
21+
- rhel-10
2122
- almalinux-8
2223
- almalinux-9
2324
agents:

.buildkite/pipelines/periodic-packaging.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ steps:
1919
- rocky-9
2020
- rhel-8
2121
- rhel-9
22+
- rhel-10
2223
- almalinux-8
2324
- almalinux-9
2425
agents:

.buildkite/pipelines/periodic-platform-support.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ steps:
1818
- rocky-9
1919
- rhel-8
2020
- rhel-9
21+
- rhel-10
2122
- almalinux-8
2223
- almalinux-9
2324
agents:

.buildkite/pipelines/pull-request/packaging-tests-unix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ steps:
2121
- rocky-9
2222
- rhel-8
2323
- rhel-9
24+
- rhel-10
2425
- almalinux-8
2526
- almalinux-9
2627
PACKAGING_TASK:

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/transport/TransportVersionGenerationFuncTest.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,4 +513,19 @@ class TransportVersionGenerationFuncTest extends AbstractTransportVersionFuncTes
513513
assertGenerateAndValidateSuccess(result)
514514
assertUpperBound("9.2", "existing_92,8123000")
515515
}
516+
517+
def "generation cannot run on release branch"() {
518+
given:
519+
file("myserver/build.gradle") << """
520+
tasks.named('generateTransportVersion') {
521+
currentUpperBoundName = '9.1'
522+
}
523+
"""
524+
525+
when:
526+
def result = runGenerateTask().buildAndFail()
527+
528+
then:
529+
assertGenerateFailure(result, "Transport version generation cannot run on release branches")
530+
}
516531
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.Arrays;
4949
import java.util.List;
5050
import java.util.Optional;
51+
import java.util.concurrent.TimeUnit;
5152

5253
import javax.inject.Inject;
5354

@@ -199,7 +200,11 @@ public void execute(BuildFinishedFlowAction.Parameters parameters) throws FileNo
199200
try {
200201
// we are very generious here, as the upload can take
201202
// a long time depending on its size
202-
pb.start().waitFor(30, java.util.concurrent.TimeUnit.MINUTES);
203+
long timeoutSec = calculateUploadWaitTimeoutSeconds(uploadFile);
204+
boolean completedInTime = pb.start().waitFor(timeoutSec, TimeUnit.SECONDS);
205+
if (completedInTime == false) {
206+
System.out.println("Timed out waiting for buildkite artifact upload after " + timeoutSec + " seconds");
207+
}
203208
} catch (InterruptedException e) {
204209
System.out.println("Failed to upload buildkite artifact " + e.getMessage());
205210
}
@@ -304,5 +309,14 @@ private static String calculateArchivePath(Path path, Path projectPath) {
304309
}
305310
return archivePath;
306311
}
312+
313+
private static long calculateUploadWaitTimeoutSeconds(File file) {
314+
long fileSizeBytes = file.length();
315+
long fileSizeMB = fileSizeBytes / (1024 * 1024);
316+
317+
// Allocate 4 seconds per MB (assumes ~250 KB/s upload speed)
318+
// with min 10 seconds and max 30 minutes
319+
return Math.max(10, Math.min(1800, fileSizeMB * 4));
320+
}
307321
}
308322
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ public abstract class GenerateTransportVersionDefinitionTask extends DefaultTask
9696
@TaskAction
9797
public void run() throws IOException {
9898
TransportVersionResourcesService resources = getResourceService().get();
99+
List<TransportVersionUpperBound> upstreamUpperBounds = resources.getUpperBoundsFromGitBase();
100+
boolean onReleaseBranch = resources.checkIfDefinitelyOnReleaseBranch(upstreamUpperBounds, getCurrentUpperBoundName().get());
101+
if (onReleaseBranch) {
102+
throw new IllegalArgumentException("Transport version generation cannot run on release branches");
103+
}
104+
99105
Set<String> referencedNames = TransportVersionReference.collectNames(getReferencesFiles());
100106
Set<String> changedDefinitionNames = resources.getChangedReferableDefinitionNames();
101107
String targetDefinitionName = getTargetDefinitionName(resources, referencedNames, changedDefinitionNames);
@@ -109,7 +115,7 @@ public void run() throws IOException {
109115
resetAllUpperBounds(resources, idsByBase);
110116
} else {
111117
getLogger().lifecycle("Generating transport version name: " + targetDefinitionName);
112-
List<TransportVersionUpperBound> upstreamUpperBounds = resources.getUpperBoundsFromGitBase();
118+
113119
Set<String> targetUpperBoundNames = getTargetUpperBoundNames(resources, upstreamUpperBounds, targetDefinitionName);
114120

115121
List<TransportVersionId> ids = updateUpperBounds(

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.nio.file.Files;
2626
import java.nio.file.Path;
2727
import java.util.ArrayList;
28+
import java.util.Collection;
2829
import java.util.Collections;
2930
import java.util.Comparator;
3031
import java.util.HashMap;
@@ -259,6 +260,20 @@ private Path getUpperBoundRelativePath(String name) {
259260
return UPPER_BOUNDS_DIR.resolve(name + ".csv");
260261
}
261262

263+
boolean checkIfDefinitelyOnReleaseBranch(Collection<TransportVersionUpperBound> upperBounds, String currentUpperBoundName) {
264+
// only want to look at definitions <= the current upper bound.
265+
// TODO: we should filter all of the upper bounds/definitions that are validated by this, not just in this method
266+
TransportVersionUpperBound currentUpperBound = upperBounds.stream()
267+
.filter(u -> u.name().equals(currentUpperBoundName))
268+
.findFirst()
269+
.orElse(null);
270+
if (currentUpperBound == null) {
271+
// since there is no current upper bound, we don't know if we are on a release branch
272+
return false;
273+
}
274+
return upperBounds.stream().anyMatch(u -> u.definitionId().complete() > currentUpperBound.definitionId().complete());
275+
}
276+
262277
private String getBaseRefName() {
263278
if (baseRefName.get() == null) {
264279
synchronized (baseRefName) {

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void validateTransportVersions() throws IOException {
8484
Map<Integer, List<IdAndDefinition>> idsByBase = resources.getIdsByBase();
8585
Map<String, TransportVersionUpperBound> upperBounds = resources.getUpperBounds();
8686
TransportVersionUpperBound currentUpperBound = upperBounds.get(getCurrentUpperBoundName().get());
87-
boolean onReleaseBranch = checkIfDefinitelyOnReleaseBranch(upperBounds);
87+
boolean onReleaseBranch = resources.checkIfDefinitelyOnReleaseBranch(upperBounds.values(), getCurrentUpperBoundName().get());
8888
boolean validateModifications = onReleaseBranch == false || getCI().get();
8989

9090
for (var definition : referableDefinitions.values()) {
@@ -330,15 +330,6 @@ private void validatePrimaryIds(
330330
);
331331
}
332332

333-
private boolean checkIfDefinitelyOnReleaseBranch(Map<String, TransportVersionUpperBound> upperBounds) {
334-
// only want to look at definitions <= the current upper bound.
335-
// TODO: we should filter all of the upper bounds/definitions that are validated by this, not just in this method
336-
String currentUpperBoundName = getCurrentUpperBoundName().get();
337-
TransportVersionUpperBound currentUpperBound = upperBounds.get(currentUpperBoundName);
338-
339-
return upperBounds.values().stream().anyMatch(u -> u.definitionId().complete() > currentUpperBound.definitionId().complete());
340-
}
341-
342333
private void throwDefinitionFailure(TransportVersionDefinition definition, String message) {
343334
Path relativePath = getResources().get().getDefinitionPath(definition);
344335
throw new VerificationException("Transport version definition file [" + relativePath + "] " + message);

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/MockApmServer.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
package org.elasticsearch.gradle.testclusters;
1111

12+
import com.fasterxml.jackson.databind.JsonNode;
1213
import com.fasterxml.jackson.databind.ObjectMapper;
1314
import com.fasterxml.jackson.databind.node.ObjectNode;
15+
import com.fasterxml.jackson.databind.util.LRUMap;
16+
import com.fasterxml.jackson.databind.util.LookupCache;
1417
import com.sun.net.httpserver.HttpExchange;
1518
import com.sun.net.httpserver.HttpHandler;
1619
import com.sun.net.httpserver.HttpServer;
@@ -28,7 +31,9 @@
2831
import java.io.InputStreamReader;
2932
import java.io.OutputStream;
3033
import java.net.InetSocketAddress;
34+
import java.util.ArrayList;
3135
import java.util.Arrays;
36+
import java.util.List;
3237
import java.util.regex.Pattern;
3338
import java.util.stream.Collectors;
3439

@@ -48,6 +53,8 @@
4853
public class MockApmServer {
4954
private static final Logger logger = Logging.getLogger(MockApmServer.class);
5055
private static final org.slf4j.Logger log = LoggerFactory.getLogger(MockApmServer.class);
56+
private static final LookupCache<String, String> transactionCache = new LRUMap(16, 16);
57+
5158
private final Pattern metricFilter;
5259
private final Pattern transactionFilter;
5360
private final Pattern transactionExcludesFilter;
@@ -136,22 +143,28 @@ private void logFiltered(InputStream body) throws IOException {
136143
ObjectMapper mapper = new ObjectMapper();
137144
try (BufferedReader reader = new BufferedReader(new InputStreamReader(body))) {
138145
String line;
139-
String tier = null;
140-
String node = null;
146+
String nodeMetadata = null;
147+
148+
List<JsonNode> spans = new ArrayList<>();
141149

142150
while ((line = reader.readLine()) != null) {
143151
var jsonNode = mapper.readTree(line);
144152

145153
if (jsonNode.has("metadata")) {
146-
node = jsonNode.path("metadata").path("service").path("node").path("configured_name").asText(null);
147-
tier = jsonNode.path("metadata").path("labels").path("node_tier").asText(null);
154+
nodeMetadata = jsonNode.path("metadata").path("service").path("node").path("configured_name").asText(null);
155+
var tier = jsonNode.path("metadata").path("labels").path("node_tier").asText(null);
156+
nodeMetadata += tier != null ? "/" + tier : "";
157+
148158
} else if (transactionFilter != null && jsonNode.has("transaction")) {
149159
var transaction = jsonNode.get("transaction");
150160
var name = transaction.get("name").asText();
151161
if (transactionFilter.matcher(name).matches()
152162
&& (transactionExcludesFilter == null || transactionExcludesFilter.matcher(name).matches() == false)) {
153-
logger.lifecycle("Transaction [{}/{}]: {}", node, tier, transaction);
163+
transactionCache.put(transaction.get("id").asText(), name);
164+
logger.lifecycle("Transaction {} [{}]: {}", name, nodeMetadata, transaction);
154165
}
166+
} else if (jsonNode.has("span")) {
167+
spans.add(jsonNode.get("span")); // make sure to record all transactions first
155168
} else if (metricFilter != null && jsonNode.has("metricset")) {
156169
var metricset = jsonNode.get("metricset");
157170
var samples = (ObjectNode) metricset.get("samples");
@@ -161,10 +174,20 @@ private void logFiltered(InputStream body) throws IOException {
161174
}
162175
}
163176
if (samples.isEmpty() == false) {
164-
logger.lifecycle("Metricset [{}/{}]", node, tier, metricset);
177+
logger.lifecycle("Metricset [{}]: {}", nodeMetadata, metricset);
165178
}
166179
}
167180
}
181+
182+
// emit only spans for previously matched transactions using the transaction cache
183+
for (var span : spans) {
184+
var name = span.get("name").asText();
185+
var transactionId = span.get("transaction_id").asText();
186+
var transactionName = transactionCache.get(transactionId);
187+
if (transactionName != null) {
188+
logger.lifecycle("Span {} of {} [{}]: {}", name, transactionName, nodeMetadata, span);
189+
}
190+
}
168191
}
169192
}
170193
}

0 commit comments

Comments
 (0)