Merge ~smoser/cloud-init:bug/lp-1731868-unset-var-in-ds-identify into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Chad Smith
Approved revision: 23b34b55cd4107f8cc2a7228eec648811813793e
Merged at revision: a30a3bb5baec4da1d8f91385849e9b5b826678bf
Proposed branch: ~smoser/cloud-init:bug/lp-1731868-unset-var-in-ds-identify
Merge into: cloud-init:master
Diff against target: 72 lines (+27/-2)
2 files modified
tests/unittests/test_ds_identify.py (+25/-0)
tools/ds-identify (+2/-2)
Reviewer Review Type Date Requested Status
Ryan Harper Approve
Joshua Powers (community) Approve
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+335086@code.launchpad.net

Commit message

ds-identify: failure in NoCloud due to unset variable usage.

The previous OVF datasource change added a debug message that
referenced an un-used variable. The failure path would be triggered
if an image was booted with a iso9660 filesystem attached to a device
that was not a cdrom.

A unit test is added for the specific failure found.

Additional safety to avoid 'cidata' labels is also added to the OVF
checker.

LP: #1737704

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

FAILED: Continuous integration, rev:75eaa4d20584eb52969acc1b011816d7d7d099c4
https://jenkins.ubuntu.com/server/job/cloud-init-ci/619/
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://jenkins.ubuntu.com/server/job/cloud-init-ci/619/rebuild

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

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

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

+1 on this changeset. Was able to see the unit tests reproducing the failure path there. Yeah I guess we should have exercised this path in the first place in our unittests. Thanks for the quick fix.

review: Approve
Revision history for this message
Joshua Powers (powersj) wrote :

+1 fixes nocloud-kvm tests

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

We could look at using shellcheck; it's not perfect, sort of like pylint, but it does catch things like this; maybe just a manual run of shellcheck on ds-identify before commits?

Change looks good.

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

wrt shellcheck, it did not find this error, and generally complains about too many things.
I've seen it and it *can* be useful, but not immediately.

It lists 113 things, 2 of which were valid (unused variables).

The '--exclude' that you'd have to pass are coarsely grained, and I'm not interested in litering code with '#make-shellcheck-happy'

http://paste.ubuntu.com/26171686/

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

On Tue, Dec 12, 2017 at 12:12 PM, Scott Moser <email address hidden>
wrote:

> wrt shellcheck, it did not find this error, and generally complains about
> too many things.
> I've seen it and it *can* be useful, but not immediately.
>
> It lists 113 things, 2 of which were valid (unused variables).
>

Besides the local, the rest seemed pretty valid.

>
> The '--exclude' that you'd have to pass are coarsely grained, and I'm not
> interested in litering code with '#make-shellcheck-happy'
>

I don't want to do that either, but it suggests reasonable fixes IMO.

>
> http://paste.ubuntu.com/26171686/
> --
> https://code.launchpad.net/~smoser/cloud-init/+git/cloud-
> init/+merge/335086
> You are reviewing the proposed merge of ~smoser/cloud-init:bug/lp-
> 1731868-unset-var-in-ds-identify into cloud-init:master.
>

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 3f1a671..c9234ed 100644
3--- a/tests/unittests/test_ds_identify.py
4+++ b/tests/unittests/test_ds_identify.py
5@@ -27,6 +27,14 @@ TYPE=ext4
6 PARTUUID=30c65c77-e07d-4039-b2fb-88b1fb5fa1fc
7 """
8
9+# this is a Ubuntu 18.04 disk.img output (dual uefi and bios bootable)
10+BLKID_UEFI_UBUNTU = [
11+ {'DEVNAME': 'vda1', 'TYPE': 'ext4', 'PARTUUID': uuid4(), 'UUID': uuid4()},
12+ {'DEVNAME': 'vda14', 'PARTUUID': uuid4()},
13+ {'DEVNAME': 'vda15', 'TYPE': 'vfat', 'LABEL': 'UEFI', 'PARTUUID': uuid4(),
14+ 'UUID': '5F55-129B'}]
15+
16+
17 POLICY_FOUND_ONLY = "search,found=all,maybe=none,notfound=disabled"
18 POLICY_FOUND_OR_MAYBE = "search,found=all,maybe=all,notfound=disabled"
19 DI_DEFAULT_POLICY = "search,found=all,maybe=all,notfound=enabled"
20@@ -340,6 +348,10 @@ class TestDsIdentify(CiTestCase):
21 self._check_via_dict(
22 ovf_cdrom_by_label, rc=RC_FOUND, dslist=['OVF', DS_NONE])
23
24+ def test_default_nocloud_as_vdb_iso9660(self):
25+ """NoCloud is found with iso9660 filesystem on non-cdrom disk."""
26+ self._test_ds_found('NoCloud')
27+
28
29 def blkid_out(disks=None):
30 """Convert a list of disk dictionaries into blkid content."""
31@@ -422,6 +434,19 @@ VALID_CFG = {
32 'files': {P_PRODUCT_SERIAL: 'GoogleCloud-8f2e88f\n'},
33 'mocks': [MOCK_VIRT_IS_KVM],
34 },
35+ 'NoCloud': {
36+ 'ds': 'NoCloud',
37+ 'mocks': [
38+ MOCK_VIRT_IS_KVM,
39+ {'name': 'blkid', 'ret': 0,
40+ 'out': blkid_out(
41+ BLKID_UEFI_UBUNTU +
42+ [{'DEVNAME': 'vdb', 'TYPE': 'iso9660', 'LABEL': 'cidata'}])},
43+ ],
44+ 'files': {
45+ 'dev/vdb': 'pretend iso content for cidata\n',
46+ }
47+ },
48 'OpenStack': {
49 'ds': 'OpenStack',
50 'files': {P_PRODUCT_NAME: 'OpenStack Nova\n'},
51diff --git a/tools/ds-identify b/tools/ds-identify
52index 4c59d7b..5893a76 100755
53--- a/tools/ds-identify
54+++ b/tools/ds-identify
55@@ -657,7 +657,7 @@ is_cdrom_ovf() {
56 # skip devices that don't look like cdrom paths.
57 case "$dev" in
58 /dev/sr[0-9]|/dev/hd[a-z]) :;;
59- *) debug 1 "skipping iso dev $d"
60+ *) debug 1 "skipping iso dev $dev"
61 return 1;;
62 esac
63
64@@ -666,7 +666,7 @@ is_cdrom_ovf() {
65
66 # explicitly skip known labels of other types. rd_rdfe is azure.
67 case "$label" in
68- config-2|rd_rdfe_stable*) return 1;;
69+ config-2|rd_rdfe_stable*|cidata) return 1;;
70 esac
71
72 local idstr="http://schemas.dmtf.org/ovf/environment/1"

Subscribers

People subscribed via source and target branches