maas datasource fails if no user-data

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

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)

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 http://launchpad.net/ubuntu/+source/cloud-init/0.7.2-0ubuntu0.13.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed 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 https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . 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