Backport PR #14780 to 7.17: [DRA] Avoid to loose err code on docker save #14785

* [DRA] Force docker save to save directly on file instead of pipe to another command loosing the execution error code

(cherry picked from commit 2e5e49d10d)

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
This commit is contained in:
github-actions[bot] 2022-11-29 13:56:54 +01:00 committed by GitHub
parent 3822b60890
commit dac65a439e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,7 +11,11 @@ function save_docker_tarballs {
local arch="${1:?architecture required}"
local version="${2:?stack-version required}"
for image in logstash logstash-oss logstash-ubi8; do
docker save "docker.elastic.co/logstash/${image}:${version}" | gzip -c > "build/${image}-${version}-docker-image-${arch}.tar.gz"
docker save -o "build/${image}-${version}-docker-image-${arch}.tar" \
"docker.elastic.co/logstash/${image}:${version}" || \
error "Hit a problem in saving the Docker image for ${image}"
# NOTE: if docker save exited with non-zero the error log already exited the script
gzip "build/${image}-${version}-docker-image-${arch}.tar"
done
}