Merge lp:~niedbalski/ubuntu/vivid/curtin/fix-1263181 into lp:ubuntu/vivid/curtin

Proposed by Jorge Niedbalski on 2015-02-18
Status: Merged
Merge reported by: Sebastien Bacher
Merged at revision: not available
Proposed branch: lp:~niedbalski/ubuntu/vivid/curtin/fix-1263181
Merge into: lp:ubuntu/vivid/curtin
Diff against target: 91 lines (+17/-8)
3 files modified
curtin/block/__init__.py (+8/-2)
curtin/commands/block_meta.py (+3/-0)
helpers/common (+6/-6)
To merge this branch: bzr merge lp:~niedbalski/ubuntu/vivid/curtin/fix-1263181
Reviewer Review Type Date Requested Status
Ubuntu branches 2015-02-18 Pending
Review via email: mp+250163@code.launchpad.net

Description of the Change

Fixes LP bug: #1263181

To post a comment you must log in.
Scott Moser (smoser) wrote :

Jorge,
I'm really sorry this has taken so long to get to.
I'd appreciate you testing with the branch I pushed to lp:~smoser/ubuntu/vivid/curtin/fix-1263181 .
It has a small change, see the comment in the commit for the issue it (untested, but attempts to resolve).

We need to figure out how to reliably do all this stuff, addressing inconsistently named devices via more reliable mechanisms.

That said, i'm willing to take this if you test my branch there, and then add a function to helpers/common to reduce your 3 checks to use that.

Maybe something like:

path_for_existing_partition() {
    local blockdev="$1" partno="$2"
    for p in "${blockdev}$partno" "${blockdev}p${partno}"; do
        [ -b "$p" ] && _RET="$p" && return 0
    done
    return 1
}

then:
path_for_existing_partition "$target" 1 ||
   { error "no partition found for part 1 on $target"; return 1; }

Also, please update to address the check for partition 15 also.
[ -b "${target}1" ]

Scott Moser (smoser) wrote :

I'll be back in on tuesday morning and will try to take a further look at this then.
Again, I'm sorry i've not had time to get to this earlier.

Firl (celpa-firl) wrote :

Any directions for me to be able to test this? I have a DL 380 with 2 drives that I am trying to use for MaaS and it is showing up in lshw as a cciss device

Scott Moser (smoser) wrote :

the fix should be in wily.
you can just install the curtin debs from wily.
download from https://launchpad.net/ubuntu/+source/curtin manually , and then install.
you probably need curtin-common and python-curtin.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'curtin/block/__init__.py'
2--- curtin/block/__init__.py 2014-10-27 12:25:27 +0000
3+++ curtin/block/__init__.py 2015-02-18 16:18:41 +0000
4@@ -25,7 +25,7 @@
5
6
7 def get_dev_name_entry(devname):
8- bname = os.path.basename(devname)
9+ bname = devname.split('/dev/')[-1]
10 return (bname, "/dev/" + bname)
11
12
13@@ -62,12 +62,15 @@
14 'TYPE', 'UUID']
15 if args is None:
16 args = []
17+ args = [x.replace('!', '/') for x in args]
18+
19 # in order to avoid a very odd error with '-o' and all output fields above
20 # we just drop one. doesn't really matter which one.
21 keys.remove('SCHED')
22 basecmd = ['lsblk', '--noheadings', '--bytes', '--pairs',
23 '--output=' + ','.join(keys)]
24 (out, _err) = util.subp(basecmd + list(args), capture=True)
25+ out = out.replace('!', '/')
26 return _lsblock_pairs_to_dict(out)
27
28
29@@ -134,7 +137,10 @@
30 syspath = "/sys/class/block/%s" % bname
31
32 if not os.path.exists(syspath):
33- raise ValueError("%s had no syspath (%s)" % (devpath, syspath))
34+ syspath2 = "/sys/class/block/cciss!%s" % bname
35+ if not os.path.exists(syspath2):
36+ raise ValueError("%s had no syspath (%s)" % (devpath, syspath))
37+ syspath = syspath2
38
39 ptpath = os.path.join(syspath, "partition")
40 if not os.path.exists(ptpath):
41
42=== modified file 'curtin/commands/block_meta.py'
43--- curtin/commands/block_meta.py 2014-09-26 17:26:34 +0000
44+++ curtin/commands/block_meta.py 2015-02-18 16:18:41 +0000
45@@ -199,6 +199,9 @@
46 rootdev = devnode + "1"
47 bootdev = None
48
49+ if not os.path.exists(rootdev):
50+ rootdev = devnode + "p1"
51+
52 LOG.debug("rootdev=%s bootdev=%s fmt=%s bootpt=%s",
53 rootdev, bootdev, ptfmt, bootpt)
54 logtime("creating partition with: %s" % ' '.join(ptcmd),
55
56=== modified file 'helpers/common'
57--- helpers/common 2014-12-08 20:01:44 +0000
58+++ helpers/common 2015-02-18 16:18:41 +0000
59@@ -153,8 +153,8 @@
60 if $isblk; then
61 blockdev --rereadpt "$target"
62 udevadm settle
63- [ -b "${target}1" ] ||
64- { error "no partition found ${target}1"; return 1; }
65+ [ -b "${target}1" ] || [ -b "${target}p1" ] ||
66+ { error "no partition found ${target}1 or ${target}p1"; return 1; }
67 [ -b "${target}15" ] ||
68 { error "no partition found ${target}15"; return 1; }
69 if [ "$boot" = true ]; then
70@@ -191,8 +191,8 @@
71 if $isblk; then
72 blockdev --rereadpt "$target"
73 udevadm settle
74- [ -b "${target}1" ] ||
75- { error "no partition found ${target}1"; return 1; }
76+ [ -b "${target}1" ] || [ -b "${target}p1" ] ||
77+ { error "no partition found ${target}1 or ${target}p1"; return 1; }
78 [ -b "${target}15" ] ||
79 { error "no partition found ${target}15"; return 1; }
80 fi
81@@ -250,8 +250,8 @@
82 if $isblk; then
83 blockdev --rereadpt "$target"
84 udevadm settle
85- [ -b "${target}1" ] ||
86- { error "no partition found ${target}1"; return 1; }
87+ [ -b "${target}1" ] || [ -b "${target}p1" ] ||
88+ { error "no partition found ${target}1 or ${target}p1"; return 1; }
89 fi
90 out=$(wipefs "--offset=$(($start*512))" "$target" 2>&1) || {
91 error "$out";

Subscribers

People subscribed via source and target branches