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

feat: step to check if a docker image exists #1077

Merged
merged 19 commits into from
Apr 21, 2021

Conversation

mdelapenya
Copy link
Contributor

@mdelapenya mdelapenya commented Apr 15, 2021

What does this PR do?

It adds a new step that will check if a given Docker image exists, checking the Docker host first: if that fails because the image does not exist in the current Docker host, then it will try to look up the manifest in the Docker registry. If it fails again then it means the image does not exist, it will log an error and will return false.

Why is it important?

We want to skip building Kibana again and again, if the image was already built. Specially important when we want to trigger an action on the same commit (i.e. triggering the e2e tests)

It will check the Docker host first, and then will try a docker pull.
If it fails, it will log an error
@mdelapenya mdelapenya self-assigned this Apr 15, 2021
@mdelapenya mdelapenya requested a review from a team April 15, 2021 16:02
vars/checkDockerImage.groovy Outdated Show resolved Hide resolved
Comment on lines 32 to 35
log(level: 'DEBUG', text: "${image} does not exist: pulling")
if (cmd(returnStatus: true, script: "docker pull ${image}") == 0) {
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think to add a default new argument to try with pulling?

checkDockerImage(image: 'hello-world:latest', pull: true)

It can be enabled by default. Then this step can verify the cached docker images or also an image from an external docker registry.

Besides, do you wanna pull or just query if it's available?

Copy link
Contributor Author

@mdelapenya mdelapenya Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bool return is in an upcoming commit!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to check. Maybe there is a simpler/faster manner

@apmmachine
Copy link
Contributor

apmmachine commented Apr 15, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #1077 updated

  • Start Time: 2021-04-21T09:09:37.203+0000

  • Duration: 32 min 18 sec

  • Commit: 47ffb37

Test stats 🧪

Test Results
Failed 0
Passed 1111
Skipped 2
Total 1113

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 1111
Skipped 2
Total 1113

vars/checkDockerImage.groovy Outdated Show resolved Hide resolved
@mdelapenya mdelapenya marked this pull request as ready for review April 19, 2021 16:29
@botelastic botelastic bot added the groovy label Apr 20, 2021
vars/dockerImageExists.groovy Outdated Show resolved Hide resolved
vars/dockerImageExists.groovy Outdated Show resolved Hide resolved
Copy link
Member

@v1v v1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments that are not blockers

@mdelapenya
Copy link
Contributor Author

mdelapenya commented Apr 21, 2021

Minor comments that are not blockers

I addressed them in last 4 commits, thanks!

@mdelapenya mdelapenya merged commit 11f20c4 into elastic:master Apr 21, 2021
v1v added a commit that referenced this pull request Apr 21, 2021
…notify-message-template

* upstream/master:
  Fix build status and adjust Vault (#1074)
  Remove super-linter since it takes 20 minutes (#1083)
  Bump elastic stack version automation (#1081)
  feat: step to check if a docker image exists (#1077)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.210
  Enable stage filter argument for the beatsStages (#1076)
@mdelapenya mdelapenya deleted the check-kibana-image-exists branch April 26, 2021 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants