Skip to content

Commit f925571

Browse files
donoghucmergify[bot]
authored andcommitted
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
1 parent e7ae92b commit f925571

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
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: 26 additions & 3 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,25 +151,39 @@ 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 && \
158158
tar -zcf ../logstash-oss-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
159159

160+
<<<<<<< HEAD
160161
public-dockerfiles_ubi8: templates/Dockerfile.erb docker_paths $(COPY_FILES)
162+
=======
163+
public-dockerfiles_wolfi: templates/Dockerfile.erb docker_paths $(COPY_FILES)
164+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
161165
../vendor/jruby/bin/jruby -S erb -T "-"\
162166
created_date="${BUILD_DATE}" \
163167
elastic_version="${ELASTIC_VERSION}" \
164168
arch="${ARCHITECTURE}" \
165169
version_tag="${VERSION_TAG}" \
170+
<<<<<<< HEAD
166171
release="${RELEASE}" \
167172
image_flavor="ubi8" \
168173
local_artifacts="false" \
169174
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ubi8" && \
170175
cd $(ARTIFACTS_DIR)/docker && \
171176
cp $(ARTIFACTS_DIR)/Dockerfile-ubi8 Dockerfile && \
172177
tar -zcf ../logstash-ubi8-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
178+
=======
179+
release="${RELEASE}" \
180+
image_flavor="wolfi" \
181+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
182+
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-wolfi" && \
183+
cd $(ARTIFACTS_DIR)/docker && \
184+
cp $(ARTIFACTS_DIR)/Dockerfile-wolfi Dockerfile && \
185+
tar -zcf ../logstash-wolfi-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
186+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
173187

174188
public-dockerfiles_observability-sre: templates/Dockerfile.erb docker_paths $(COPY_FILES)
175189
../vendor/jruby/bin/jruby -S erb -T "-"\
@@ -179,12 +193,13 @@ public-dockerfiles_observability-sre: templates/Dockerfile.erb docker_paths $(CO
179193
version_tag="${VERSION_TAG}" \
180194
release="${RELEASE}" \
181195
image_flavor="observability-sre" \
182-
local_artifacts="false" \
196+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
183197
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-observability-sre" && \
184198
cd $(ARTIFACTS_DIR)/docker && \
185199
cp $(ARTIFACTS_DIR)/Dockerfile-observability-sre Dockerfile && \
186200
tar -zcf ../logstash-observability-sre-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
187201

202+
<<<<<<< HEAD
188203
public-dockerfiles_wolfi: templates/Dockerfile.erb docker_paths $(COPY_FILES)
189204
../vendor/jruby/bin/jruby -S erb -T "-"\
190205
created_date="${BUILD_DATE}" \
@@ -200,6 +215,9 @@ public-dockerfiles_wolfi: templates/Dockerfile.erb docker_paths $(COPY_FILES)
200215
tar -zcf ../logstash-wolfi-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
201216

202217
public-dockerfiles_ironbank: templates/hardening_manifest.yaml.erb templates/Dockerfile.erb ironbank_docker_paths $(COPY_IRONBANK_FILES)
218+
=======
219+
public-dockerfiles_ironbank: templates/hardening_manifest.yaml.erb templates/IronbankDockerfile.erb ironbank_docker_paths $(COPY_IRONBANK_FILES)
220+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
203221
../vendor/jruby/bin/jruby -S erb -T "-"\
204222
elastic_version="${ELASTIC_VERSION}" \
205223
templates/hardening_manifest.yaml.erb > $(ARTIFACTS_DIR)/ironbank/hardening_manifest.yaml && \
@@ -210,8 +228,13 @@ public-dockerfiles_ironbank: templates/hardening_manifest.yaml.erb templates/Doc
210228
version_tag="${VERSION_TAG}" \
211229
release="${RELEASE}" \
212230
image_flavor="ironbank" \
231+
<<<<<<< HEAD
213232
local_artifacts="false" \
214233
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ironbank" && \
234+
=======
235+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
236+
templates/IronbankDockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ironbank" && \
237+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
215238
cd $(ARTIFACTS_DIR)/ironbank && \
216239
cp $(ARTIFACTS_DIR)/Dockerfile-ironbank Dockerfile && \
217240
tar -zcf ../logstash-ironbank-$(VERSION_TAG)-docker-build-context.tar.gz scripts Dockerfile hardening_manifest.yaml LICENSE README.md

rakelib/artifacts.rake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ namespace "artifact" do
171171

172172
desc "Generate rpm, deb, tar and zip artifacts"
173173
task "all" => ["prepare", "build"]
174+
<<<<<<< HEAD
174175
task "docker_only" => ["prepare", "build_docker_full", "build_docker_oss", "build_docker_ubi8", "build_docker_wolfi", "build_docker_observabilitySRE"]
176+
=======
177+
task "docker_only" => ["prepare", "docker", "docker_oss", "docker_wolfi", "docker_observabilitySRE"]
178+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
175179

176180
desc "Build all (jdk bundled and not) tar.gz and zip of default logstash plugins with all dependencies"
177181
task "archives" => ["prepare", "generate_build_metadata"] do
@@ -418,12 +422,15 @@ namespace "artifact" do
418422
build_dockerfile('full')
419423
end
420424

425+
<<<<<<< HEAD
421426
desc "Generate Dockerfile for UBI8 images"
422427
task "dockerfile_ubi8" => ["prepare", "generate_build_metadata"] do
423428
puts("[dockerfiles] Building ubi8 Dockerfiles")
424429
build_dockerfile('ubi8')
425430
end
426431

432+
=======
433+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
427434
desc "Generate Dockerfile for wolfi images"
428435
task "dockerfile_wolfi" => ["prepare", "generate_build_metadata"] do
429436
puts("[dockerfiles] Building wolfi Dockerfiles")
@@ -457,6 +464,7 @@ namespace "artifact" do
457464
Rake::Task["artifact:archives_oss"].invoke
458465
end
459466

467+
<<<<<<< HEAD
460468
task "build_docker_full" => [:generate_build_metadata] do
461469
Rake::Task["artifact:docker"].invoke
462470
Rake::Task["artifact:dockerfile_full"].invoke
@@ -482,6 +490,8 @@ namespace "artifact" do
482490
Rake::Task["artifact:dockerfile_wolfi"].invoke
483491
end
484492

493+
=======
494+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
485495
task "generate_build_metadata" do
486496
require 'time'
487497
require 'tempfile'

0 commit comments

Comments
 (0)