← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1172742] Re: maas datasource fails if no user-data

 

This bug was fixed in the package cloud-init - 0.7.2-0ubuntu0.13.04.1

---------------
cloud-init (0.7.2-0ubuntu0.13.04.1) raring-proposed; urgency=low

  * New upstream release.
    * fix merging routines to be backwards compatible (LP: #1180867)
    * fix maas datasource if user-data is not present (LP: #1172742)
    * fix for python 2.6
    * Fix chef omnibus installation support. (LP: #1182265)
 -- Scott Moser <smoser@xxxxxxxxxx>   Thu, 20 Jun 2013 16:49:52 -0400

** Changed in: cloud-init (Ubuntu Raring)
       Status: Fix Committed => Fix Released

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

Title:
  maas datasource fails if no user-data

Status in Init scripts for use on cloud images:
  Fix Released
Status in “cloud-init” package in Ubuntu:
  Fix Released
Status in “cloud-init” source package in Raring:
  Fix Released

Bug description:
  It seems that in re-working to use requests instead of urllib2, we
  regressed here.

  $ echo $maasds
  /usr/share/pyshared/cloudinit/sources/DataSourceMAAS.py

  $ echo == $cfg == ; sudo cat $cfg
  == /etc/cloud/cloud.cfg.d/90_dpkg_maas.cfg ==
  # written by cloud-init debian package per preseed entries
  # cloud-init/{maas-metadata-url,/maas-metadata-credentials}
  datasource:
    MAAS: {consumer_key: RW2x8P3mxz4ym5sQvc, metadata_url: 'http://192.168.64.1/MAAS/metadata/',
      token_key: XRH3eh9brJpAVGahGB, token_secret: zC4cUvHDjErAMkS7H92GKVKpQYqEVw2Y}

  $ sudo python $maasds --config=$cfg check-seed ${url%/}
  Traceback (most recent call last):
    File "/usr/share/pyshared/cloudinit/sources/DataSourceMAAS.py", line 399, in <module>
      main()
    File "/usr/share/pyshared/cloudinit/sources/DataSourceMAAS.py", line 383, in main
      version=args.apiver)
    File "/usr/share/pyshared/cloudinit/sources/DataSourceMAAS.py", line 233, in read_maas_seed_url
      ssl_details=ssl_details)
    File "/usr/lib/python2.7/dist-packages/cloudinit/util.py", line 690, in read_file_or_url
      ssl_details=ssl_details)
    File "/usr/lib/python2.7/dist-packages/cloudinit/url_helper.py", line 194, in readurl
      raise excps[-1]
  cloudinit.url_helper.UrlError: 401 Client Error: UNAUTHORIZED

  
  There are 2 issues here:
  a.) when re-trying, you actually need to re-generate headers.
      as implemented, DataSourceMAAS.py:read_maas_seed_url uses
      util.read_file_or_url without 'retries' param, which then defaults
      to 10.

      The first request returns (correctly) 404 on non-existant url.
      Subsequent requests then get 401 (possibly because the oauth headers
      have already been seen).  The last error is raised, thus showing
      the 401.

  b.) 'readurl' in url_helper.py fails to set code in the UrlError
      From the debugger, we see why, in the exception handling block:

      pdb> bool(isinstance(e, (exceptions.HTTPError)))
      True
      pdb> bool(hasattr(e, 'response'))
      True
      pdb> bool(e.response)
      False
      pdb> e.response
      <Response [404]>
      pdb> e.response.status_code
      404
      pdb> bool(hasattr(e.response, 'status_code'))
      True

  The fix for 'b' appears to be:
    -  and e.response)
    +  and hasattr(e.response, 'status_code'))

  The fix for 'a' may entail re-generating headers pre re-try.

  ProblemType: Bug
  DistroRelease: Ubuntu 13.04
  Package: cloud-init 0.7.2~bzr809-0ubuntu1 [modified: usr/share/pyshared/cloudinit/sources/DataSourceMAAS.py usr/share/pyshared/cloudinit/url_helper.py]
  ProcVersionSignature: Ubuntu 3.8.0-19.29-generic 3.8.8
  Uname: Linux 3.8.0-19-generic x86_64
  ApportVersion: 2.9.2-0ubuntu8
  Architecture: amd64
  Date: Thu Apr 25 14:31:19 2013
  MarkForUpload: True
  PackageArchitecture: all
  ProcEnviron:
   TERM=screen-bce
   PATH=(custom, no user)
   LANG=C
   SHELL=/bin/bash
  SourcePackage: cloud-init
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1172742/+subscriptions