-
Notifications
You must be signed in to change notification settings - Fork 293
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 run image metadata when --run-image is provided #2022
Conversation
@jjbustamante @natalieparellano could you please review and suggest improvements. |
@Pratham1812 could you run |
@jjbustamante I have run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pratham1812 thanks a lot for this! I left a few comments
pkg/client/build_test.go
Outdated
@@ -1045,7 +1045,7 @@ api = "0.2" | |||
h.AssertNil(t, err) | |||
h.AssertEq(t, fakeLifecycle.Opts.Builder.Name(), defaultBuilderImage.Name()) | |||
|
|||
bldr, err := builder.FromImage(defaultBuilderImage) | |||
bldr, err := builder.FromImage(defaultBuilderImage, "", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be awesome to see a test that passes in some-value
for the run image, and then verifies that some-value
is present in the image metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! I did the changes as per the above comments, I am not sure how to write tests for this, if you could guide me further, it would be great.
pkg/client/build.go
Outdated
@@ -332,7 +332,7 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error { | |||
return errors.Wrapf(err, "getting builder architecture") | |||
} | |||
|
|||
bldr, err := c.getBuilder(rawBuilderImage) | |||
bldr, err := c.getBuilder(rawBuilderImage, opts.RunImage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this one? is it not enough with the createEphemeralBuilder
change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled your branch, built the binary and tested out removing this, and it is still working so I think we don't need it.
@natalieparellano could you give me your thoughts here. Testing the binary, I can see the following output pack build -B paketobuildpacks/builder-jammy-base -p ./java-maven --run-image paketobuildpacks/run-jammy-base:0.0.2 java-app-3 In this case we are replacing the docker inspect java-app-3 | jq '.[] | .Config.Labels | ."io.buildpacks.lifecycle.metadata" | fromjson' | jq . {
"runImage": {
"topLayer": "sha256:be9eb0a7d50b0438c62376a29b5557f85496a55ae83d41a49f934160ffa09421",
"reference": "945a5e4052d9b9b024f69bf89f8cf8bd72bc727882ab0b78df9592b37119a31c",
"image": "paketobuildpacks/run-jammy-base:0.0.2"
},
"stack": {
"runImage": {
"image": "paketobuildpacks/run-jammy-base:0.0.2"
}
}
|
It should be okay, actually preferred - |
Hi @Pratham1812 could try to solve the merge conflicts and the DCO check ? |
I tried to fix the acceptance test failures. I focused in one of them and here are my findings. The test case is trying to rebase an application image saved in the docker daemon with mirrors metadata saved with the application image. Behavior before this PR
"runImage": {
"topLayer": "sha256:47746006a138ccf6c120beaf5ec55a5589fc6a9b93777082ee9e3b722f3ddf73",
"reference": "92761540a511123b9c76b9e4fe8c4826c3d19ef1dbfd67ed6b825d6b43546bb6",
"image": "pack-test/run",
"mirrors": [
"localhost:32801/pack-test/run"
]
},
"stack": {
"runImage": {
"image": "pack-test/run",
"mirrors": [
"localhost:32801/pack-test/run"
]
}
}
If we take a look at the previous metadata, the Behavior with this PRThe current PR is updating the metadata when "runImage": {
"topLayer": "sha256:74275d5fce8e3c3343321b75529e7751bd5966664f6af3aec1bb50890c7b6e39",
"reference": "5d17ab3bdb1b4764f429b059f7a8a1a7f820c4553d2a3f3dfeff69668a5c881a",
"image": "localhost:32804/run-before/byxrrrztji",
"mirrors": [
"localhost:32804/pack-test/run"
]
},
"stack": {
"runImage": {
"image": "localhost:32804/run-before/byxrrrztji",
"mirrors": [
"localhost:32804/pack-test/run"
]
}
}
|
internal/builder/builder.go
Outdated
@@ -140,6 +148,11 @@ func constructBuilder(img imgutil.Image, newName string, errOnMissingLabel bool, | |||
return nil, err | |||
} | |||
|
|||
if opts.runImage != "" { | |||
metadata.RunImages = []RunImageMetadata{{Image: opts.runImage}} | |||
metadata.Stack.RunImage.Image = opts.runImage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again, we need to be consistent in how we handle mirrors information. Right now it is being zeroed out for metadata.RunImages
but preserved for metadata.Stack.RunImage
(as metadata.Stack.RunImage.Mirrors
could still have data).
I propose we look in the existing known run images (RunImageMetadata.Mirrors
) and if the provided opts.runImage
is found there then preserve the run image mirror information, otherwise zero it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I did that locally, trying to fix the issues with the acceptance but I didn't push it
@jjbustamante since the linked acceptance test is validating rebase behavior we should probably just update the test setup to produce a test image ( Update: I think my suggestion of updating the setup will work. But, you have to also remove these lines from the setup, otherwise the test will fail with an inscrutable error. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2022 +/- ##
==========================================
+ Coverage 79.70% 79.72% +0.02%
==========================================
Files 176 176
Lines 13250 13261 +11
==========================================
+ Hits 10560 10571 +11
Misses 2021 2021
Partials 669 669
Flags with carried forward coverage won't be shown. Click here to find out more. |
Hi @Pratham1812! We made some changes to your code to get it into the last mile! but we need you to fix the DCO issues to get this PR merged. Is it possible for you to do that? |
The steps required to sign-off your commits are describe here, the most important are: To add your Signed-off-by line to every commit in this branch:
It is very important that you sign-off your commits in order for us to merge the PR! Otherwise we can't do it |
6c76367
to
1c4ed5e
Compare
Oh man! I think you didn't update your main fork before running the rebase right? and we still have some commits without signing. |
Signed-off-by: Pratham Agarwal <agarwalpratham1812@gmail.com>
Signed-off-by: Pratham Agarwal <agarwalpratham1812@gmail.com>
Signed-off-by: Pratham Agarwal <agarwalpratham1812@gmail.com>
Signed-off-by: Pratham Agarwal <agarwalpratham1812@gmail.com>
1c4ed5e
to
3c2a901
Compare
- Adding acceptance tests Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
3c2a901
to
1122cab
Compare
Looks good to me :) I suggested a few cosmetic changes |
…ck from Natalie Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Summary
Output
Before
After
Documentation
Related
Resolves #1964