-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Existing images are tagged with correct reference on push #12525
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package imagestreammapping | ||
|
||
import ( | ||
"github.com/golang/glog" | ||
|
||
kapi "k8s.io/kubernetes/pkg/api" | ||
"k8s.io/kubernetes/pkg/api/errors" | ||
"k8s.io/kubernetes/pkg/api/rest" | ||
|
@@ -64,13 +66,27 @@ 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) { | ||
return nil, err | ||
imageCreateErr := s.imageRegistry.CreateImage(ctx, &image) | ||
if imageCreateErr != nil && !errors.IsAlreadyExists(imageCreateErr) { | ||
return nil, imageCreateErr | ||
} | ||
|
||
// 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" { | ||
// 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Logging the error now. |
||
streamRef.ID = image.Name | ||
ref = streamRef.Exact() | ||
} else { | ||
glog.V(4).Infof("Failed to get dockerImageReference for stream %s/%s: %v", stream.Namespace, stream.Name, err) | ||
} | ||
} | ||
|
||
next := api.TagEvent{ | ||
Created: unversioned.Now(), | ||
DockerImageReference: image.DockerImageReference, | ||
DockerImageReference: ref, | ||
Image: image.Name, | ||
} | ||
|
||
|
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.