let the list images fails fast if the glance API is not responding
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance Client |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
The list method of the images.py file (for both v1 and v2) version returns a generators over a list of images.
In case the client can't talk correctly with the glance API we have an exception but this exception is actually raised only once the generator is consumed.
The reason for this is that inside the nested paginate method the client trigger the API call to get the list of images [1] and as that method is a generator the excpetion is not caught immediately.
That leads to some ugly behaviour by the callers of the client method, for example in nova we have to "force" a consume of the generator to catch any potential excpetions [2].
I think the client should fails fast if it gets an error from the API, to do that it should be enough to separate the fetching of the images from the generator.
What do you think?
Changed in python-glanceclient: | |
importance: | Undecided → Wishlist |
status: | New → Confirmed |
Failing early makes sense to me. You seem to know the code well, so do you know where the exception you are talking about is raised? I think it would also make sense to check the value of "resp" at https:/ /github. com/openstack/ python- glanceclient/ blob/14b9ba2981 1d63aa6b61e8773 76cc538c32aeadc /glanceclient/ v2/images. py#L108 .