maas datasource fails if no user-data

Bug #1172742 reported by Scott Moser on 2013-04-25
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Scott Moser
cloud-init (Ubuntu)
Scott Moser
Scott Moser

Bug Description

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

$ echo $maasds

$ 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}
  MAAS: {consumer_key: RW2x8P3mxz4ym5sQvc, metadata_url: '',
    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/", line 399, in <module>
  File "/usr/share/pyshared/cloudinit/sources/", line 383, in main
  File "/usr/share/pyshared/cloudinit/sources/", line 233, in read_maas_seed_url
  File "/usr/lib/python2.7/dist-packages/cloudinit/", line 690, in read_file_or_url
  File "/usr/lib/python2.7/dist-packages/cloudinit/", 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, 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 fails to set code in the UrlError
    From the debugger, we see why, in the exception handling block:

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

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/ usr/share/pyshared/cloudinit/]
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
 PATH=(custom, no user)
SourcePackage: cloud-init
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Scott Moser (smoser) wrote :
Changed in cloud-init (Ubuntu):
status: New → Confirmed
Scott Moser (smoser) wrote :

fixed in 0.7.2 (revno 812)

Changed in cloud-init:
status: New → Fix Released
importance: Undecided → Medium
assignee: nobody → Scott Moser (smoser)
Changed in cloud-init (Ubuntu):
importance: Undecided → Medium
assignee: nobody → Scott Moser (smoser)
status: Confirmed → Fix Released
Changed in cloud-init (Ubuntu Raring):
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Scott Moser (smoser)

Hello Scott, or anyone else affected,

Accepted cloud-init into raring-proposed. The package will build now and be available at in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at . Thank you in advance!

Changed in cloud-init (Ubuntu Raring):
status: Confirmed → Fix Committed
tags: added: verification-needed
Scott Moser (smoser) wrote :

verified fixed in 0.7.2-0ubuntu0.13.04.1

tags: added: cloud-images verification-done
removed: uec-images verification-needed
Launchpad Janitor (janitor) wrote :

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 <email address hidden> Thu, 20 Jun 2013 16:49:52 -0400

Changed in cloud-init (Ubuntu Raring):
status: Fix Committed → Fix Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

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

Duplicates of this bug

Other bug subscribers