glance-replicator doesn't support https connection to glance api

Bug #1408940 reported by Jun Hong Li
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Glance
Wishlist
Itisha Dewan

Bug Description

Tried to call livecopy command with glance-replicator, encountered the following error:

[root@controller66 ~]# glance-replicator livecopy -M $r1_token -S $r2_token 192.168.101.10:9292 controller66.region2.com:9292
2014-12-04 14:03:11.766 804 CRITICAL glance [-] BadStatusLine
2014-12-04 14:03:11.766 804 TRACE glance Traceback (most recent call last):
2014-12-04 14:03:11.766 804 TRACE glance File "/usr/bin/glance-replicator", line 10, in <module>
2014-12-04 14:03:11.766 804 TRACE glance sys.exit(main())
2014-12-04 14:03:11.766 804 TRACE glance File "/usr/lib/python2.6/site-packages/glance/cmd/replicator.py", line 737, in main
2014-12-04 14:03:11.766 804 TRACE glance command(options, args)
2014-12-04 14:03:11.766 804 TRACE glance File "/usr/lib/python2.6/site-packages/glance/cmd/replicator.py", line 477, in replication_livecopy
2014-12-04 14:03:11.766 804 TRACE glance for image in master_client.get_images():
2014-12-04 14:03:11.766 804 TRACE glance File "/usr/lib/python2.6/site-packages/glance/cmd/replicator.py", line 154, in get_images
2014-12-04 14:03:11.766 804 TRACE glance response = self._http_request('GET', url, {}, '')
2014-12-04 14:03:11.766 804 TRACE glance File "/usr/lib/python2.6/site-packages/glance/cmd/replicator.py", line 115, in _http_request
2014-12-04 14:03:11.766 804 TRACE glance response = self.conn.getresponse()
2014-12-04 14:03:11.766 804 TRACE glance File "/usr/lib64/python2.6/httplib.py", line 990, in getresponse
2014-12-04 14:03:11.766 804 TRACE glance response.begin()
2014-12-04 14:03:11.766 804 TRACE glance File "/usr/lib64/python2.6/httplib.py", line 391, in begin
2014-12-04 14:03:11.766 804 TRACE glance version, status, reason = self._read_status()
2014-12-04 14:03:11.766 804 TRACE glance File "/usr/lib64/python2.6/httplib.py", line 355, in _read_status
2014-12-04 14:03:11.766 804 TRACE glance raise BadStatusLine(line)
2014-12-04 14:03:11.766 804 TRACE glance BadStatusLine
2014-12-04 14:03:11.766 804 TRACE glance

After checking the codes, I found that the connection is established with httplib.HTTPConnection for commands, which implies that https connection is not supported.

Revision history for this message
Jun Hong Li (junhongl) wrote :

I read the implementation of glance-replicator, and found that the api call is initiated by httplib.HTTPConnection only without considering the https case.

I think we can enhance it by adding httplib.HTTPSConnection into it. but i'm hesitating about it because i noticed the implementation of glance-replicator is kind of different from other clis, i don't see other clis like nova, cinder use httplib.

So i would like to see any comments from community, to figure out how to enhance glance-replicator to let it support https

Revision history for this message
Flavio Percoco (flaper87) wrote :

Hey @Jun,

Thanks for the report. I agree this code could use some refreshing/refactor. For instance, I'd probably use `requests` instead of bare httplib. Would you mind proposing a spec with your ideas and suggestions for this refactor?

I'll tag this bug as Wishlist as it's not a priority right now but it'd be nice to have.

Changed in glance:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Feilong Wang (flwang) wrote :

JunHong, I just go though the replicator code. I think you're right. Now we're hard code HTTPConnection. Obviously, it's wrong for the https case.

glance-replicator is a mangement command instead of the common cli. So it may contain some dirty code. And I agree with flavio87, requests would be a good option to replace httplib since it can take care https perfectly. It would be great if you can work on this refactor since it's a very helpful feature for enterprise users.

Ian Cordasco (icordasc)
Changed in glance:
assignee: nobody → Ian Cordasco (icordasc)
Revision history for this message
Brian Rosmaita (brian-rosmaita) wrote :

Itisha has a patch up to fix this bug: https://review.openstack.org/#/c/283335/

Ian, please take a look when you have a chance (I think you're the Glance person most familiar with requests).

Changed in glance:
assignee: Ian Cordasco (icordasc) → Itisha Dewan (ishadewan07)
status: Triaged → In Progress
Revision history for this message
Christopher Brown (snecklifter) wrote :

Itisha, are you still looking at getting this merged?

Thanks

Revision history for this message
Itisha Dewan (ishadewan07) wrote :

Yeah, I am working on this again now, looking to get it merged soon.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers