Skip to content

Commit b5de207

Browse files
[8.19] (backport #18181) Remove redundant testing and circular dependency from docker acceptance testing (#18252)
* Remove redundant testing and circular dependency from docker acceptance testing (#18181) * Use locally build artifact to build container from public dockerfile Previously we would build an image (which would not actually be used), build dockerfiles, modify dockerfiles to curl from `https://snapshots.elastic.co/downloads/logstash'` then build the image used for testing based on the modified dockerfile. This resulted in testing the last published image to `snapshots`. This presents two problems 1. The test is running against the last published image (not the tip of the branch being tested) 2. this carries a dependency on both a DRA and unified stack release having been run. Therefor acceptance tests will fail in between the time we bump logstash version and a successful run of unified release. This commit modifies the dockerfile to use the artifact prepared in the first step instead of curling the last published one. This solves both issues as the tests run against the code from the tip fo the branch being tested and there is no dependency on an artifact existing as a result of a unified release pipeline. * Remove redundant docker steps from workflows Previously for docker acceptance tests three steps were performed: 1. Build container images (based on local artifacts) 2. Build "public" dockerfiles 3. Build container based on (a modified) file from step 2. The ONLY difference between the dockerfile that ultimately is used to define an image between 1 and 2 is WHERE the logstash source is downloaded from. In acceptance testing we WANT to use the source at the current checkout of logstash (not a remote). Using remote causes a dependency issue when changes are not published. Publishing is tied to unified release and gated on tests so naturally this is a bad fit for that dependency. This commit removes the redundancy by ONLY generating images for testing (step 1 from above). This also firms up our use of LOCAL_ARTIFACTS. Namely, the ONLY time we want that set to `false` is when we build a "public" dockerfile. We explicitly set that in the corresponding DRA script now. Similarly we explicitly set it to `true` when testing. * Remove unused function and argument This commit removes the unused function for building from dockerfiles. It also removes an unused argument for the make task for build_docker. (cherry picked from commit a994c7c) # Conflicts: # docker/Makefile # rakelib/artifacts.rake * fix merge conflicts * fix merge conflict and update rake task name --------- Co-authored-by: Cas Donoghue <[email protected]>
1 parent 8de4a19 commit b5de207

File tree

5 files changed

+14
-33
lines changed

5 files changed

+14
-33
lines changed

.buildkite/scripts/dra/build_docker.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ esac
2424
rake artifact:docker || error "artifact:docker build failed."
2525
rake artifact:docker_oss || error "artifact:docker_oss build failed."
2626
rake artifact:docker_wolfi || error "artifact:docker_wolfi build failed."
27+
28+
# Generating public dockerfiles is the primary use case for NOT using local artifacts
29+
export LOCAL_ARTIFACTS=false
2730
rake artifact:dockerfiles || error "artifact:dockerfiles build failed."
2831

2932
if [[ "$ARCH" != "aarch64" ]]; then

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ tasks.register("artifactDockerObservabilitySRE") {
337337
include "jdk-*-linux-*.tar.gz"
338338
}
339339
doLast {
340-
rake(projectDir, buildDir, 'artifact:build_docker_observabilitySRE')
340+
rake(projectDir, buildDir, 'artifact:docker_observabilitySRE')
341341
}
342342
}
343343

ci/docker_acceptance_tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ set -x
88
export JRUBY_OPTS="-J-Xmx1g"
99
export GRADLE_OPTS="-Xmx4g -Dorg.gradle.console=plain -Dorg.gradle.daemon=false -Dorg.gradle.logging.level=info -Dfile.encoding=UTF-8"
1010

11+
# Use local artifacts for acceptance test Docker builds
12+
export LOCAL_ARTIFACTS=true
13+
1114
if [ -n "$BUILD_JAVA_HOME" ]; then
1215
GRADLE_OPTS="$GRADLE_OPTS -Dorg.gradle.java.home=$BUILD_JAVA_HOME"
1316
fi

docker/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public-dockerfiles_full: templates/Dockerfile.erb docker_paths $(COPY_FILES)
137137
version_tag="${VERSION_TAG}" \
138138
release="${RELEASE}" \
139139
image_flavor="full" \
140-
local_artifacts="false" \
140+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
141141
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-full" && \
142142
cd $(ARTIFACTS_DIR)/docker && \
143143
cp $(ARTIFACTS_DIR)/Dockerfile-full Dockerfile && \
@@ -151,7 +151,7 @@ public-dockerfiles_oss: templates/Dockerfile.erb docker_paths $(COPY_FILES)
151151
version_tag="${VERSION_TAG}" \
152152
release="${RELEASE}" \
153153
image_flavor="oss" \
154-
local_artifacts="false" \
154+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
155155
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-oss" && \
156156
cd $(ARTIFACTS_DIR)/docker && \
157157
cp $(ARTIFACTS_DIR)/Dockerfile-oss Dockerfile && \
@@ -165,7 +165,7 @@ public-dockerfiles_ubi8: templates/Dockerfile.erb docker_paths $(COPY_FILES)
165165
version_tag="${VERSION_TAG}" \
166166
release="${RELEASE}" \
167167
image_flavor="ubi8" \
168-
local_artifacts="false" \
168+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
169169
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ubi8" && \
170170
cd $(ARTIFACTS_DIR)/docker && \
171171
cp $(ARTIFACTS_DIR)/Dockerfile-ubi8 Dockerfile && \
@@ -179,7 +179,7 @@ public-dockerfiles_observability-sre: templates/Dockerfile.erb docker_paths $(CO
179179
version_tag="${VERSION_TAG}" \
180180
release="${RELEASE}" \
181181
image_flavor="observability-sre" \
182-
local_artifacts="false" \
182+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
183183
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-observability-sre" && \
184184
cd $(ARTIFACTS_DIR)/docker && \
185185
cp $(ARTIFACTS_DIR)/Dockerfile-observability-sre Dockerfile && \
@@ -193,7 +193,7 @@ public-dockerfiles_wolfi: templates/Dockerfile.erb docker_paths $(COPY_FILES)
193193
version_tag="${VERSION_TAG}" \
194194
release="${RELEASE}" \
195195
image_flavor="wolfi" \
196-
local_artifacts="false" \
196+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
197197
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-wolfi" && \
198198
cd $(ARTIFACTS_DIR)/docker && \
199199
cp $(ARTIFACTS_DIR)/Dockerfile-wolfi Dockerfile && \
@@ -210,7 +210,7 @@ public-dockerfiles_ironbank: templates/hardening_manifest.yaml.erb templates/Doc
210210
version_tag="${VERSION_TAG}" \
211211
release="${RELEASE}" \
212212
image_flavor="ironbank" \
213-
local_artifacts="false" \
213+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
214214
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ironbank" && \
215215
cd $(ARTIFACTS_DIR)/ironbank && \
216216
cp $(ARTIFACTS_DIR)/Dockerfile-ironbank Dockerfile && \

rakelib/artifacts.rake

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ namespace "artifact" do
171171

172172
desc "Generate rpm, deb, tar and zip artifacts"
173173
task "all" => ["prepare", "build"]
174-
task "docker_only" => ["prepare", "build_docker_full", "build_docker_oss", "build_docker_ubi8", "build_docker_wolfi", "build_docker_observabilitySRE"]
174+
task "docker_only" => ["prepare", "docker", "docker_oss", "docker_wolfi", "docker_ubi8", "docker_observabilitySRE"]
175175

176176
desc "Build all (jdk bundled and not) tar.gz and zip of default logstash plugins with all dependencies"
177177
task "archives" => ["prepare", "generate_build_metadata"] do
@@ -457,31 +457,6 @@ namespace "artifact" do
457457
Rake::Task["artifact:archives_oss"].invoke
458458
end
459459

460-
task "build_docker_full" => [:generate_build_metadata] do
461-
Rake::Task["artifact:docker"].invoke
462-
Rake::Task["artifact:dockerfile_full"].invoke
463-
end
464-
465-
task "build_docker_oss" => [:generate_build_metadata] do
466-
Rake::Task["artifact:docker_oss"].invoke
467-
Rake::Task["artifact:dockerfile_oss"].invoke
468-
end
469-
470-
task "build_docker_ubi8" => [:generate_build_metadata] do
471-
Rake::Task["artifact:docker_ubi8"].invoke
472-
Rake::Task["artifact:dockerfile_ubi8"].invoke
473-
end
474-
475-
task "build_docker_observabilitySRE" => [:generate_build_metadata] do
476-
Rake::Task["artifact:docker_observabilitySRE"].invoke
477-
Rake::Task["artifact:dockerfile_observabilitySRE"].invoke
478-
end
479-
480-
task "build_docker_wolfi" => [:generate_build_metadata] do
481-
Rake::Task["artifact:docker_wolfi"].invoke
482-
Rake::Task["artifact:dockerfile_wolfi"].invoke
483-
end
484-
485460
task "generate_build_metadata" do
486461
require 'time'
487462
require 'tempfile'

0 commit comments

Comments
 (0)