fog-openstack
fog-openstack copied to clipboard
Re-authenticate in case of token expiry fails for Glance
Refreshing of expired tokens seems to be broken.
- Fog::Image::OpenStack::V1::Real#initialize calls
authenticate
from included core module. Then @path is set to a supported version by https://github.com/fog/fog-openstack/blob/master/lib/fog/openstack/image_v1.rb#L119-L124. - Fog::OpenStack::Common#request rescues from Excon::Errors::Unauthorized with
authenticate
andretry
(https://github.com/fog/fog-openstack/blob/90342522f68a85fbe82bc7b32ee68350df7b506e/lib/fog/openstack/common.rb#L22-L28) - Fog::OpenStack::Core#authenticate sets the path to keystone auth path in https://github.com/fog/fog-openstack/blob/90342522f68a85fbe82bc7b32ee68350df7b506e/lib/fog/openstack/core.rb#L102
- The retry of Fog::OpenStack::Common#request no longer has a valid Glance version as part of the path. Hence Glance responds with HTTP 300 and a json of supported versions.
You can see a good overall log of the consequences in the BOSH OpenStack CPI issue https://github.com/cloudfoundry-incubator/bosh-openstack-cpi-release/issues/40. I.e. 300 multiple choices while actively waiting for the image to be ready to use (repeated image.reload & check state) in the fog-openstack consumer log. A 401 followed by a 300 in the Glance HTTP log.
I could imagine this is a more general problem that just with Fog::Image::OpenStack. The root cause seems to be in common.rb and core.rb.
@dhague Have you seen something like this before?
Any opinions on how the token caching works from one of the maintainers? Are @loewenstein's thoughts from above correct?
I don't think so, retry has been refactored to set the api path https://github.com/fog/fog-openstack/blob/f72d2fce5fc0c89f9a901eb97767b095f4b3522a/lib/fog/openstack/core.rb#L85-L92 which gets done in the glance parts https://github.com/fog/fog-openstack/blob/4217d76368aa0c570b268e96a3cf21f760ccc967/lib/fog/image/openstack/v2.rb#L129-L135 https://github.com/fog/fog-openstack/blob/4217d76368aa0c570b268e96a3cf21f760ccc967/lib/fog/image/openstack/v1.rb#L121-L127 and thus should work