Skip to content

Commit e31d9c9

Browse files
[8.18] (backport #18181) Remove redundant testing and circular dependency from docker acceptance testing (#18251)
* 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 --------- Co-authored-by: Cas Donoghue <[email protected]>
1 parent 4a6b1f2 commit e31d9c9

File tree

4 files changed

+12
-27
lines changed

4 files changed

+12
-27
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

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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public-dockerfiles_full: templates/Dockerfile.erb docker_paths $(COPY_FILES)
128128
version_tag="${VERSION_TAG}" \
129129
release="${RELEASE}" \
130130
image_flavor="full" \
131-
local_artifacts="false" \
131+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
132132
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-full" && \
133133
cd $(ARTIFACTS_DIR)/docker && \
134134
cp $(ARTIFACTS_DIR)/Dockerfile-full Dockerfile && \
@@ -142,7 +142,7 @@ public-dockerfiles_oss: templates/Dockerfile.erb docker_paths $(COPY_FILES)
142142
version_tag="${VERSION_TAG}" \
143143
release="${RELEASE}" \
144144
image_flavor="oss" \
145-
local_artifacts="false" \
145+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
146146
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-oss" && \
147147
cd $(ARTIFACTS_DIR)/docker && \
148148
cp $(ARTIFACTS_DIR)/Dockerfile-oss Dockerfile && \
@@ -156,7 +156,7 @@ public-dockerfiles_ubi8: templates/Dockerfile.erb docker_paths $(COPY_FILES)
156156
version_tag="${VERSION_TAG}" \
157157
release="${RELEASE}" \
158158
image_flavor="ubi8" \
159-
local_artifacts="false" \
159+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
160160
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ubi8" && \
161161
cd $(ARTIFACTS_DIR)/docker && \
162162
cp $(ARTIFACTS_DIR)/Dockerfile-ubi8 Dockerfile && \
@@ -170,7 +170,7 @@ public-dockerfiles_wolfi: templates/Dockerfile.erb docker_paths $(COPY_FILES)
170170
version_tag="${VERSION_TAG}" \
171171
release="${RELEASE}" \
172172
image_flavor="wolfi" \
173-
local_artifacts="false" \
173+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
174174
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-wolfi" && \
175175
cd $(ARTIFACTS_DIR)/docker && \
176176
cp $(ARTIFACTS_DIR)/Dockerfile-wolfi Dockerfile && \
@@ -187,7 +187,7 @@ public-dockerfiles_ironbank: templates/hardening_manifest.yaml.erb templates/Doc
187187
version_tag="${VERSION_TAG}" \
188188
release="${RELEASE}" \
189189
image_flavor="ironbank" \
190-
local_artifacts="false" \
190+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
191191
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ironbank" && \
192192
cd $(ARTIFACTS_DIR)/ironbank && \
193193
cp $(ARTIFACTS_DIR)/Dockerfile-ironbank Dockerfile && \

rakelib/artifacts.rake

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +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"]
175-
174+
task "docker_only" => ["prepare", "docker", "docker_oss", "docker_wolfi", "docker_ubi8"]
176175
desc "Build all (jdk bundled and not) tar.gz and zip of default logstash plugins with all dependencies"
177176
task "archives" => ["prepare", "generate_build_metadata"] do
178177
#with bundled JDKs
@@ -424,26 +423,6 @@ namespace "artifact" do
424423
Rake::Task["artifact:archives_oss"].invoke
425424
end
426425

427-
task "build_docker_full" => [:generate_build_metadata] do
428-
Rake::Task["artifact:docker"].invoke
429-
Rake::Task["artifact:dockerfile_full"].invoke
430-
end
431-
432-
task "build_docker_oss" => [:generate_build_metadata] do
433-
Rake::Task["artifact:docker_oss"].invoke
434-
Rake::Task["artifact:dockerfile_oss"].invoke
435-
end
436-
437-
task "build_docker_ubi8" => [:generate_build_metadata] do
438-
Rake::Task["artifact:docker_ubi8"].invoke
439-
Rake::Task["artifact:dockerfile_ubi8"].invoke
440-
end
441-
442-
task "build_docker_wolfi" => [:generate_build_metadata] do
443-
Rake::Task["artifact:docker_wolfi"].invoke
444-
Rake::Task["artifact:dockerfile_wolfi"].invoke
445-
end
446-
447426
task "generate_build_metadata" do
448427
require 'time'
449428
require 'tempfile'

0 commit comments

Comments
 (0)