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

Add --all-tags copy of container image between different container registries #187

Merged

Conversation

peterzhuamazon
Copy link
Member

@peterzhuamazon peterzhuamazon commented Apr 11, 2023

Description

Add --all-tags copy of container image between different container registries.
Either between docker hub / ecr or other registries.

Issues Resolved

Closes opensearch-project/opensearch-build#3386

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@peterzhuamazon peterzhuamazon added the enhancement New feature or request label Apr 11, 2023
@peterzhuamazon peterzhuamazon self-assigned this Apr 11, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 11, 2023

Codecov Report

Merging #187 (fc1f315) into main (35f6aa9) will increase coverage by 0.07%.
The diff coverage is 100.00%.

❗ Current head fc1f315 differs from pull request most recent head 1a5547f. Consider uploading reports for the commit 1a5547f to get more accurate results

@@             Coverage Diff              @@
##               main     #187      +/-   ##
============================================
+ Coverage     85.42%   85.50%   +0.07%     
  Complexity       25       25              
============================================
  Files            74       75       +1     
  Lines           199      200       +1     
  Branches         11       11              
============================================
+ Hits            170      171       +1     
  Misses           21       21              
  Partials          8        8              
Impacted Files Coverage Δ
tests/jenkins/jobs/DockerCopy_Jenkinsfile 100.00% <ø> (ø)
tests/jenkins/jobs/DockerCopyAllTags_Jenkinsfile 100.00% <100.00%> (ø)

Copy link
Member

@gaiksaya gaiksaya left a comment

Choose a reason for hiding this comment

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

I am still not clear (after reading related GH issue) what we are trying to achieve here? When you say recursive copy, it is just for one image or all images? For example we build os-ubuntu-1 and it pushed to dockerhub, enabling recursive copy will push to ECR too simultaneously?

tests/jenkins/jobs/DockerCopyRecursive_Jenkinsfile Outdated Show resolved Hide resolved
vars/copyContainer.groovy Outdated Show resolved Hide resolved
vars/copyContainer.groovy Outdated Show resolved Hide resolved
vars/copyContainer.groovy Outdated Show resolved Hide resolved
vars/copyContainer.groovy Outdated Show resolved Hide resolved
vars/copyContainer.groovy Outdated Show resolved Hide resolved
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
@peterzhuamazon peterzhuamazon force-pushed the docker-runner-sync-lib branch 3 times, most recently from 4189c57 to f724938 Compare May 8, 2023 19:19
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
Copy link
Collaborator

@rishabh6788 rishabh6788 left a comment

Choose a reason for hiding this comment

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

As understood, the recursive copy will only happen for tags between provided registries.
LGTM.

@peterzhuamazon
Copy link
Member Author

Apparently someone has pushed a change last week in the latest version 0.15.x to allow all tags push during gcrane copy.

Which solves:

@peterzhuamazon
Copy link
Member Author

Will consider making that change to avoid issues like manually iterate through all the tags by gathering info from gcrane ls.

@peterzhuamazon
Copy link
Member Author

New commands:

./crane <reg>/<repo>/<image> <reg>/<repo>/<image> --all-tags

@peterzhuamazon
Copy link
Member Author

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
@peterzhuamazon peterzhuamazon changed the title Add recursive copy of container images repositories Add --all-tags copy of container images between different container registries May 9, 2023
@peterzhuamazon peterzhuamazon changed the title Add --all-tags copy of container images between different container registries Add --all-tags copy of container image between different container registries May 9, 2023
@peterzhuamazon
Copy link
Member Author

peterzhuamazon commented May 9, 2023

Hi @gaiksaya @rishabh6788
Please review again as the current implementation is much cleaner.

Also:

  1. Switch from gcrane to crane as --all-tags functionality is specifically added on crane.
  2. gcrane is just a gcr specific crane variant that has better ls function, crane can do same thing and it is the source of truth. Similarly krane is more for the kube variant. See https://github.com/google/go-containerregistry#tools.
  3. Make more logic in groovy to replace full-blown shell scripts.

Thanks.

tests/jenkins/TestCopyContainer.groovy Outdated Show resolved Hide resolved
vars/copyContainer.groovy Outdated Show resolved Hide resolved
@peterzhuamazon
Copy link
Member Author

peterzhuamazon commented May 10, 2023

Replied your comment @gaiksaya see my responses, Thanks.
#187 (comment)

cc: @bbarani @rishabh6788 @prudhvigodithi .

vars/copyContainer.groovy Outdated Show resolved Hide resolved
vars/copyContainer.groovy Outdated Show resolved Hide resolved
vars/copyContainer.groovy Outdated Show resolved Hide resolved
peterzhuamazon and others added 3 commits May 19, 2023 16:38
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
@rishabh6788
Copy link
Collaborator

LGTM

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
@peterzhuamazon peterzhuamazon dismissed gaiksaya’s stale review May 20, 2023 01:42

All the comments have been adressed and reviewed again. Thanks.

vars/copyContainer.groovy Outdated Show resolved Hide resolved
vars/copyContainer.groovy Show resolved Hide resolved
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
@peterzhuamazon peterzhuamazon merged commit 942749a into opensearch-project:main May 22, 2023
@peterzhuamazon peterzhuamazon deleted the docker-runner-sync-lib branch May 22, 2023 19:57
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 22, 2023
…gistries (#187)

* Add recursive copy of container images repositories

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add boolean param and the tests

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add params requirements

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add new alltags

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Update vars/copyContainer.groovy

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Update vars/copyContainer.groovy

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add tests

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Bump version

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Update vars/copyContainer.groovy

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com>
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

---------

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com>
(cherry picked from commit 942749a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 4.x enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

[Enhancement] Make ci-runner images easier to build and sync between different container registries
4 participants