-
Notifications
You must be signed in to change notification settings - Fork 314
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
fix: clone images on specified services #4270
Conversation
Signed-off-by: Javier Lopez <javier@okteto.com>
@@ -92,6 +94,19 @@ func (it imageTagger) getServiceImageReference(manifestName, svcName string, b * | |||
return useReferenceTemplate(targetRegistry, sanitizedName, svcName, model.OktetoDefaultImageTag) | |||
} | |||
|
|||
func (it imageTagger) getGlobalTagFromDevIfNeccesary(tags, namespace, registryURL, buildHash, manifestName, svcName string, ic registry.ImageCtrl) string { | |||
tagList := strings.Split(tags, ",") |
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.
We need to expand this to build all the global images from the parsed tags
E: fmt.Errorf("'%s' isn't a valid image tag", imageTag), | ||
Hint: fmt.Sprintf("The Okteto Registry syntax is: '%s/image_name'", prefix), | ||
tags := strings.Split(imageTags, ",") | ||
for _, tag := range tags { |
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.
Fix to pass several tags with okteto.dev
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4270 +/- ##
=======================================
Coverage 43.25% 43.25%
=======================================
Files 375 375
Lines 30200 30222 +22
=======================================
+ Hits 13064 13074 +10
- Misses 15989 16007 +18
+ Partials 1147 1141 -6 |
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
@jLopezbarb Why the double message? Before it was also happening but only on BuildKit logs, but not in the final success step |
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.
As we talked offline, we are mixing 2 ways of cloning images:
- Old one: If the user didn't specify an image in the build info, we pass one tag in
buildInfo.Tag
and then, in buildkit.go, we fillbuildOptions.DevTag
with the dev tag to push - New one (added in this PR). If the user specify an image, and it is for dev registry, we pass 2 images in
buildOptions.Tag
and then,DevTag
is not filled just because dev tag is the first in the list
We should unify both ways to just one to avoid problems in the future
cmd/build/v2/build.go
Outdated
if ob.Registry.IsOktetoRegistry(firstTag) { | ||
imageWithDigest, err = ob.smartBuildCtrl.Clone(imageWithDigest, firstTag) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} else { | ||
imageWithDigest, err = ob.smartBuildCtrl.CloneGlobalImageToDev(imageWithDigest) | ||
if err != nil { |
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.
Can't we unify this somehow instead of having to have 2 different functions (very similar)? At the end, CloneGlobalImageToDev
wil have to clone always to okteto.dev/<image>:okteto
. WDYT? Would it make sense?
Signed-off-by: Javier Lopez <javier@okteto.com>
On the old one we were only adding the dev tag if the image was a global image. I've removed the code so we are only using the new method |
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
@@ -185,70 +188,6 @@ func TestGetBuildHash(t *testing.T) { | |||
assert.Equal(t, "hash", out) | |||
} | |||
|
|||
func TestCloneGlobalImageToDev(t *testing.T) { |
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 think you need to change also the tests. It is no longer TestClone
Discussed offline, there is 1 case that doesn't work as expected. If I set my own image with a specific name, it is being cloned to global with other name instead of using the 1 I specified |
Signed-off-by: Javier Lopez <javier@okteto.com>
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.
Tested couple scenarios, LGTM
Signed-off-by: Javier Lopez <javier@okteto.com>
I found another issue while validating the changes. It is related to my previous message: #4270 (comment) When I specify a custom image in the |
Signed-off-by: Javier Lopez <javier@okteto.com>
Proposed changes
Fixes DEV-232
okteto build -t okteto.dev/myapp:1.0.0,okteto.dev/myapp:latest
cloneFromGlobalToDev
getGlobalTagFromDevIfNeccesary
in order to get the global tag from dev if we need to build into the global registry tooIt has created a side effect where we show that the image has been successfully pushed into the two registries. I think it's better for the user so he knows what's happening. Are we ok with that
![Screenshot 2024-05-22 at 12 49 15](https://private-user-images.githubusercontent.com/25170843/332767388-73b414e0-588d-4439-a9ff-68bb018775a2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMzA5MTgsIm5iZiI6MTcyNDEzMDYxOCwicGF0aCI6Ii8yNTE3MDg0My8zMzI3NjczODgtNzNiNDE0ZTAtNTg4ZC00NDM5LWE5ZmYtNjhiYjAxODc3NWEyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIwVDA1MTAxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIxYzk2MGZlNmYzYmZiZTIxN2EyNjcwYzQ4OGMyYjJhYWNiNGI2YWExZGU4Y2JiNzJkNmIzYjllZGUzYjI1ODMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Yc3qEE6NeDfPGWU6538PaUNc-7Iq1-dfAHN0mRjBzmQ)
How to validate
my-service
folder with a simpleDockerfile
(FROM alpine
)okteto build
CLI Quality Reminders 🔧
For both authors and reviewers: