-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Existing images are tagged with correct reference on push #12525
Existing images are tagged with correct reference on push #12525
Conversation
[test] |
@@ -291,7 +420,7 @@ func TestAddExistingImageAndTag(t *testing.T) { | |||
Name: "existingImage", | |||
Namespace: "default", | |||
}, | |||
DockerImageReference: "localhost:5000/someproject/somerepo:imageID1", | |||
DockerImageReference: "localhost:5000/someproject/somerepo@sha256@" + testImageID, |
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.
@miminar Typo ?
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.
Fixed.
}, | ||
DockerImageReference: "localhost:5000/someproject/somerepo:" + imageID, | ||
DockerImageReference: "localhost:5000/somens/somerepo:" + imageID, |
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.
@miminar imageID
is a tag ?
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.
Good catch.
12d6b8d
to
25b394c
Compare
Yum flake in https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12971/
|
25b394c
to
5aefe9c
Compare
@@ -64,13 +64,25 @@ func (s *REST) Create(ctx kapi.Context, obj runtime.Object) (runtime.Object, err | |||
tag = api.DefaultImageTag | |||
} | |||
|
|||
if err := s.imageRegistry.CreateImage(ctx, &image); err != nil && !errors.IsAlreadyExists(err) { | |||
imageCreateErr := s.imageRegistry.CreateImage(ctx, &image) | |||
if imageCreateErr != nil && !errors.IsAlreadyExists(imageCreateErr) { | |||
return nil, err |
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.
return imageCreateErr ?
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.
Ouch, good catch!
return nil, err | ||
} | ||
|
||
// prefer dockerImageReference set on image for the tagEvent if the image is new | ||
ref := image.DockerImageReference | ||
if errors.IsAlreadyExists(imageCreateErr) && image.Annotations[api.ManagedByOpenShiftAnnotation] == "true" { |
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.
kapi.ConditionTrue ?
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.
This annotation is always checked against "true"
, kapi.ConditionTrue
is capitalized.
if errors.IsAlreadyExists(imageCreateErr) && image.Annotations[api.ManagedByOpenShiftAnnotation] == "true" { | ||
// the image is managed by us and, most probably, tagged in some other image stream | ||
// let's make the reference local to this stream | ||
if streamRef, err := api.DockerImageReferenceForStream(stream); 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.
do we want to log the error case?
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 might. I'll add a debug statement.
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.
Logging the error now.
5aefe9c
to
a6932ba
Compare
Comments addressed. |
@legionus if you have some time again, could you take another look? |
streamRef.ID = image.Name | ||
ref = streamRef.Exact() | ||
} else { | ||
utilruntime.HandleError(err) |
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.
Is there any specific reason to use this, instead of plain old glog?
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'm not really convinced one is more preferred than the other. In strategy and rest files under pkg/image/registry/
the use of utilruntime.HandleError()
vs glog.V(?).Info
is 7 to 8 .
But I'll rewrite it.
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.
Done.
a6932ba
to
ebcbf19
Compare
Thanks for the review. @legionus is it any better now? |
LGTM [merge] |
@miminar looks like you missed this one:
|
ebcbf19
to
119fbbe
Compare
Ouch! Fixed. |
Flake #12661 |
Prior to this patch, when docker pushed an image with manifest of schema 2 where the image already existed in the integrated registry, the tagevent used to point to the original image stream. With this patch, the dockerImageReference of the tag event will be rewritten to the target image stream of image stream mapping. Signed-off-by: Michal Minář <[email protected]>
119fbbe
to
4b5918e
Compare
Evaluated for origin test up to 4b5918e |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/13287/) (Base Commit: dced7f7) |
@soltysh can you please try to merge one more time? |
[merge] |
Evaluated for origin merge up to 4b5918e |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/13335/) (Base Commit: 249ec86) (Image: devenv-rhel7_5786) |
Prior to this patch, when docker pushed an image with manifest of schema 2 where the image already existed in the integrated registry, the tag event used to point to the original image stream.
With this patch, the dockerImageReference of the tag event will be rewritten to the target image stream of image stream mapping.
Resolves bz#1408993