← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1491311] [NEW] glanceclient/common/utils.py safe_header throws an exception on X-Auth-Token with None value

 

Public bug reported:

When using the glance-client with an internally generated admin context
(e.g. using nova_context.get_admin_context) the log_curl_request fails
due to safe_header trying to "value.encode('utf-8')" on a value that is
None.

An example of a stack trace (coming from RH juno distro's
nova.compute.manager but the potential problem exists in Kilo &
Liberty):

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 364, in decorated_function
    *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 3021, in snapshot_instance
    task_states.IMAGE_SNAPSHOT)
  File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 3052, in _snapshot_instance
    update_task_state)
  File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 1701, in snapshot
    self._detach_sriov_ports(instance, virt_dom)
  File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 3239, in _detach_sriov_ports
    instance)
  File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 3189, in _prepare_args_for_get_config
    context, self._image_api, image_ref, instance)
  File "/usr/lib/python2.7/site-packages/nova/compute/utils.py", line 201, in get_image_metadata
    image = image_api.get(context, image_id_or_uri)
  File "/usr/lib/python2.7/site-packages/nova/image/api.py", line 89, in get
    include_locations=include_locations)
  File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 311, in show
    _reraise_translated_image_exception(image_id)
  File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 309, in show
    image = self._client.call(context, version, 'get', image_id)
  File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 232, in call
    return getattr(client.images, method)(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/glanceclient/v1/images.py", line 126, in get
    % urlparse.quote(str(image_id)))
  File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 250, in head
    return self._request('HEAD', url, **kwargs)
  File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 194, in _request
    self.log_curl_request(method, conn_url, headers, data, kwargs)
  File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 101, in log_curl_request
    header = '-H \'%s: %s\'' % safe_header(key, value)
  File "/usr/lib/python2.7/site-packages/glanceclient/common/utils.py", line 394, in safe_header
    v = value.encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'

** Affects: glance
     Importance: Undecided
     Assignee: David Edery (david-edery)
         Status: New

** Changed in: glance
     Assignee: (unassigned) => David Edery (david-edery)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1491311

Title:
  glanceclient/common/utils.py safe_header throws an exception on X
  -Auth-Token with None value

Status in Glance:
  New

Bug description:
  When using the glance-client with an internally generated admin
  context (e.g. using nova_context.get_admin_context) the
  log_curl_request fails due to safe_header trying to
  "value.encode('utf-8')" on a value that is None.

  An example of a stack trace (coming from RH juno distro's
  nova.compute.manager but the potential problem exists in Kilo &
  Liberty):

  Traceback (most recent call last):
    File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 364, in decorated_function
      *args, **kwargs)
    File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 3021, in snapshot_instance
      task_states.IMAGE_SNAPSHOT)
    File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 3052, in _snapshot_instance
      update_task_state)
    File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 1701, in snapshot
      self._detach_sriov_ports(instance, virt_dom)
    File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 3239, in _detach_sriov_ports
      instance)
    File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 3189, in _prepare_args_for_get_config
      context, self._image_api, image_ref, instance)
    File "/usr/lib/python2.7/site-packages/nova/compute/utils.py", line 201, in get_image_metadata
      image = image_api.get(context, image_id_or_uri)
    File "/usr/lib/python2.7/site-packages/nova/image/api.py", line 89, in get
      include_locations=include_locations)
    File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 311, in show
      _reraise_translated_image_exception(image_id)
    File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 309, in show
      image = self._client.call(context, version, 'get', image_id)
    File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 232, in call
      return getattr(client.images, method)(*args, **kwargs)
    File "/usr/lib/python2.7/site-packages/glanceclient/v1/images.py", line 126, in get
      % urlparse.quote(str(image_id)))
    File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 250, in head
      return self._request('HEAD', url, **kwargs)
    File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 194, in _request
      self.log_curl_request(method, conn_url, headers, data, kwargs)
    File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 101, in log_curl_request
      header = '-H \'%s: %s\'' % safe_header(key, value)
    File "/usr/lib/python2.7/site-packages/glanceclient/common/utils.py", line 394, in safe_header
      v = value.encode('utf-8')
  AttributeError: 'NoneType' object has no attribute 'encode'

To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1491311/+subscriptions


Follow ups