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

Update relocation map during porter publish #2186

Merged
merged 6 commits into from Jun 28, 2022

Conversation

VinozzZ
Copy link
Contributor

@VinozzZ VinozzZ commented Jun 21, 2022

What does this change

Currently, when publishing from a bundle, porter generates a new bundle that don't preserve content digests.
This PR updates the logic to use relocation maps in the original bundle to associate the old images with the newly copied images.

What issue does it fix

Closes #1819

Notes for the reviewer

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Reviewer Checklist

  • Comment with /azp run test-porter-release if a magefile or build script was modified
  • Comment with /azp run porter-integration if it's a non-trivial PR

@getporterbot getporterbot added this to In Progress in Porter and Mixins Jun 21, 2022
@carolynvs carolynvs self-assigned this Jun 21, 2022
@VinozzZ VinozzZ force-pushed the update-relocation-map-publish branch 2 times, most recently from e9baaa6 to 47d0d04 Compare June 21, 2022 21:49
@VinozzZ VinozzZ marked this pull request as ready for review June 21, 2022 21:57
@carolynvs
Copy link
Member

@VinozzZ Sorry it took me a bit to review this and in the meantime there are merge conflicts. Can you resolve them and then I'll do a review?

Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
@VinozzZ VinozzZ force-pushed the update-relocation-map-publish branch from 43a72c1 to 12d87c5 Compare June 23, 2022 22:24
@@ -416,6 +357,31 @@ func (p *Porter) rewriteBundleWithInvocationImageDigest(ctx context.Context, m *
return bun, nil
}

func (p *Porter) updateRelocationMapping(relocationMap relocation.ImageRelocationMap, layout registry.Layout, originImg string, newReference string) (relocation.ImageRelocationMap, error) {
Copy link
Member

Choose a reason for hiding this comment

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

The function name made me initially assume that this function only updated the relocation mapping file, and it never ocurred to me that it would also push the image. What do you think about changing the function name so that it's more obvious what it does?

Suggested change
func (p *Porter) updateRelocationMapping(relocationMap relocation.ImageRelocationMap, layout registry.Layout, originImg string, newReference string) (relocation.ImageRelocationMap, error) {
func (p *Porter) relocateImage(relocationMap relocation.ImageRelocationMap, layout registry.Layout, originImg string, newReference string) (relocation.ImageRelocationMap, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's good point and a great name. I will change it

description string
relocationMap relocation.ImageRelocationMap
layout registry.Layout
hasError bool
Copy link
Member

Choose a reason for hiding this comment

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

Let's change this to use wantError string so that we can check that it failed for the expected reason.

@@ -77,6 +77,8 @@ func TestArchive_StableDigest(t *testing.T) {

// Use a fixed bundle to work with so that we can rely on the registry and layer digests
const reference = "ghcr.io/getporter/examples/whalegap:v0.2.0"
const referencedImg = "carolynvs/whalesayd@sha256:8b92b7269f59e3ed824e811a1ff1ee64f0d44c0218efefada57a4bebc2d7ef6f"
Copy link
Member

Choose a reason for hiding this comment

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

I was expecting that these extra validations would be added to the Airgapped test above, since this feature supports airgap and testing it requires that we are making it impossible to use the original images by taking the original registry offline.

The test you are editing is for checking that when we archive twice, we get the same digest.

Can you move these checks into the other test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good

Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
@VinozzZ VinozzZ changed the title Update relocation map publish Update relocation map during porter publish Jun 27, 2022
Copy link
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

LGTM

@carolynvs carolynvs merged commit 62d0ba5 into getporter:release/v1 Jun 28, 2022
Porter and Mixins automation moved this from In Progress to Done Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants