-
Notifications
You must be signed in to change notification settings - Fork 244
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
Include imagestreams in current namespace for catalog listing #618
Conversation
@surajnarwade I tried grepping for any other usages of |
How to test ?
|
pkg/catalog/catalog.go
Outdated
func getDefaultBuilderImages(client *occlient.Client) ([]CatalogImage, error) { | ||
imageStreams, err := client.GetImageStreams(occlient.OpenShiftNameSpace) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "unable to get Image Streams") | ||
} | ||
|
||
imageStreams2, err := client.GetImageStreams(client.GetCurrentProjectName()) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "unable to get Image Streams") |
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.
unable to get Image Streams from current project
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.
Ack
Verified as in : [redhat@localhost redhat-developer]$ oc project [redhat@localhost redhat-developer]$ oc get imagestreams -n myproject [redhat@localhost redhat-developer]$ odo catalog list |
@surajnarwade can you please revisit the PR I have incorporated your comments.. |
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.
odo create
needs also work with images from the user's namespace.
Sorry if it wasn't obvious from the original issue :-(
The main point is that user has to be able to create new component using builder image that is in his namespace.
pkg/catalog/catalog.go
Outdated
} | ||
|
||
imageStreams2, err := client.GetImageStreams(client.GetCurrentProjectName()) |
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 might be better to have a more descriptive name than imageStreams2
pkg/catalog/catalog_test.go
Outdated
name string | ||
args args | ||
wantErr bool | ||
wantOp []CatalogImage // Expect 1 duplicate because of 2 calls(1 for current namespace and another for openshift namespace) to client.GetImageStreams per call to list |
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.
@kadel Is there a better way of doing this test
i.e, https://github.com/redhat-developer/odo/pull/618/files#diff-1dfbb1796e8d3ca31e26fe9d003bb488R188 for particular parameters instead of whole list?
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 that this is ok, but the duplicate stuff is a bit weird
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.
The duplicate is because of 2 calls to the same function(although different params) https://github.com/redhat-developer/odo/pull/618/files#diff-6025e9b620e9321c03c11bf29e5c4dbdR401 and https://github.com/redhat-developer/odo/pull/618/files#diff-6025e9b620e9321c03c11bf29e5c4dbdR391 and the function to mock the call isn't per parameter(as in return x when function called with y as parameter else return z) and the mocking is to api function not its wrapper that is immediately used in our func...
pkg/catalog/catalog.go
Outdated
} | ||
|
||
imageStreams2, err := client.GetImageStreams(client.GetCurrentProjectName()) | ||
if err != nil { | ||
return nil, errors.Wrapf(err, "unable to get Image Streams from %s namespace", imageStreams2) |
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.
In this return statement it should be client.GetCurrentProjectName()
instead of imageStreams2
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.
Ack
pkg/catalog/catalog_test.go
Outdated
tags []string | ||
currentNSImageName string | ||
currentNamespace string | ||
currentNSImageTags []string |
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.
what is this variable for?
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.
There are 2 calls to the same function(although different params) https://github.com/redhat-developer/odo/pull/618/files#diff-6025e9b620e9321c03c11bf29e5c4dbdR401 and https://github.com/redhat-developer/odo/pull/618/files#diff-6025e9b620e9321c03c11bf29e5c4dbdR391 and the function to mock the call isn't per parameter(as in return x when function called with y as parameter else return z) and the mocking is to api function not its wrapper that is immediately used in our func...
Hence, inorder for the mocking function to be able to return values from both namespaces this was the only way possible because the mocking is not per parameter
pkg/catalog/catalog_test.go
Outdated
@@ -140,7 +186,7 @@ func TestList(t *testing.T) { | |||
// Fake the client with the appropriate arguments | |||
client, fakeClientSet := occlient.FakeNew() | |||
fakeClientSet.ImageClientset.PrependReactor("list", "imagestreams", func(action ktesting.Action) (bool, runtime.Object, error) { | |||
return true, testingutil.FakeImageStreams(tt.args.name, tt.args.namespace, tt.args.tags), nil | |||
return true, testingutil.FakeImageStreams(tt.args.name, tt.args.namespace, tt.args.tags, tt.args.currentNSImageName, tt.args.currentNamespace, tt.args.currentNSImageTags), 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.
why not just call FakeImageStreams
twice? Once to add images to "openshift" namespace, second time to add them to the other namespace. You don't have to modify FakeImageStreams
function at all.
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.
or add it two prependReactor calls
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.
will try this
but how would this work? the prependReactor doesn't take params as arg right to expect it to return 2 different NS values for 2 different calls based on params passed?
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.
@kadel Hey but it worked
pkg/catalog/catalog.go
Outdated
@@ -87,13 +87,19 @@ func VersionExists(client *occlient.Client, componentType string, componentVersi | |||
} | |||
|
|||
// getDefaultBuilderImages returns the default builder images available in the | |||
// openshift namespace | |||
// openshift namespace and current namespace | |||
func getDefaultBuilderImages(client *occlient.Client) ([]CatalogImage, error) { |
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 image should also return in what namespace the image is. as there might be two images with the same name in both openshift and current namespace. We also have to figure out what we will do if there is a collision.
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.
Ack
The o/p now looks like this: https://gist.github.com/anmolbabu/028a4caf25c009e3c63c82721f8146f3
It can list the new imagestream, but can not use it |
How are we going to solve the duplicity issue? What if the same image/ImageStream is in openshift project and in the current project? |
Still facing the issue: Error resolving ImageStreamTag python:latest in namespace openshift: imagestreams.image.openshift.io "python" not found Probably an additional param/config needs to be passed to build intialise request |
pkg/occlient/occlient.go
Outdated
return nil, errors.Wrapf(err, "no match found for : %s in namespace %s. error :%v", imageName, currentProjectName, e) | ||
} | ||
// Ignore the error if there was no error previously as the desired imagestream might be only in openshift namespace | ||
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.
you dont need this
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.
Ack
pkg/catalog/catalog.go
Outdated
imageStreams, err := client.GetImageStreams(occlient.OpenShiftNameSpace) | ||
// openshift namespace and current namespace | ||
// Return map[imageName: string]map[namespace:string][]tags:string | ||
func getDefaultBuilderImages(client *occlient.Client) (map[string]map[string][]string, error) { |
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.
uff this is pretty complicated return type. Wouldn't it be easier to create some nice struct for this?
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.
Iteration of struct array becomes tedious for any operations like search and delete.
But in a map the access is O(1) for most cases although at the cost of ease of code maintenance.
But it might now boil down to likely max size of list of imagestreams in current NS and openshift NS which looking at default size in my minishift deployment seems very small to bother about time complexities..
So, I am changing https://github.com/redhat-developer/odo/pull/618/files#diff-4373e1ac6258d2d589cb87e96b1fc994R13 to
type CatalogImage struct {
Name string
NamespacedTags map[Namespace: string]Tags: []string
}
What we need to do for this PR ?
|
|
@anmolbabu , if there's an issue with creating imagestream, follow this: http://suraj.pro/post/access-minishift-registry/ |
@kadel As how openshift works currently, and I think it might make sense, when there's imagestreams that are duplicated, in openshift namespace and current namespace, we should qualify the image or else, the local namespace should take precendence. Probably would also be good to show in the catalog listing as well:
Or add a visual indication to the printed list:
Then, it would be obvious which one is used. I used the term catalog here in my explanation although it might not be the best term. |
This PR adds `*` to the catalog that will be considered on priority for component creation in cases when a imagestream of same name exists in both openshift and the current namespaces. fixes redhat-developer#566 Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Extract the component type part from passed fully qualified or un-qualified default component type and use it as default chosen component name fixes redhat-developer#566 Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
fixes redhat-developer#566 Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
fixes redhat-developer#566 Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Thanks for being patient with the added tests! This LGTM! Thanks so much @anmolbabu |
This PR considers imagestream in current namespace along with
imagestreams in openshift namespace for:
odo catalog list
is now expected to show items in localnamespace along with those in openshift namespace
odo create <comp_name> --git <git_url>
is expectedto work even if comp_name is present in current namespace but not in openshift
namespace
fixes #566
Signed-off-by: anmolbabu anmolbudugutta@gmail.com