Merge ~chad.smith/cloud-init:unify-datasource-get-data into cloud-init:master
| Status: | Merged |
|---|---|
| Approved by: | Chad Smith on 2017-12-06 |
| Approved revision: | 88aefe1fc382327420b91b71246226e7fc378006 |
| Merged at revision: | 0cf6db3617e0cebeb89c4809396f84360827e96c |
| Proposed branch: | ~chad.smith/cloud-init:unify-datasource-get-data |
| Merge into: | cloud-init:master |
| Prerequisite: | ~chad.smith/cloud-init:feature/move-base-testcase |
| Diff against target: |
1726 lines (+517/-153) 47 files modified
cloudinit/analyze/__main__.py (+3/-1) cloudinit/analyze/dump.py (+1/-7) cloudinit/net/tests/test_dhcp.py (+0/-4) cloudinit/sources/DataSourceAliYun.py (+1/-0) cloudinit/sources/DataSourceAltCloud.py (+4/-1) cloudinit/sources/DataSourceAzure.py (+3/-1) cloudinit/sources/DataSourceBigstep.py (+4/-1) cloudinit/sources/DataSourceCloudSigma.py (+4/-1) cloudinit/sources/DataSourceCloudStack.py (+4/-1) cloudinit/sources/DataSourceConfigDrive.py (+4/-1) cloudinit/sources/DataSourceDigitalOcean.py (+4/-1) cloudinit/sources/DataSourceEc2.py (+9/-3) cloudinit/sources/DataSourceGCE.py (+4/-1) cloudinit/sources/DataSourceMAAS.py (+4/-1) cloudinit/sources/DataSourceNoCloud.py (+4/-1) cloudinit/sources/DataSourceNone.py (+4/-1) cloudinit/sources/DataSourceOVF.py (+4/-1) cloudinit/sources/DataSourceOpenNebula.py (+4/-1) cloudinit/sources/DataSourceOpenStack.py (+4/-1) cloudinit/sources/DataSourceScaleway.py (+3/-1) cloudinit/sources/DataSourceSmartOS.py (+4/-1) cloudinit/sources/__init__.py (+116/-13) cloudinit/sources/tests/__init__.py (+0/-0) cloudinit/sources/tests/test_init.py (+202/-0) cloudinit/tests/helpers.py (+0/-10) cloudinit/util.py (+24/-9) tests/unittests/test_datasource/test_aliyun.py (+1/-1) tests/unittests/test_datasource/test_altcloud.py (+13/-9) tests/unittests/test_datasource/test_azure.py (+15/-13) tests/unittests/test_datasource/test_azure_helper.py (+0/-4) tests/unittests/test_datasource/test_cloudsigma.py (+9/-4) tests/unittests/test_datasource/test_cloudstack.py (+13/-10) tests/unittests/test_datasource/test_configdrive.py (+2/-1) tests/unittests/test_datasource/test_digitalocean.py (+7/-4) tests/unittests/test_datasource/test_ec2.py (+2/-1) tests/unittests/test_datasource/test_gce.py (+2/-1) tests/unittests/test_datasource/test_nocloud.py (+6/-8) tests/unittests/test_datasource/test_opennebula.py (+5/-7) tests/unittests/test_datasource/test_openstack.py (+8/-4) tests/unittests/test_datasource/test_scaleway.py (+9/-4) tests/unittests/test_datasource/test_smartos.py (+2/-1) tests/unittests/test_ds_identify.py (+2/-2) tests/unittests/test_handler/test_handler_chef.py (+0/-4) tests/unittests/test_handler/test_handler_lxd.py (+0/-5) tests/unittests/test_runs/test_merge_run.py (+1/-0) tests/unittests/test_runs/test_simple_run.py (+2/-1) tests/unittests/test_vmware_config_file.py (+0/-6) |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Scott Moser | 2017-09-01 | Approve on 2017-12-05 | |
| Server Team CI bot | continuous-integration | 2017-09-01 | Approve on 2017-12-05 |
|
Review via email:
|
|||
Description of the Change
Datasources: Formalize DataSource get_data and related properties.
Each DataSource subclass must define its own get_data method. This branch
formalizes our DataSource class to require that subclasses define an
explicit dsname for sourcing cloud-config datasource configuration.
Subclasses must also override the _get_data method or a
NotImplementedError is raised.
The branch also writes /run/cloud-
contains all meta-data, user-data and vendor-data and a standardized set
of metadata keys in a json blob which other utilities with root-access
could make use of. Because some meta-data or user-data is potentially
sensitive the file is only readable by root.
Generally most metadata content types should be json serializable. If
specific keys or values are not serializable, those specific values will
be base64encoded and the key path will be listed under the top-level key
'base64-
other TypeErrors or UnicodeDecodeEr
/var/log/
| Ryan Harper (raharper) wrote : | # |
In commit message:
s/it's/its
I'd replace 'caches' metadata, to dumps; cache implies (to me) reuse but cloud-init doesn't use the json file at all (nor would it since it's already part of the cloud object).
Drop the 'Subsequent' sentence; while you may follow up with that it's not needed as part of the commit message.
Finally, question on the aborting if we have unserializable data; is it possible to skip/replace the binary data so we don't have an all-or-nothing situation?
- 2da6f0d... by Chad Smith on 2017-09-08
- c60d25d... by Chad Smith on 2017-09-08
| Chad Smith (chad.smith) wrote : | # |
Thanks for the review Ryan, pushed changes per your review comments. We should be able to handle TypeError issues during json errors and attempt encoding or exclusion of those items instead of bailing on everything.
FAILED: Continuous integration, rev:3cf4ab99853
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
FAILED: Continuous integration, rev:95c1151f048
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
- 145541c... by Chad Smith on 2017-09-08
PASSED: Continuous integration, rev:c0009178b95
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Scott Moser (smoser) wrote : | # |
userdata_raw for an instance should *always* be bytes, which is *always* unserializble in json:
>>> json.dumps({'key': b'bytes value'})
TypeError: Object of type 'bytes' is not JSON serializable
heres a test that shows more actual content of user-data:
http://
So that means that unless something is wrong in the Datasource, the 'user-data' (and maybe vendor-data) blobs are going to be redacted with the Warning.
Is meta-data one of our "normalized" values ?
I kind of expected that our exported data looks like:
{'instance-id': <string>,
'hostname': <hostname>,
'user-data'
'vendor-data':
'base64-keys': ['user-data', 'vendor-data', 'ec2/blobs/blob1', 'ec2/more-blobs/0']
'_datasource': {
'ec2-
'blobs': { 'blob1': <bytes> },
'more-blobs': [b'blobby'],
}
So we'd have generally available keys in the top (many of them taken out of 'meta-data') with well known names, and then '_datasource' or other name with non-guaranteed stuff under that key.
Maybe i'm thinknig to far ahead, but I'm afraid of putting something in /run/cloud-
the 'base64-keys' thought above is that those would be paths in the data to keys whose value is binary data. We should also make a distinction between a value whos contents raise error on .decode('utf-8') and a value that should generally be regarded as binary. Ie, we shouldnt just "try and see" if we can decode the values because then that leads to oddness for the user where sometimes a given key path might be in base64-keys and other times not.
I don't like that the value of a key can be a string 'Warning:' ... that seems
hard for someone to identify the difference between a possible but strange
value and "didnt work". We should never come to this case I do not think.
And if we do, raising exception is prbably ok.
- 25481bf... by Chad Smith on 2017-10-04
- 14b44a8... by Chad Smith on 2017-10-04
- 3020dfa... by Chad Smith on 2017-10-04
- 24ffc07... by Chad Smith on 2017-10-04
- eb66299... by Chad Smith on 2017-10-04
FAILED: Continuous integration, rev:5d4105b8bf1
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
- 71fe9b0... by Chad Smith on 2017-10-04
FAILED: Continuous integration, rev:f29e17db6a3
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
- 477ddd6... by Chad Smith on 2017-10-04
PASSED: Continuous integration, rev:8415d1035bb
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
- 6274b97... by Chad Smith on 2017-10-04
| Chad Smith (chad.smith) wrote : | # |
@smoser: addressed discussions we had at the Ubuntu Rally about standardizing metadata keys in instance-data.json and versioning it. The branch is getting big (and therefore risky) so I didn't address some cloud-name renames and surfacing 'platform' in this branch as it would involve a bit of renaming in DataSourceEc2.
FAILED: Continuous integration, rev:39d79188da5
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
FAILED: MAAS Compatability Testing
Click here to trigger a rebuild:
https:/
PASSED: Continuous integration, rev:39d79188da5
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
- d4ae4e6... by Chad Smith on 2017-11-20
PASSED: Continuous integration, rev:874f2a2bd45
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Chad Smith (chad.smith) wrote : | # |
Latest example of instance-data.json on EC2 with the following user-data:
$ echo 'I2Nsb3VkLWNvbm
#cloud-config
timezone: Pacific/Honolulu
- 23b31d5... by Chad Smith on 2017-11-20
| Chad Smith (chad.smith) wrote : | # |
let's just use hyphens throughout http://
PASSED: Continuous integration, rev:87def7b76e6
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Scott Moser (smoser) wrote : | # |
you have some merge conflicts in the diff.
i'll review more later.
this does look good though.
- 7bbc057... by Chad Smith on 2017-11-29
FAILED: Continuous integration, rev:eb1ad7e9711
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
- 05c7419... by Chad Smith on 2017-11-29
PASSED: Continuous integration, rev:05c74190b01
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Chad Smith (chad.smith) wrote : | # |
One more pass of instance-data from lxc and ec2 validated no Tracebacks as well.
| Chad Smith (chad.smith) wrote : | # |
Since we are playing around, here's Azure instance-data. not much there http://
- d936c64... by Chad Smith on 2017-11-30
FAILED: Continuous integration, rev:d936c64b352
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
| Chad Smith (chad.smith) wrote : | # |
And openstack instance data for the win
http://
| Scott Moser (smoser) wrote : | # |
you do still have merge conflicts.
- 88aefe1... by Chad Smith on 2017-12-05
PASSED: Continuous integration, rev:88aefe1fc38
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Scott Moser (smoser) wrote : | # |
Two things
a.) i'd like some doc/ I think this can be followed up with in another branch
b.) your commit message has a long line. i read and quickly fixed a small thing
or two.
| Chad Smith (chad.smith) wrote : | # |
GCE instance-data for reference
http://


PASSED: Continuous integration, rev:e04585b6417 a9a75a834c0b8ed 22adf8ffe435a2 /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 255/
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 255/rebuild
https:/