Merge lp:~wesley-wiedenmeier/curtin/curtin-1543263 into lp:~curtin-dev/curtin/trunk

Proposed by Wesley Wiedenmeier
Status: Merged
Merged at revision: 351
Proposed branch: lp:~wesley-wiedenmeier/curtin/curtin-1543263
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 95 lines (+49/-2)
3 files modified
curtin/commands/block_meta.py (+17/-1)
examples/tests/basic.yaml (+16/-0)
tests/vmtests/test_basic.py (+16/-1)
To merge this branch: bzr merge lp:~wesley-wiedenmeier/curtin/curtin-1543263
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Needs Fixing
Scott Moser (community) Approve
Review via email: mp+285825@code.launchpad.net

Commit message

partitioning: limited support for odd ordering of partition numbers

This fixes a bug in the partitioning code where it assumes that the
previous partition is numbered N-1. That is not always the case.
The change here is very focused on:
 a.) fixing bug 1543263 and allowing maas to send configuration
     for power that "hides" the PReP partition as number 15
     so they don't have to really show it to the user.
 b.) Being non-invasive.

Ultimately, we want to re-write the partitioning code to walk
through the storage config and correctly fill in number, start
and end for each entry. That is a more invasive and time-consuming
change though.

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

FAILED: Continuous integration, rev:350
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~wesley-wiedenmeier/curtin/curtin-1543263/+merge/285825/+edit-commit-message

https://server-team-jenkins.canonical.com/job/curtin-ci/159/
Executed test runs:
    None: https://server-team-jenkins.canonical.com/job/generic-update-mp/156/console

Click here to trigger a rebuild:
https://server-team-jenkins.canonical.com/job/curtin-ci/159/rebuild

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

nitpicks in line, but need fixing.

review: Needs Fixing
351. By Wesley Wiedenmeier

Dropped print statements and added a debug message for partition number

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

Use better style string formatting for syslog

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

I'm running a test with your suggested vmtest change at http://paste.ubuntu.com/15021746/
I approve of this for nwo.

review: Approve
353. By Wesley Wiedenmeier

Added test case for partition numbering

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'curtin/commands/block_meta.py'
--- curtin/commands/block_meta.py 2016-02-11 18:52:29 +0000
+++ curtin/commands/block_meta.py 2016-02-12 04:14:05 +0000
@@ -503,6 +503,19 @@
503 return logicaldisks503 return logicaldisks
504504
505505
506def find_previous_partition(disk_id, part_id, storage_config):
507 last_partnum = 0
508 for item_id, command in storage_config.items():
509 if item_id == part_id:
510 return last_partnum
511 if command['type'] == 'partition' and command['device'] == disk_id:
512 if 'number' in item_id:
513 last_partnum = item_id['number']
514 else:
515 last_partnum += 1
516 return None
517
518
506def partition_handler(info, storage_config):519def partition_handler(info, storage_config):
507 device = info.get('device')520 device = info.get('device')
508 size = info.get('size')521 size = info.get('size')
@@ -540,8 +553,11 @@
540 previous_partition = "/sys/block/%s/%s%s/" % \553 previous_partition = "/sys/block/%s/%s%s/" % \
541 (disk_kname, disk_kname, extended_part_no)554 (disk_kname, disk_kname, extended_part_no)
542 else:555 else:
556 pnum = find_previous_partition(device, info['id'], storage_config)
557 LOG.debug("previous partition number for '%s' found to be '%s'",
558 info.get('id'), pnum)
543 previous_partition = "/sys/block/%s/%s%s/" % \559 previous_partition = "/sys/block/%s/%s%s/" % \
544 (disk_kname, disk_kname, partnumber - 1)560 (disk_kname, disk_kname, pnum)
545 with open(os.path.join(previous_partition, "size"), "r") as fp:561 with open(os.path.join(previous_partition, "size"), "r") as fp:
546 previous_size = int(fp.read())562 previous_size = int(fp.read())
547 with open(os.path.join(previous_partition, "start"), "r") as fp:563 with open(os.path.join(previous_partition, "start"), "r") as fp:
548564
=== modified file 'examples/tests/basic.yaml'
--- examples/tests/basic.yaml 2015-12-07 15:14:55 +0000
+++ examples/tests/basic.yaml 2016-02-12 04:14:05 +0000
@@ -54,3 +54,19 @@
54 type: mount54 type: mount
55 path: /btrfs55 path: /btrfs
56 device: btrfs_disk_fmt_id56 device: btrfs_disk_fmt_id
57 - id: pnum_disk
58 type: disk
59 path: /dev/vde
60 name: sparedisk
61 wipe: superblock
62 ptable: gpt
63 - id: pnum_disk_p1
64 type: partition
65 number: 1
66 size: 1GB
67 device: pnum_disk
68 - id: pnum_disk_p2
69 type: partition
70 number: 10
71 size: 1GB
72 device: pnum_disk
5773
=== modified file 'tests/vmtests/test_basic.py'
--- tests/vmtests/test_basic.py 2015-12-17 22:07:00 +0000
+++ tests/vmtests/test_basic.py 2016-02-12 04:14:05 +0000
@@ -13,7 +13,7 @@
13 conf_file = "examples/tests/basic.yaml"13 conf_file = "examples/tests/basic.yaml"
14 install_timeout = 60014 install_timeout = 600
15 boot_timeout = 12015 boot_timeout = 120
16 extra_disks = ['128G', '128G']16 extra_disks = ['128G', '128G', '4G']
17 disk_to_check = {'main_disk': 1, 'main_disk': 2}17 disk_to_check = {'main_disk': 1, 'main_disk': 2}
18 collect_scripts = [textwrap.dedent("""18 collect_scripts = [textwrap.dedent("""
19 cd OUTPUT_COLLECT_D19 cd OUTPUT_COLLECT_D
@@ -43,6 +43,21 @@
43 blkid_info = self.get_blkid_data("blkid_output_vda")43 blkid_info = self.get_blkid_data("blkid_output_vda")
44 self.assertEquals(blkid_info["PTTYPE"], "dos")44 self.assertEquals(blkid_info["PTTYPE"], "dos")
4545
46 def test_partition_numbers(self):
47 # vde should have partitions 1 and 10
48 disk = "vde"
49 proc_partitions_path = os.path.join(self.td.collect,
50 'proc_partitions')
51 self.assertTrue(os.path.exists(proc_partitions_path))
52 found = []
53 with open(proc_partitions_path, 'r') as fp:
54 for line in fp.readlines():
55 if disk in line:
56 found.append(line.split()[3])
57 # /proc/partitions should have 3 lines with 'vde' in them.
58 expected = [disk + s for s in ["", "1", "10"]]
59 self.assertEqual(found, expected)
60
46 def test_partitions(self):61 def test_partitions(self):
47 with open(os.path.join(self.td.collect, "fstab")) as fp:62 with open(os.path.join(self.td.collect, "fstab")) as fp:
48 fstab_lines = fp.readlines()63 fstab_lines = fp.readlines()

Subscribers

People subscribed via source and target branches