Merge ~smoser/cirros:fix/1598783-config-drive-upper-case into cirros:master

Proposed by Scott Moser
Status: Merged
Merged at revision: e3a288f0a72f0f7005aff8e364e94e19de49b27b
Proposed branch: ~smoser/cirros:fix/1598783-config-drive-upper-case
Merge into: cirros:master
Diff against target: 42 lines (+10/-7)
1 file modified
src/lib/cirros/ds/configdrive (+10/-7)
Reviewer Review Type Date Requested Status
Murilo Opsfelder Araújo (community) Approve
cirros developers Pending
Review via email: mp+335476@code.launchpad.net

Commit message

configdrive: support upper or lower case labels.

The label on a config drive may end up being 'config-2' or 'CONFIG-2'.
The bug explains well why that is.

This isn't ideal as we end up using blkid twice, but it is the simplist
fix for the moment.

LP: #1598783

To post a comment you must log in.
Revision history for this message
Murilo Opsfelder Araújo (mopsfelder) :
Revision history for this message
Scott Moser (smoser) wrote :

Good catch. Thank you

On December 20, 2017 6:41:02 PM EST, "Murilo Opsfelder Araújo" <email address hidden> wrote:
>
>
>Diff comments:
>
>> diff --git a/src/lib/cirros/ds/configdrive
>b/src/lib/cirros/ds/configdrive
>> index 9bc201d..0300bd6 100755
>> --- a/src/lib/cirros/ds/configdrive
>> +++ b/src/lib/cirros/ds/configdrive
>> @@ -22,11 +22,15 @@ search_local() {
>> local out_d="$1"
>> local devlist="" num="" found="" fstree_d=""
>> local raw_d="" dev="" rdir="" mdjson="" ud="" found=""
>> - find_devs_with "LABEL=$LABEL" ||
>> - { error "failed to find devs"; return 1; }
>> -
>> + local label=""
>> + for label in $LABELS; do
>> + find_devs_with "LABEL=$label" && devlist=${_RET} && break
>> + done
>> devlist=${_RET}
>> - [ -n "$devlist" ] || { debug 1 "no devices labeled $LABEL"; exit 0;
>}
>> + [ -n "$devlist" ] || {
>> + debug 1 "no devices with a label in $labels";
>
>Where does the variable $labels (in lowercase) come from? Wouldn't it
>be $LABELS?
>
>> + exit 0;
>> + }
>>
>> if [ -d "${SEED_PRE_D}" ]; then
>> devlist="$SEED_PRE_D $devlist"
>
>
>--
>https://code.launchpad.net/~smoser/cirros/+git/cirros/+merge/335476
>You are the owner of
>~smoser/cirros:fix/1598783-config-drive-upper-case.

Revision history for this message
Murilo Opsfelder Araújo (mopsfelder) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/lib/cirros/ds/configdrive b/src/lib/cirros/ds/configdrive
2index 9bc201d..e2bebb0 100755
3--- a/src/lib/cirros/ds/configdrive
4+++ b/src/lib/cirros/ds/configdrive
5@@ -3,7 +3,7 @@
6 VERBOSITY=0
7 CONFIG=/etc/cirros-init/configdrive
8 NAME="${0##*/}"
9-LABEL="config-2"
10+LABELS="config-2 CONFIG-2"
11 SEED_PRE_D="/var/lib/cloud/seed/configdrive-pre"
12 SEED_POST_D="/var/lib/cloud/seed/configdrive"
13
14@@ -22,11 +22,14 @@ search_local() {
15 local out_d="$1"
16 local devlist="" num="" found="" fstree_d=""
17 local raw_d="" dev="" rdir="" mdjson="" ud="" found=""
18- find_devs_with "LABEL=$LABEL" ||
19- { error "failed to find devs"; return 1; }
20-
21- devlist=${_RET}
22- [ -n "$devlist" ] || { debug 1 "no devices labeled $LABEL"; exit 0; }
23+ local label=""
24+ for label in $LABELS; do
25+ find_devs_with "LABEL=$label" && devlist=${_RET} && break
26+ done
27+ [ -n "$devlist" ] || {
28+ debug 1 "no devices with a label in $LABELS";
29+ exit 0;
30+ }
31
32 if [ -d "${SEED_PRE_D}" ]; then
33 devlist="$SEED_PRE_D $devlist"
34@@ -37,7 +40,7 @@ search_local() {
35
36 num=0
37 for dev in ${devlist}; do num=$(($num+1)); done
38- [ $num -eq 1 ] || debug 1 "multiple devices matching $LABEL: $devlist"
39+ [ $num -eq 1 ] || debug 1 "multiple devices matching $label: $devlist"
40
41 [ -d "$out_d" ] || mkdir -p "$out_d" ||
42 fail "failed to create outputdir: ${out_d}"

Subscribers

People subscribed via source and target branches