Merge ~smoser/cloud-init:feature/enable-aliyun into cloud-init:master
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Scott Moser on 2017-05-30 | ||||
| Approved revision: | 8db9cd3f44c3848574a7e690a53bb3d8962fb9f6 | ||||
| Merged at revision: | 4a60af54957634920e84a928aa22b4fc9a6dfd11 | ||||
| Proposed branch: | ~smoser/cloud-init:feature/enable-aliyun | ||||
| Merge into: | cloud-init:master | ||||
| Diff against target: |
231 lines (+96/-8) 7 files modified
cloudinit/settings.py (+1/-0) cloudinit/sources/DataSourceAliYun.py (+13/-1) cloudinit/sources/DataSourceEc2.py (+7/-0) tests/unittests/test_datasource/test_aliyun.py (+49/-2) tests/unittests/test_datasource/test_common.py (+1/-0) tests/unittests/test_ds_identify.py (+18/-0) tools/ds-identify (+7/-5) |
||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Junjie.Wang (community) | 2017-05-30 | Approve on 2017-05-31 | |
| Server Team CI bot | continuous-integration | 2017-05-30 | Approve on 2017-05-30 |
| Chad Smith | 2017-05-30 | Approve on 2017-05-30 | |
| cloud-init commiters | 2017-05-30 | Pending | |
|
Review via email:
|
|||
This proposal supersedes a proposal from 2017-05-25.
Commit Message
AliYun: Enable platform identification and enable by default.
AliYun cloud platform is now identifying themselves by setting the dmi
product id to the well known value "Alibaba Cloud ECS". The changes here
identify that properly in tools/ds-identify and in the DataSourceAliYun.
Since the 'get_data' for AliYun now identifies itself correctly, we can
enable AliYun by default.
LP: #1638931
| Scott Moser (smoser) wrote : | # |
| Scott Moser (smoser) wrote : | # |
This has no merge proposal shown because of bug 1693543
FAILED: Continuous integration, rev:2722a2f7d7f
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
PASSED: Continuous integration, rev:
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
| Junjie.Wang (jingni.wjj) wrote : | # |
Hi,smoser
I review this code change at
https:/
that good ,and test it in our AliYun platform ,it's also work fine .thanks
| Chad Smith (chad.smith) wrote : | # |
Thanks for this good work approved pending your decision on the following comments.
My comments will be made per the consolidated visual diff @ http://
line 49 in the above diff:
Since order of datasources matters to determine which datasource is detectred first in both cloudinit/
line 95:
- Please add a comment in the code about the intent of NO_EC2_METADATA in in cloudinit/
line 103 cloudinit/
- s/NO_EC2_
line 104 cloudinit/
I see no unit test coverage of "elif self.cloud_platform == Platforms.
line 124 tests/unittests
Since we have mocked _is_aliyun we aren't really testing anywhere that we are getting this info from dmi. It might be better to mock util.read_dmi_data as that is the interface we are calling into. Then we can validate the calls into that interface as follows:
@mock.
@httpretty.
def test_with_
line 140 tests/unittests
These network tests feel like they aren't all testing the right things. Why is the test
Why is test_expected_
line 175: Since DataSourceAliYu
| Scott Moser (smoser) wrote : | # |
> Thanks for this good work approved pending your decision on the following
> comments.
>
> My comments will be made per the consolidated visual diff @
> http://
>
> line 49 in the above diff:
> Since order of datasources matters to determine which datasource is detectred
> first in both cloudinit/
> DI_DSLIST_DEFAULT. Why are these two lists not ordered the same? AliYun is
> placed just before Ec2 in ds-identify but way at the beginning settings.py.
> Should we make an attempt to ensure both lists are consistently ordered?
I think it probably makes sense to put AliYun at the end on both lists
at this point. I will make that change.
the list in ds_identify is only used in the case that there is no explicit
list defined in /etc/cloud/
of a case that this list is referenced (at least not in Ubuntu where the
package contains a list of datasources that can be configured with
dpkg-reconfigure).
The list that is in ds-identify right now is kind of done over iterative
development when i first worked on it. It started out as a list
where I had definitive sources at the front and network datasources
at the back ('Ec2', 'GCE'...).
I believe I put 'Aliyun' before 'Ec2' because I was thinking that Ec2 might
end up claiming 'found' on Aliyun cloud. That is now not the case unless
Aliyun starts crafting dmi data that looks like Ec2... which would break
themselves.
I think we can/should put some more thought into how this list (and that in
settings.py) is maintained. Once 'strict_id' is turned on in EC2 by default
we will really be able to re-order almost at whim.
> line 95:
> - Please add a comment in the code about the intent of NO_EC2_METADATA in in
> cloudinit/
> devs looking at the code for a subclass of DataSourceEc2 could know how and
> why to make use of this value. commit messages are lost, comments live forever
> :).
Well, I sort of agree. (I read 'git log' and 'git blame' a lot, and expect
that other developers do also. I don't take the time to write useful
commit messages for no reason).
> line 103 cloudinit/
> - s/NO_EC2_
> code as it frequently involves a second glance to figure out what the intent
> of the variable is to determine context.
OK.
>
> line 104 cloudinit/
> I see no unit test coverage of "elif self.cloud_platform ==
> Platforms.
i'll try to put something together.
> line 124 tests/unittests
> Since we have mocked _is_aliyun we aren't really testing anywhere that we
> are getting this info from dmi. It might be better to mock util.read_dmi_data
> as that is the interface we are calling into. Then we can validate the calls
> into that interface as follows:
>
> @mock.patch(
> @httpretty.activate
> def test_with_
> m_read_
> self.regist_defa...
| Scott Moser (smoser) wrote : | # |
OK, So i thought some more, and with regard to the order of the two 'datasource_lists'.
Some points to think about
a.) If EC2's 'strict_id' is set to "warn" or "false", then the Ec2 datasource
will poll and time out very annoyingly. "true" is the default setting in
trunk, but not yet in xenial. historically, Ec2 was the first "polling"
datasource. Any sources that did not positively identify themselves had to be
after Ec2 in the default list. That was because "the early bird gets the
worm". Basically in the event of cloud-init not having good information on
where it was running Ec2 got first dibs.
b.) the order in tools/ds-identify doesnt matter so much.
Remember that this list is only consulted if there is no datasource_list declared in /etc/cloud/
the following matter:
i.) if there were multiple datasources "DS_FOUND" (or DS_MAYBE), then they are placed into the list in the order of the DI_DSLIST_DEFAULT. All DS_FOUND preceeed DS_MAYBE in such a list.
ii.) if there are no DS_FOUND by ds-identify, and strict_id is false, then Ec2 would be return DS_MAYBE. Having it first in that list means others after it would have to wait.
PASSED: Continuous integration, rev:1f7e87c2996
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
| Chad Smith (chad.smith) wrote : | # |
Thanks for the clarification and background on the datasource list ordering. And I see your point on git log (as that's how I determined what the intent of the var was in the first place).
+1 on the separate mocked unit test for _is_aliyun() to exercise the interface we are actually calling. It'd be nice at some point if we had a fake dmidecode or SMBIOS test resource which could be used to seed datasource testing. Then we wouldn't really have to 'mock', just inject required dmi values and let things run.
Per the importing the ay.ALIYUN_PRODUCT variable into unit tests, I agree with your consistency comment. Having a module variable imported into that module's unit tests only asserts that the module consistently references whatever the variable's value is (correct or incorrect). I'd suggest though that copying that string directly into the unit test does the same type of conisitency validation. The module writer could have defined a variable which won't work on aliyun systems in the first place, and then tested that ALIYUN_PRODUCT == "blah" as well. It doesn't actually assert that this value will work on aliyun environments. We'd probably have to rely on integration tests for that.
Also this suggestion was to try to also bridge some consistency between our cloudinit/
FAILED: Continuous integration, rev:3ae4ef707d4
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
PASSED: Continuous integration, rev:
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
PASSED: Continuous integration, rev:8db9cd3f44c
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/


This supersedes https:/ /code.launchpad .net/~jingni. wjj/cloud- init/+git/ cloud-init/ +merge/ 323306.
It has some re-wording of Junjie's commit, and then a commit to show my additional changes.