Merge ~smoser/cloud-init:bug/1715241-openstack-maybe-on-non-intel into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: c2637c7cfa67049f69ba0e4260deb98a8b84d81d
Merged at revision: dcbb901cc3e9e888bc8f87e87bdc0ca8436a2baa
Proposed branch: ~smoser/cloud-init:bug/1715241-openstack-maybe-on-non-intel
Merge into: cloud-init:master
Diff against target: 121 lines (+48/-3)
2 files modified
tests/unittests/test_ds_identify.py (+42/-3)
tools/ds-identify (+6/-0)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+330242@code.launchpad.net

Commit message

ds-identify: OpenStack on arch other than intel, identify 'maybe'

OpenStack Nova identifies itself only to Intel guests.
Make ds-identify return 'MAYBE' for OpenStack on non-intel arches.

An unnecessary change here is to rename the 'policy_nodmi' kwarg
to 'policy_no_dmi' in the related unit tests.

LP: #1715241

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) :
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:7e33dc9d39cc7de7be7cd5306db12b6c78ed684b
https://jenkins.ubuntu.com/server/job/cloud-init-ci/256/
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://jenkins.ubuntu.com/server/job/cloud-init-ci/256/rebuild

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

On September 5, 2017 5:20:40 PM EDT, Ryan Harper <email address hidden> wrote:
>
>
>Diff comments:
>
>> diff --git a/tests/unittests/test_ds_identify.py
>b/tests/unittests/test_ds_identify.py
>> index 1a81a89..c389029 100644
>> --- a/tests/unittests/test_ds_identify.py
>> +++ b/tests/unittests/test_ds_identify.py
>> @@ -48,6 +54,7 @@ P_SEED_DIR = "var/lib/cloud/seed"
>> P_DSID_CFG = "etc/cloud/ds-identify.cfg"
>>
>> MOCK_VIRT_IS_KVM = {'name': 'detect_virt', 'RET': 'kvm', 'ret': 0}
>> +MOCK_UNAME_IS_PPC64 = {'name': 'uname', 'out': UNAME_PPC64EL, 'ret':
>0}
>
>why is there 'out' here vs. 'RET' in the other mock?
>

Detect_virt is a function that sets the _RET variable. It has no stdout or stderr. Uname is actually a command that has its stdout and stderr mocked.

Revision history for this message
Ryan Harper (raharper) wrote :

It may be more obvious for the MOCK_XXX values always have the same keys (even if they don't use them).

MOCK_VIRT_IS_KVM = {
  'name': 'detect_virt',
  'out': "",
  'err': "",
  'RET': "kvm",
  'ret': 0
}

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

It might be more obvious, but its more verbose.
Same as calling a function with default arguments.
The default values are filled in via 'write_mock' in call.

the reason that we have 'detect_virt' as a shell function is that the call binary it is wrapping is 'detect-virt', which is not a valid posix shell function name... so we can't just mock it by adding a function (which is what the 'write_mock' function does).

Revision history for this message
Chad Smith (chad.smith) wrote :

Ok so this adds a slight cost to non-x86 platforms init-network stage by placing a maybe on OpenStack datasource right? This maybe openstack still won't affect datasources which now run in init-local because they would have already been discovered. So ConfigDrive, Ec2,SmartOS, OpenNebula,DO etc would have already been discovered if their platforms were non-x86.

Revision history for this message
Chad Smith (chad.smith) :
Revision history for this message
Scott Moser (smoser) wrote :

will address chad's comment.

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

addressed chad's request.

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

PASSED: Continuous integration, rev:1722c4b5601da81197289c3ca87837172039922b
https://jenkins.ubuntu.com/server/job/cloud-init-ci/265/
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://jenkins.ubuntu.com/server/job/cloud-init-ci/265/rebuild

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

PASSED: Continuous integration, rev:c2637c7cfa67049f69ba0e4260deb98a8b84d81d
https://jenkins.ubuntu.com/server/job/cloud-init-ci/266/
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://jenkins.ubuntu.com/server/job/cloud-init-ci/266/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 on this changeset. Thanks!

review: Approve

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
2index 1a81a89..92454d7 100644
3--- a/tests/unittests/test_ds_identify.py
4+++ b/tests/unittests/test_ds_identify.py
5@@ -11,6 +11,10 @@ from cloudinit.tests.helpers import (
6
7 UNAME_MYSYS = ("Linux bart 4.4.0-62-generic #83-Ubuntu "
8 "SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 GNU/Linux")
9+UNAME_PPC64EL = ("Linux diamond 4.4.0-83-generic #106-Ubuntu SMP "
10+ "Mon Jun 26 17:53:54 UTC 2017 "
11+ "ppc64le ppc64le ppc64le GNU/Linux")
12+
13 BLKID_EFI_ROOT = """
14 DEVNAME=/dev/sda1
15 UUID=8B36-5390
16@@ -23,6 +27,8 @@ TYPE=ext4
17 PARTUUID=30c65c77-e07d-4039-b2fb-88b1fb5fa1fc
18 """
19
20+POLICY_FOUND_ONLY = "search,found=all,maybe=none,notfound=disabled"
21+POLICY_FOUND_OR_MAYBE = "search,found=all,maybe=all,notfound=disabled"
22 DI_DEFAULT_POLICY = "search,found=all,maybe=all,notfound=enabled"
23 DI_DEFAULT_POLICY_NO_DMI = "search,found=all,maybe=all,notfound=disabled"
24
25@@ -48,6 +54,7 @@ P_SEED_DIR = "var/lib/cloud/seed"
26 P_DSID_CFG = "etc/cloud/ds-identify.cfg"
27
28 MOCK_VIRT_IS_KVM = {'name': 'detect_virt', 'RET': 'kvm', 'ret': 0}
29+MOCK_UNAME_IS_PPC64 = {'name': 'uname', 'out': UNAME_PPC64EL, 'ret': 0}
30
31
32 class TestDsIdentify(CiTestCase):
33@@ -55,7 +62,7 @@ class TestDsIdentify(CiTestCase):
34
35 def call(self, rootd=None, mocks=None, args=None, files=None,
36 policy_dmi=DI_DEFAULT_POLICY,
37- policy_nodmi=DI_DEFAULT_POLICY_NO_DMI):
38+ policy_no_dmi=DI_DEFAULT_POLICY_NO_DMI):
39 if args is None:
40 args = []
41 if mocks is None:
42@@ -81,7 +88,7 @@ class TestDsIdentify(CiTestCase):
43 "PATH_ROOT='%s'" % rootd,
44 ". " + self.dsid_path,
45 'DI_DEFAULT_POLICY="%s"' % policy_dmi,
46- 'DI_DEFAULT_POLICY_NO_DMI="%s"' % policy_nodmi,
47+ 'DI_DEFAULT_POLICY_NO_DMI="%s"' % policy_no_dmi,
48 ""
49 ]
50
51@@ -137,7 +144,7 @@ class TestDsIdentify(CiTestCase):
52 def _call_via_dict(self, data, rootd=None, **kwargs):
53 # return output of self.call with a dict input like VALID_CFG[item]
54 xwargs = {'rootd': rootd}
55- for k in ('mocks', 'args', 'policy_dmi', 'policy_nodmi', 'files'):
56+ for k in ('mocks', 'args', 'policy_dmi', 'policy_no_dmi', 'files'):
57 if k in data:
58 xwargs[k] = data[k]
59 if k in kwargs:
60@@ -261,6 +268,31 @@ class TestDsIdentify(CiTestCase):
61 self._check_via_dict(mydata, rc=RC_FOUND, dslist=['AliYun', DS_NONE],
62 policy_dmi=policy)
63
64+ def test_default_openstack_intel_is_found(self):
65+ """On Intel, openstack must be identified."""
66+ self._test_ds_found('OpenStack')
67+
68+ def test_openstack_on_non_intel_is_maybe(self):
69+ """On non-Intel, openstack without dmi info is maybe.
70+
71+ nova does not identify itself on platforms other than intel.
72+ https://bugs.launchpad.net/cloud-init/+bugs?field.tag=dsid-nova"""
73+
74+ data = VALID_CFG['OpenStack'].copy()
75+ del data['files'][P_PRODUCT_NAME]
76+ data.update({'policy_dmi': POLICY_FOUND_OR_MAYBE,
77+ 'policy_no_dmi': POLICY_FOUND_OR_MAYBE})
78+
79+ # this should show not found as default uname in tests is intel.
80+ # and intel openstack requires positive identification.
81+ self._check_via_dict(data, RC_NOT_FOUND, dslist=None)
82+
83+ # updating the uname to ppc64 though should get a maybe.
84+ data.update({'mocks': [MOCK_VIRT_IS_KVM, MOCK_UNAME_IS_PPC64]})
85+ (_, _, err, _, _) = self._check_via_dict(
86+ data, RC_FOUND, dslist=['OpenStack', 'None'])
87+ self.assertIn("check for 'OpenStack' returned maybe", err)
88+
89
90 def blkid_out(disks=None):
91 """Convert a list of disk dictionaries into blkid content."""
92@@ -341,6 +373,13 @@ VALID_CFG = {
93 'files': {P_PRODUCT_SERIAL: 'GoogleCloud-8f2e88f\n'},
94 'mocks': [MOCK_VIRT_IS_KVM],
95 },
96+ 'OpenStack': {
97+ 'ds': 'OpenStack',
98+ 'files': {P_PRODUCT_NAME: 'OpenStack Nova\n'},
99+ 'mocks': [MOCK_VIRT_IS_KVM],
100+ 'policy_dmi': POLICY_FOUND_ONLY,
101+ 'policy_no_dmi': POLICY_FOUND_ONLY,
102+ },
103 'ConfigDrive': {
104 'ds': 'ConfigDrive',
105 'mocks': [
106diff --git a/tools/ds-identify b/tools/ds-identify
107index 33bd299..ee5e05a 100755
108--- a/tools/ds-identify
109+++ b/tools/ds-identify
110@@ -833,6 +833,12 @@ dscheck_OpenStack() {
111 return ${DS_FOUND}
112 fi
113
114+ # LP: #1715241 : arch other than intel are not identified properly.
115+ case "$DI_UNAME_MACHINE" in
116+ i?86|x86_64) :;;
117+ *) return ${DS_MAYBE};;
118+ esac
119+
120 return ${DS_NOT_FOUND}
121 }
122

Subscribers

People subscribed via source and target branches