Skip to content

Commit c1d761c

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 8e00c87 commit c1d761c

File tree

4 files changed

+54
-3
lines changed

4 files changed

+54
-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: 29 additions & 3 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,12 +142,13 @@ 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 && \
149149
tar -zcf ../logstash-oss-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
150150

151+
<<<<<<< HEAD
151152
public-dockerfiles_ubi8: templates/Dockerfile.erb docker_paths $(COPY_FILES)
152153
../vendor/jruby/bin/jruby -S erb -T "-"\
153154
created_date="${BUILD_DATE}" \
@@ -162,6 +163,8 @@ public-dockerfiles_ubi8: templates/Dockerfile.erb docker_paths $(COPY_FILES)
162163
cp $(ARTIFACTS_DIR)/Dockerfile-ubi8 Dockerfile && \
163164
tar -zcf ../logstash-ubi8-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
164165

166+
=======
167+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
165168
public-dockerfiles_wolfi: templates/Dockerfile.erb docker_paths $(COPY_FILES)
166169
../vendor/jruby/bin/jruby -S erb -T "-"\
167170
created_date="${BUILD_DATE}" \
@@ -170,13 +173,31 @@ public-dockerfiles_wolfi: templates/Dockerfile.erb docker_paths $(COPY_FILES)
170173
version_tag="${VERSION_TAG}" \
171174
release="${RELEASE}" \
172175
image_flavor="wolfi" \
173-
local_artifacts="false" \
176+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
174177
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-wolfi" && \
175178
cd $(ARTIFACTS_DIR)/docker && \
176179
cp $(ARTIFACTS_DIR)/Dockerfile-wolfi Dockerfile && \
177180
tar -zcf ../logstash-wolfi-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
178181

182+
<<<<<<< HEAD
179183
public-dockerfiles_ironbank: templates/hardening_manifest.yaml.erb templates/Dockerfile.erb ironbank_docker_paths $(COPY_IRONBANK_FILES)
184+
=======
185+
public-dockerfiles_observability-sre: templates/Dockerfile.erb docker_paths $(COPY_FILES)
186+
../vendor/jruby/bin/jruby -S erb -T "-"\
187+
created_date="${BUILD_DATE}" \
188+
elastic_version="${ELASTIC_VERSION}" \
189+
arch="${ARCHITECTURE}" \
190+
version_tag="${VERSION_TAG}" \
191+
release="${RELEASE}" \
192+
image_flavor="observability-sre" \
193+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
194+
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-observability-sre" && \
195+
cd $(ARTIFACTS_DIR)/docker && \
196+
cp $(ARTIFACTS_DIR)/Dockerfile-observability-sre Dockerfile && \
197+
tar -zcf ../logstash-observability-sre-$(VERSION_TAG)-docker-build-context.tar.gz Dockerfile bin config env2yaml pipeline
198+
199+
public-dockerfiles_ironbank: templates/hardening_manifest.yaml.erb templates/IronbankDockerfile.erb ironbank_docker_paths $(COPY_IRONBANK_FILES)
200+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
180201
../vendor/jruby/bin/jruby -S erb -T "-"\
181202
elastic_version="${ELASTIC_VERSION}" \
182203
templates/hardening_manifest.yaml.erb > $(ARTIFACTS_DIR)/ironbank/hardening_manifest.yaml && \
@@ -187,8 +208,13 @@ public-dockerfiles_ironbank: templates/hardening_manifest.yaml.erb templates/Doc
187208
version_tag="${VERSION_TAG}" \
188209
release="${RELEASE}" \
189210
image_flavor="ironbank" \
211+
<<<<<<< HEAD
190212
local_artifacts="false" \
191213
templates/Dockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ironbank" && \
214+
=======
215+
local_artifacts="$(or $(LOCAL_ARTIFACTS),false)" \
216+
templates/IronbankDockerfile.erb > "${ARTIFACTS_DIR}/Dockerfile-ironbank" && \
217+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
192218
cd $(ARTIFACTS_DIR)/ironbank && \
193219
cp $(ARTIFACTS_DIR)/Dockerfile-ironbank Dockerfile && \
194220
tar -zcf ../logstash-ironbank-$(VERSION_TAG)-docker-build-context.tar.gz scripts Dockerfile hardening_manifest.yaml LICENSE README.md

rakelib/artifacts.rake

Lines changed: 19 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"]
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
@@ -380,18 +384,30 @@ namespace "artifact" do
380384
build_dockerfile('oss')
381385
end
382386

387+
<<<<<<< HEAD
388+
=======
389+
desc "Generate Dockerfile for observability-sre images"
390+
task "dockerfile_observabilitySRE" => ["prepare-observabilitySRE", "generate_build_metadata"] do
391+
puts("[dockerfiles] Building observability-sre Dockerfile")
392+
build_dockerfile('observability-sre')
393+
end
394+
395+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
383396
desc "Generate Dockerfile for full images"
384397
task "dockerfile_full" => ["prepare", "generate_build_metadata"] do
385398
puts("[dockerfiles] Building full Dockerfiles")
386399
build_dockerfile('full')
387400
end
388401

402+
<<<<<<< HEAD
389403
desc "Generate Dockerfile for UBI8 images"
390404
task "dockerfile_ubi8" => ["prepare", "generate_build_metadata"] do
391405
puts("[dockerfiles] Building ubi8 Dockerfiles")
392406
build_dockerfile('ubi8')
393407
end
394408

409+
=======
410+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
395411
desc "Generate Dockerfile for wolfi images"
396412
task "dockerfile_wolfi" => ["prepare", "generate_build_metadata"] do
397413
puts("[dockerfiles] Building wolfi Dockerfiles")
@@ -424,6 +440,7 @@ namespace "artifact" do
424440
Rake::Task["artifact:archives_oss"].invoke
425441
end
426442

443+
<<<<<<< HEAD
427444
task "build_docker_full" => [:generate_build_metadata] do
428445
Rake::Task["artifact:docker"].invoke
429446
Rake::Task["artifact:dockerfile_full"].invoke
@@ -444,6 +461,8 @@ namespace "artifact" do
444461
Rake::Task["artifact:dockerfile_wolfi"].invoke
445462
end
446463

464+
=======
465+
>>>>>>> a994c7cb (Remove redundant testing and circular dependency from docker acceptance testing (#18181))
447466
task "generate_build_metadata" do
448467
require 'time'
449468
require 'tempfile'

0 commit comments

Comments
 (0)