Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packer: cache docker images #3620

Merged
merged 1 commit into from
Apr 6, 2020
Merged

Conversation

v1v
Copy link
Member

@v1v v1v commented Apr 6, 2020

Motivation/summary

I initially was tempted to add a retry/sleep command to wrap the packaging stage but it looks like it might cause some other issues, such as the workspace being reused (maybe go doesn't like it) and a bit hard to maintain.

This is a bit more elegant, based on the packer-cache approach that we use for other projects.
It will cache the required docker images for the packaging stage in the CI since those docker images are pulled from the docker registry everytime a build is triggered by the master branch. It will help to speed up the builds and avoid any kind of environmental issues with 500 errors.

[2020-04-06T12:00:22.040Z] ec813748fdd2: Waiting
[2020-04-06T12:00:22.040Z] docker: Error response from daemon: received unexpected HTTP status: 500 Internal Server Error.
[2020-04-06T12:00:22.040Z] See 'docker run --help'.
[2020-04-06T12:00:22.040Z] >> golangCrossBuild: Building for darwin/amd64
[2020-04-06T12:00:22.040Z] docker: Error response from daemon: received unexpected HTTP status: 500 Internal Server Error.
[2020-04-06T12:00:22.040Z] See 'docker run --help'.
[2020-04-06T12:00:22.040Z] >> golangCrossBuild: Building for linux/386
[2020-04-06T12:00:22.040Z] Unable to find image 'docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-darwin' locally

Just to clarify we do have something in place:

But it's not dynamic based on the go-version.

How to test these changes

sh -x .ci/packer_cache.sh 
+ source /usr/local/bin/bash_standard_lib.sh
++ readonly CACHE_DIR=/Users/vmartinez/.git-references
++ CACHE_DIR=/Users/vmartinez/.git-references
++ declare -a cloned_git_repos
+ source ./script/common.bash
++++ dirname ./script/common.bash
+++ cd ./script
+++ pwd
++ _sdir=/Users/vmartinez/work/src/github.com/elastic/apm-server/script
+ get_go_version
++ cat /Users/vmartinez/work/src/github.com/elastic/apm-server/script/../.go-version
+ GO_VERSION=1.13.9
+ '[' -z 1.13.9 ']'
+ DOCKER_IMAGES='
docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-arm
docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-darwin
docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-main
docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-main-debian7
docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-main-debian8
docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-mips
docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-ppc
docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-s390x
golang:1.13.9
'
+ for image in '${DOCKER_IMAGES}'
+ retry 2 docker pull docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-arm
+ local retries=2
+ shift
+ local count=0
+ docker pull docker.elastic.co/beats-dev/golang-crossbuild:1.13.9-arm
1.13.9-arm: Pulling from beats-dev/golang-crossbuild
c0c53f743a40: Already exists 
...

Related issues

Further details

There is an entry for this project in the infra side ansible/playbooks/group_vars/apm-ci/jenkins.yml:

git_reference_repos:
...
  - git@github.com:elastic/apm-server.git

@v1v v1v self-assigned this Apr 6, 2020
@v1v v1v added the automation label Apr 6, 2020
@v1v v1v requested review from a team and jalvz April 6, 2020 13:40
@v1v v1v added the ci label Apr 6, 2020
@v1v v1v marked this pull request as ready for review April 6, 2020 13:42
@v1v v1v merged commit 6cc7ade into elastic:master Apr 6, 2020
@v1v v1v deleted the feature/retry-package branch April 6, 2020 15:41
simitt pushed a commit to simitt/apm-server that referenced this pull request Dec 15, 2020
simitt added a commit that referenced this pull request Dec 16, 2020
* chore(ci): move CI scripts to the .ci directory (#4452)

* chore(ci): movee windows scripts to the CI location

* chore(ci): move more scripts

* chore(ci): move check-changelogs to CI folder

* chore(ci): move intake script to CI dir

* chore(ci): move bench script

* chore(ci): move sync script

* chore(ci): move package to CI dir

* chore(ci): move test-install to CI dir

* chore(ci): remove unused windows script

* ci: remove cron trigger from the check changelog job (#3957)

* fix: ci build and test of the golang-mage docker image (#3563)

* [CI][docker] prepare required context (#4136)

* packer: cache docker images (#3620)

* fix: check that docker is installed (#3889)

* Update Jenkinsfile

Co-authored-by: Victor Martinez <victormartinezrubio@gmail.com>

Co-authored-by: Manuel de la Peña <mdelapenya@gmail.com>
Co-authored-by: Ivan Fernandez Calvo <kuisathaverat@users.noreply.github.com>
Co-authored-by: Victor Martinez <victormartinezrubio@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants