Merge ~penick/cloud-init:handle_uppercase_labels into cloud-init:master

Proposed by James Penick
Status: Merged
Approved by: Chad Smith
Approved revision: 0687d25c69a01812c00206036ec02580299c04ac
Merge reported by: Chad Smith
Merged at revision: eb70975eaf37cf9549949f72e7647addb81a52ac
Proposed branch: ~penick/cloud-init:handle_uppercase_labels
Merge into: cloud-init:master
Diff against target: 96 lines (+28/-3)
4 files modified
cloudinit/sources/DataSourceConfigDrive.py (+2/-2)
tests/unittests/test_datasource/test_configdrive.py (+6/-0)
tests/unittests/test_ds_identify.py (+17/-0)
tools/ds-identify (+3/-1)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Review via email: mp+335286@code.launchpad.net

Commit message

Recognize uppercase vfat disk labels

New mkfs.vfat and fatlabel tools included in the dosfsutils package no
longer support creating vfat disks with lowercase labels. They silently
default to an all uppercase label eg CONFIG-2 instead of config-2. This
change makes cloud-init handle either upper or lower case.

LP: #1598783

Description of the change

Recognize uppercase vfat disk labels

New mkfs.vfat and fatlabel tools included in the dosfsutils package no longer support creating vfat disks with lowercase labels. They silently default to an all uppercase label eg CONFIG-2 instead of config-2. This change makes cloud-init handle either upper or lower case.

LP: #1598783

To post a comment you must log in.
Revision history for this message
Chad Smith (chad.smith) wrote :

Thank your contribution and making making cloud-init and Ubuntu better.

Cloud-init is governed by Canonical's Contributors Agreement. Before we can get your contribution upstream, I needed to confirm that you have signed that CLA. I didn't find your launchpad user name listed in the Launchpad group https://launchpad.net/~contributor-agreement-canonical.

To get there please review the CLA at https://www.ubuntu.com/legal/contributors and digitally sign it if you haven't already.

Thank you again for your help.

Revision history for this message
James Penick (penick) wrote :

CLA Signed, thanks!

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

Thanks for signing the CLA, forgot to refresh on this branch. +1 LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
2index 870b368..b8db626 100644
3--- a/cloudinit/sources/DataSourceConfigDrive.py
4+++ b/cloudinit/sources/DataSourceConfigDrive.py
5@@ -25,7 +25,7 @@ DEFAULT_METADATA = {
6 "instance-id": DEFAULT_IID,
7 }
8 FS_TYPES = ('vfat', 'iso9660')
9-LABEL_TYPES = ('config-2',)
10+LABEL_TYPES = ('config-2', 'CONFIG-2')
11 POSSIBLE_MOUNTS = ('sr', 'cd')
12 OPTICAL_DEVICES = tuple(('/dev/%s%s' % (z, i) for z in POSSIBLE_MOUNTS
13 for i in range(0, 2)))
14@@ -224,7 +224,7 @@ def find_candidate_devs(probe_optical=True):
15 config drive v2:
16 Disk should be:
17 * either vfat or iso9660 formated
18- * labeled with 'config-2'
19+ * labeled with 'config-2' or 'CONFIG-2'
20 """
21 # query optical drive to get it in blkid cache for 2.6 kernels
22 if probe_optical:
23diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
24index 6ef5a35..68400f2 100644
25--- a/tests/unittests/test_datasource/test_configdrive.py
26+++ b/tests/unittests/test_datasource/test_configdrive.py
27@@ -458,6 +458,12 @@ class TestConfigDriveDataSource(CiTestCase):
28 self.assertEqual(["/dev/vdb3"],
29 ds.find_candidate_devs())
30
31+ # Verify that uppercase labels are also found.
32+ devs_with_answers = {"TYPE=vfat": [],
33+ "TYPE=iso9660": ["/dev/vdb"],
34+ "LABEL=CONFIG-2": ["/dev/vdb"]}
35+ self.assertEqual(["/dev/vdb"], ds.find_candidate_devs())
36+
37 finally:
38 util.find_devs_with = orig_find_devs_with
39 util.is_partition = orig_is_partition
40diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
41index c9234ed..ad6c5cf 100644
42--- a/tests/unittests/test_ds_identify.py
43+++ b/tests/unittests/test_ds_identify.py
44@@ -232,6 +232,11 @@ class TestDsIdentify(CiTestCase):
45 self._test_ds_found('ConfigDrive')
46 return
47
48+ def test_config_drive_upper(self):
49+ """ConfigDrive datasource has a disk with LABEL=CONFIG-2."""
50+ self._test_ds_found('ConfigDriveUpper')
51+ return
52+
53 def test_policy_disabled(self):
54 """A Builtin policy of 'disabled' should return not found.
55
56@@ -503,6 +508,18 @@ VALID_CFG = {
57 },
58 ],
59 },
60+ 'ConfigDriveUpper': {
61+ 'ds': 'ConfigDrive',
62+ 'mocks': [
63+ {'name': 'blkid', 'ret': 0,
64+ 'out': blkid_out(
65+ [{'DEVNAME': 'vda1', 'TYPE': 'vfat', 'PARTUUID': uuid4()},
66+ {'DEVNAME': 'vda2', 'TYPE': 'ext4',
67+ 'LABEL': 'cloudimg-rootfs', 'PARTUUID': uuid4()},
68+ {'DEVNAME': 'vdb', 'TYPE': 'vfat', 'LABEL': 'CONFIG-2'}])
69+ },
70+ ],
71+ },
72 }
73
74 # vi: ts=4 expandtab
75diff --git a/tools/ds-identify b/tools/ds-identify
76index 5893a76..374c3ad 100755
77--- a/tools/ds-identify
78+++ b/tools/ds-identify
79@@ -579,6 +579,8 @@ dscheck_NoCloud() {
80 check_configdrive_v2() {
81 if has_fs_with_label "config-2"; then
82 return ${DS_FOUND}
83+ elif has_fs_with_label "CONFIG-2"; then
84+ return ${DS_FOUND}
85 fi
86 # look in /config-drive <vlc>/seed/config_drive for a directory
87 # openstack/YYYY-MM-DD format with a file meta_data.json
88@@ -666,7 +668,7 @@ is_cdrom_ovf() {
89
90 # explicitly skip known labels of other types. rd_rdfe is azure.
91 case "$label" in
92- config-2|rd_rdfe_stable*|cidata) return 1;;
93+ config-2|CONFIG-2|rd_rdfe_stable*|cidata) return 1;;
94 esac
95
96 local idstr="http://schemas.dmtf.org/ovf/environment/1"

Subscribers

People subscribed via source and target branches