Skip to content

Commit 7fc6dc2

Browse files
committed
Merge remote-tracking branch 'elastic/master' into pr/36141
* elastic/master: (36 commits) Add check for minimum required Docker version (elastic#36497) Minor search controller changes (elastic#36479) Add default methods to DocValueFormat (elastic#36480) Fix the mixed cluster REST test explain/11_basic_with_types. Modify `BigArrays` to take name of circuit breaker (elastic#36461) Move LoggedExec to minimumRuntime source set (elastic#36453) added 6.5.4 version Add test logging for elastic#35644 Tests- added helper methods to ESRestTestCase for checking warnings (elastic#36443) SQL: move requests' parameters to requests JSON body (elastic#36149) [Zen2] Respect the no_master_block setting (elastic#36478) Require soft-deletes when access changes snapshot (elastic#36446) Switch more tests to zen2 (elastic#36367) [Painless] Add extensive tests for def to primitive casts (elastic#36455) Add setting to bypass Rollover action (elastic#36235) Try running CI against Zulu (elastic#36391) [DOCS] Reworked the shard allocation filtering info. (elastic#36456) Log [initial_master_nodes] on formation failure (elastic#36466) converting ForbiddenPatternsTask to .java (elastic#36194) fixed typo ...
2 parents 18c42ec + f2e18a6 commit 7fc6dc2

File tree

485 files changed

+5426
-2282
lines changed

Some content is hidden

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

485 files changed

+5426
-2282
lines changed

.ci/matrix-runtime-javas.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ ES_RUNTIME_JAVA:
99
- java8
1010
- java8fips
1111
- java11
12+
- zulu8
13+
- zulu11

buildSrc/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ dependencies {
9595
}
9696
minimumRuntimeCompile "junit:junit:${props.getProperty('junit')}"
9797
minimumRuntimeCompile localGroovy()
98+
minimumRuntimeCompile gradleApi()
9899
}
99100
jar {
100101
from sourceSets.minimumRuntime.output
@@ -217,7 +218,7 @@ if (project != rootProject) {
217218
forbiddenPatterns {
218219
exclude '**/*.wav'
219220
// the file that actually defines nocommit
220-
exclude '**/ForbiddenPatternsTask.groovy'
221+
exclude '**/ForbiddenPatternsTask.java'
221222
}
222223

223224
namingConventions {

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 58 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import org.gradle.util.GradleVersion
5757
import java.nio.charset.StandardCharsets
5858
import java.time.ZoneOffset
5959
import java.time.ZonedDateTime
60+
import java.util.regex.Matcher
6061

6162
/**
6263
* Encapsulates build configuration for elasticsearch projects.
@@ -245,9 +246,16 @@ class BuildPlugin implements Plugin<Project> {
245246
*
246247
* If either of these fail, we fail the build.
247248
*/
249+
250+
// check if the Docker binary exists and record its path
251+
final List<String> maybeDockerBinaries = ['/usr/bin/docker', '/usr/local/bin/docker']
252+
final String dockerBinary = maybeDockerBinaries.find { it -> new File(it).exists() }
253+
248254
final boolean buildDocker
249255
final String buildDockerProperty = System.getProperty("build.docker")
250-
if (buildDockerProperty == null || buildDockerProperty == "true") {
256+
if (buildDockerProperty == null) {
257+
buildDocker = dockerBinary != null
258+
} else if (buildDockerProperty == "true") {
251259
buildDocker = true
252260
} else if (buildDockerProperty == "false") {
253261
buildDocker = false
@@ -258,60 +266,68 @@ class BuildPlugin implements Plugin<Project> {
258266
rootProject.rootProject.ext.buildDocker = buildDocker
259267
rootProject.rootProject.ext.requiresDocker = []
260268
rootProject.gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
261-
// check if the Docker binary exists and record its path
262-
final List<String> maybeDockerBinaries = ['/usr/bin/docker', '/usr/local/bin/docker']
263-
final String dockerBinary = maybeDockerBinaries.find { it -> new File(it).exists() }
264-
265-
int exitCode
266-
String dockerErrorOutput
267-
if (dockerBinary == null) {
268-
exitCode = -1
269-
dockerErrorOutput = null
270-
} else {
271-
// the Docker binary executes, check that we can execute a privileged command
272-
final ByteArrayOutputStream output = new ByteArrayOutputStream()
273-
final ExecResult result = LoggedExec.exec(rootProject, { ExecSpec it ->
274-
it.commandLine dockerBinary, "images"
275-
it.errorOutput = output
276-
it.ignoreExitValue = true
277-
})
278-
if (result.exitValue == 0) {
279-
return
280-
}
281-
exitCode = result.exitValue
282-
dockerErrorOutput = output.toString()
283-
}
284269
final List<String> tasks =
285270
((List<Task>)rootProject.requiresDocker).findAll { taskGraph.hasTask(it) }.collect { " ${it.path}".toString()}
286271
if (tasks.isEmpty() == false) {
287272
/*
288273
* There are tasks in the task graph that require Docker. Now we are failing because either the Docker binary does not
289274
* exist or because execution of a privileged Docker command failed.
290275
*/
291-
String message
292276
if (dockerBinary == null) {
293-
message = String.format(
277+
final String message = String.format(
294278
Locale.ROOT,
295279
"Docker (checked [%s]) is required to run the following task%s: \n%s",
296280
maybeDockerBinaries.join(","),
297281
tasks.size() > 1 ? "s" : "",
298282
tasks.join('\n'))
299-
} else {
300-
assert exitCode > 0 && dockerErrorOutput != null
301-
message = String.format(
283+
throwDockerRequiredException(message)
284+
}
285+
286+
// we use a multi-stage Docker build, check the Docker version since 17.05
287+
final ByteArrayOutputStream dockerVersionOutput = new ByteArrayOutputStream()
288+
LoggedExec.exec(
289+
rootProject,
290+
{ ExecSpec it ->
291+
it.commandLine = [dockerBinary, '--version']
292+
it.standardOutput = dockerVersionOutput
293+
})
294+
final String dockerVersion = dockerVersionOutput.toString().trim()
295+
final Matcher matcher = dockerVersion =~ /Docker version (\d+\.\d+)\.\d+(?:-ce)?, build [0-9a-f]{7}/
296+
assert matcher.matches() : dockerVersion
297+
final dockerMajorMinorVersion = matcher.group(1)
298+
final String[] majorMinor = dockerMajorMinorVersion.split("\\.")
299+
if (Integer.parseInt(majorMinor[0]) < 17
300+
|| (Integer.parseInt(majorMinor[0]) == 17 && Integer.parseInt(majorMinor[1]) < 5)) {
301+
final String message = String.format(
302+
Locale.ROOT,
303+
"building Docker images requires Docker version 17.05+ due to use of multi-stage builds yet was [%s]",
304+
dockerVersion)
305+
throwDockerRequiredException(message)
306+
}
307+
308+
final ByteArrayOutputStream dockerImagesErrorOutput = new ByteArrayOutputStream()
309+
// the Docker binary executes, check that we can execute a privileged command
310+
final ExecResult dockerImagesResult = LoggedExec.exec(
311+
rootProject,
312+
{ ExecSpec it ->
313+
it.commandLine = [dockerBinary, "images"]
314+
it.errorOutput = dockerImagesErrorOutput
315+
it.ignoreExitValue = true
316+
})
317+
318+
if (dockerImagesResult.exitValue != 0) {
319+
final String message = String.format(
302320
Locale.ROOT,
303321
"a problem occurred running Docker from [%s] yet it is required to run the following task%s: \n%s\n" +
304322
"the problem is that Docker exited with exit code [%d] with standard error output [%s]",
305323
dockerBinary,
306324
tasks.size() > 1 ? "s" : "",
307325
tasks.join('\n'),
308-
exitCode,
309-
dockerErrorOutput.trim())
326+
dockerImagesResult.exitValue,
327+
dockerImagesErrorOutput.toString().trim())
328+
throwDockerRequiredException(message)
310329
}
311-
throw new GradleException(
312-
message + "\nyou can address this by attending to the reported issue, "
313-
+ "removing the offending tasks from being executed, "
314-
+ "or by passing -Dbuild.docker=false")
330+
315331
}
316332
}
317333
}
@@ -322,6 +338,13 @@ class BuildPlugin implements Plugin<Project> {
322338
}
323339
}
324340

341+
private static void throwDockerRequiredException(final String message) {
342+
throw new GradleException(
343+
message + "\nyou can address this by attending to the reported issue, "
344+
+ "removing the offending tasks from being executed, "
345+
+ "or by passing -Dbuild.docker=false")
346+
}
347+
325348
private static String findCompilerJavaHome() {
326349
String compilerJavaHome = System.getenv('JAVA_HOME')
327350
final String compilerJavaProperty = System.getProperty('compiler.java')

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.groovy

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)