-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Make it possible to use Stack logging in Docker #65778
Changes from 13 commits
f0b1243
a978be7
74ab274
580bc0b
288ac14
044929f
2520719
9f31d88
e2e9b47
ab73850
96536fd
d1bb242
6cff1aa
bfc4748
b9c420a
199a550
4d120f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,33 @@ configurations { | |
dockerSource | ||
aarch64OssDockerSource | ||
ossDockerSource | ||
transformLog4jJar | ||
} | ||
|
||
dependencies { | ||
aarch64DockerSource project(path: ":distribution:archives:linux-aarch64-tar", configuration:"default") | ||
dockerSource project(path: ":distribution:archives:linux-tar", configuration:"default") | ||
aarch64OssDockerSource project(path: ":distribution:archives:oss-linux-aarch64-tar", configuration:"default") | ||
ossDockerSource project(path: ":distribution:archives:oss-linux-tar", configuration:"default") | ||
transformLog4jJar project(path: ":distribution:docker:transform-log4j-config", configuration: "default") | ||
} | ||
|
||
/** | ||
* Used in the Dockerfile template to wrap commands in a retry loop. It can't be | ||
* a closure because Gradle can't effectively cache those. | ||
*/ | ||
class Retry { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general I'm in favour to have class definitions living in buildSrc somewhere no matter how small they are. To keep our build scripts a bit cleaner and smaller. Also these classes should change less often than the script itself. |
||
static String loop(name, command, indentSize = 4, exitKeyword = 'exit') { | ||
String indent = ' ' * indentSize | ||
String commandWithRetry = """for iter in {1..10}; do | ||
${indent} ${command} && | ||
${indent} exit_code=0 && break || | ||
${indent} exit_code=\$? && echo "${name} error: retry \$iter in 10s" && sleep 10; | ||
${indent}done; | ||
${indent}${exitKeyword} \$exit_code""" | ||
|
||
return commandWithRetry.replaceAll(" *\n", " \\\\\n") | ||
} | ||
} | ||
|
||
ext.expansions = { Architecture architecture, boolean oss, DockerBase base, boolean local -> | ||
|
@@ -75,18 +95,6 @@ RUN curl --retry 8 -S -L \\ | |
|
||
def (major,minor) = VersionProperties.elasticsearch.split("\\.") | ||
|
||
def retry_loop = { name, command, indentSize = 4, exitKeyword = 'exit' -> | ||
String indent = ' ' * indentSize | ||
String commandWithRetry = """for iter in {1..10}; do | ||
${indent} ${command} && | ||
${indent} exit_code=0 && break || | ||
${indent} exit_code=\$? && echo "${name} error: retry \$iter in 10s" && sleep 10; | ||
${indent}done; | ||
${indent}${exitKeyword} \$exit_code""" | ||
|
||
return commandWithRetry.replaceAll(" *\n", " \\\\\n") | ||
} | ||
|
||
return [ | ||
'base_image' : base.getImage(), | ||
'bin_dir' : base == DockerBase.IRON_BANK ? 'scripts' : 'bin', | ||
|
@@ -100,7 +108,7 @@ ${indent}${exitKeyword} \$exit_code""" | |
'docker_base' : base.name().toLowerCase(), | ||
'version' : VersionProperties.elasticsearch, | ||
'major_minor_version' : "${major}.${minor}", | ||
'retry_loop' : retry_loop | ||
'retry' : Retry, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the , is too much here |
||
] | ||
} | ||
|
||
|
@@ -185,6 +193,10 @@ void addCopyDockerContextTask(Architecture architecture, boolean oss, DockerBase | |
|
||
with dockerBuildContext(architecture, oss, base, true) | ||
|
||
into(base == DockerBase.IRON_BANK ? 'scripts' : 'bin') { | ||
from configurations.transformLog4jJar | ||
} | ||
|
||
if (architecture == Architecture.AARCH64) { | ||
if (oss) { | ||
from configurations.aarch64OssDockerSource | ||
|
@@ -219,46 +231,6 @@ tasks.register("copyKeystore", Sync) { | |
} | ||
} | ||
|
||
tasks.register("checkSecurityAuditLayoutPatternIdentical") { | ||
// the two log4j2.properties files containing security audit configuration for archive and docker builds respectively | ||
def originalLog4j = project(":x-pack:plugin:core").file('src/main/config/log4j2.properties') | ||
def dockerLog4j = project.file("src/docker/config/log4j2.properties") | ||
inputs.files(originalLog4j, dockerLog4j) | ||
def patternPropertyKey = "appender.audit_rolling.layout.pattern" | ||
doLast { | ||
def coreLog4jProperties = new Properties() | ||
originalLog4j.withInputStream { input -> | ||
coreLog4jProperties.load(input) | ||
} | ||
|
||
if (false == coreLog4jProperties.containsKey(patternPropertyKey)) { | ||
throw new GradleException("The [${originalLog4j.getPath()}] file changed such that the layout pattern is not " + | ||
"referred to by the property named [${patternPropertyKey}]. Please update the task [${name}] " + | ||
"definition from project [${path}] to reflect the new name for the layout pattern property.") | ||
} | ||
|
||
def dockerLog4jProperties = new Properties() | ||
dockerLog4j.withInputStream { input -> | ||
dockerLog4jProperties.load(input) | ||
} | ||
|
||
if (false == dockerLog4jProperties.containsKey(patternPropertyKey)) { | ||
throw new GradleException("The [${dockerLog4j.getPath()}] file changed such that the layout pattern is not " + | ||
"referred to by the property named [${patternPropertyKey}]. Please update the task [${name}] " + | ||
"definition from project [${path}] to reflect the new name for the layout pattern property.") | ||
} | ||
|
||
if (false == coreLog4jProperties.getProperty(patternPropertyKey).equals(dockerLog4jProperties.getProperty(patternPropertyKey))) { | ||
throw new GradleException("The property value for the layout pattern [${patternPropertyKey}] is NOT identical " + | ||
"between the [${originalLog4j.getPath()}] and the [${dockerLog4j.getPath()}] files.") | ||
} | ||
} | ||
} | ||
|
||
tasks.named("precommit").configure { | ||
dependsOn 'checkSecurityAuditLayoutPatternIdentical' | ||
} | ||
|
||
elasticsearch_distributions { | ||
Architecture.values().each { eachArchitecture -> | ||
Flavor.values().each { distroFlavor -> | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apply plugin: 'elasticsearch.build' | ||
|
||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
testImplementation "junit:junit:${versions.junit}" | ||
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}" | ||
} | ||
|
||
tasks.named('jar').configure { | ||
manifest { | ||
attributes 'Main-Class': 'org.elasticsearch.transform.log4j.TransformLog4jConfig' | ||
} | ||
} | ||
|
||
// This tests depend on ES core | ||
disableTasks('forbiddenApisMain', 'forbiddenApisTest') | ||
|
||
tasks.named('testingConventions').configure { | ||
naming.clear() | ||
naming { | ||
Tests { | ||
baseClass 'junit.framework.TestCase' | ||
} | ||
} | ||
} | ||
|
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.
Can you elaborate what can't be cached here?