Merge ~smoser/cloud-init:fix/brightbox-less-matchy into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Ryan Harper
Approved revision: f8b0b19b2f0b985dbce7d1b85d75d0cc931283e1
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~smoser/cloud-init:fix/brightbox-less-matchy
Merge into: cloud-init:master
Diff against target: 71 lines (+16/-5)
3 files modified
cloudinit/sources/DataSourceEc2.py (+1/-1)
tests/unittests/test_ds_identify.py (+14/-2)
tools/ds-identify (+1/-2)
Reviewer Review Type Date Requested Status
Ryan Harper Approve
Server Team CI bot continuous-integration Approve
Dan Watkins Approve
Neil Wilson Pending
Review via email: mp+372622@code.launchpad.net

Commit message

Brightbox: restrict detection to require full domain match .brightbox.com

The detection for brightbox in both ds-identify and in
identify_brightbox would incorrectly match the domain 'bobrightbox',
which is not a brightbox platform. The fix here is to restrict
matching to '*.brightbox.com' rather than '*brightbox.com'

Also, while here remove a url to bug 1661693 which added the
knowledge of brightbox.

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

Just for reference, bug 1661693 has some real collected output that shows:

$ ( cd /sys/class/dmi/id && sudo grep -r . . ) 2>/dev/null
./product_serial:srv-fajvm.gb1.brightbox.com
./bios_vendor:Seabios
./product_version:RHEL 6.6.0 PC
./power/runtime_active_kids:0
./power/runtime_suspended_time:0
./power/runtime_enabled:disabled
./power/runtime_active_time:0
./power/control:auto
./power/async:disabled
./power/runtime_usage:0
./power/runtime_status:unsupported
./chassis_vendor:Red Hat
./modalias:dmi:bvnSeabios:bvr0.5.1:bd01/01/2007:svnRedHat:pnKVM:pvrRHEL6.6.0PC:cvnRedHat:ct1:cvr:
./product_uuid:D5BF3AE9-7D9C-2923-0B1E-B0ED967E7DF0
./bios_version:0.5.1
./sys_vendor:Red Hat
./chassis_type:1
./uevent:MODALIAS=dmi:bvnSeabios:bvr0.5.1:bd01/01/2007:svnRedHat:pnKVM:pvrRHEL6.6.0PC:cvnRedHat:ct1:cvr:
./product_name:KVM
./bios_date:01/01/2007

Revision history for this message
Scott Moser (smoser) wrote :

I happened to see this false positive when reviewing the add of zstack under
Bug 1841181.
  https://code.launchpad.net/~ruansx/cloud-init/+git/cloud-init/+merge/372445

Revision history for this message
Dan Watkins (oddbloke) :
review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:187401a1810946f9f02d88fd16e646d17a0e4346
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1116/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1116//rebuild

review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

This looks good to me. One in-line question about filing a bug and updating the comment in ds-identify to reference this issue rather than the original brightbox bug.

Revision history for this message
Scott Moser (smoser) :
Revision history for this message
Neil Wilson (neil-aldur) wrote :

Could you put actual product serials in the tests? For example

srv-otuxg.gb1.brightbox.com
srv-4mhaz.gb1.brightbox.com

It probably doesn't matter - until it does

Revision history for this message
Scott Moser (smoser) wrote :

> Could you put actual product serials in the tests? For example
>
> srv-otuxg.gb1.brightbox.com
> srv-4mhaz.gb1.brightbox.com
>
> It probably doesn't matter - until it does

Done!

Revision history for this message
Scott Moser (smoser) wrote :

Neil, thanks for the quick review.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:46fc93925f47d665689ec718fd181ba9f9dd9780
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1120/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1120//rebuild

review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

I'd like feedback from Ryan on the bug url.

I just now dropped it.
Complain about that if you'd like, or mark Approved.

Thanks.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:f8b0b19b2f0b985dbce7d1b85d75d0cc931283e1
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1121/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1121//rebuild

review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) :
Revision history for this message
Ryan Harper (raharper) wrote :

I'd still prefer a new bug and comment.

review: Approve
Revision history for this message
Scott Moser (smoser) wrote :

Just for the record, I'm not at all opposed to having opened a bug that stated this match was too wide. That was a good idea.

I was opposed to updating a comment in the code that pointed to a bug. I'd prefer to *not* have comments referring to external resources in the code itself. Rather cloud-init shoudl:
 a.) have good commit messages that reference bugs
 b.) have revision control history that can show those bugs
 c.) have documentation on datasources in doc/ that has links to official external resources where available.

Revision history for this message
Scott Moser (smoser) wrote :

Thanks for merging.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
2index 5c017bf..1010745 100644
3--- a/cloudinit/sources/DataSourceEc2.py
4+++ b/cloudinit/sources/DataSourceEc2.py
5@@ -473,7 +473,7 @@ def identify_aws(data):
6
7
8 def identify_brightbox(data):
9- if data['serial'].endswith('brightbox.com'):
10+ if data['serial'].endswith('.brightbox.com'):
11 return CloudNames.BRIGHTBOX
12
13
14diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
15index 587e699..de87be2 100644
16--- a/tests/unittests/test_ds_identify.py
17+++ b/tests/unittests/test_ds_identify.py
18@@ -195,6 +195,10 @@ class DsIdentifyBase(CiTestCase):
19 return self._check_via_dict(
20 data, RC_FOUND, dslist=[data.get('ds'), DS_NONE])
21
22+ def _test_ds_not_found(self, name):
23+ data = copy.deepcopy(VALID_CFG[name])
24+ return self._check_via_dict(data, RC_NOT_FOUND)
25+
26 def _check_via_dict(self, data, rc, dslist=None, **kwargs):
27 ret = self._call_via_dict(data, **kwargs)
28 good = False
29@@ -244,9 +248,13 @@ class TestDsIdentify(DsIdentifyBase):
30 self._test_ds_found('Ec2-xen')
31
32 def test_brightbox_is_ec2(self):
33- """EC2: product_serial ends with 'brightbox.com'"""
34+ """EC2: product_serial ends with '.brightbox.com'"""
35 self._test_ds_found('Ec2-brightbox')
36
37+ def test_bobrightbox_is_not_brightbox(self):
38+ """EC2: bobrightbox.com in product_serial is not brightbox'"""
39+ self._test_ds_not_found('Ec2-brightbox-negative')
40+
41 def test_gce_by_product_name(self):
42 """GCE identifies itself with product_name."""
43 self._test_ds_found('GCE')
44@@ -724,7 +732,11 @@ VALID_CFG = {
45 },
46 'Ec2-brightbox': {
47 'ds': 'Ec2',
48- 'files': {P_PRODUCT_SERIAL: 'facc6e2f.brightbox.com\n'},
49+ 'files': {P_PRODUCT_SERIAL: 'srv-otuxg.gb1.brightbox.com\n'},
50+ },
51+ 'Ec2-brightbox-negative': {
52+ 'ds': 'Ec2',
53+ 'files': {P_PRODUCT_SERIAL: 'tricky-host.bobrightbox.com\n'},
54 },
55 'GCE': {
56 'ds': 'GCE',
57diff --git a/tools/ds-identify b/tools/ds-identify
58index e0d4865..2447d14 100755
59--- a/tools/ds-identify
60+++ b/tools/ds-identify
61@@ -891,9 +891,8 @@ ec2_identify_platform() {
62 local default="$1"
63 local serial="${DI_DMI_PRODUCT_SERIAL}"
64
65- # brightbox https://bugs.launchpad.net/cloud-init/+bug/1661693
66 case "$serial" in
67- *brightbox.com) _RET="Brightbox"; return 0;;
68+ *.brightbox.com) _RET="Brightbox"; return 0;;
69 esac
70
71 # AWS http://docs.aws.amazon.com/AWSEC2/

Subscribers

People subscribed via source and target branches