← Back to team overview

curtin-dev team mailing list archive

[Merge] ~mwhudson/curtin:reformat-vs-preserve into curtin:master

 

Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:reformat-vs-preserve into curtin:master.

Commit message:
disk_handler: allow a reformat flag to override preserve

Currently preserve=true for raid means "preserve the RAID array" and
ALSO "preserve the partition table". So this adds a check so that if you
add reformat=true to a raid action with preserve=true, the RAID array
still gets a new partition table.

LP: #1932976


Requested reviews:
  curtin developers (curtin-dev)
Related bugs:
  Bug #1932976 in curtin: "cannot partition existing raid"
  https://bugs.launchpad.net/curtin/+bug/1932976

For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/404623
-- 
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:reformat-vs-preserve into curtin:master.
diff --git a/curtin/block/schemas.py b/curtin/block/schemas.py
index d846505..ee2700f 100644
--- a/curtin/block/schemas.py
+++ b/curtin/block/schemas.py
@@ -17,6 +17,7 @@ definitions = {
     'devices': {'type': 'array', 'items': {'$ref': '#/definitions/ref_id'}},
     'name': {'type': 'string'},
     'preserve': {'type': 'boolean'},
+    'reformat': {'type': 'boolean'},
     'ptable': {'type': 'string', 'enum': _ptables_valid},
     'size': {'type': ['string', 'number'],
              'minimum': 1,
@@ -126,6 +127,7 @@ DISK = {
         'multipath': {'type': 'string'},
         'device_id': {'type': 'string'},
         'preserve': {'$ref': '#/definitions/preserve'},
+        'reformat': {'$ref': '#/definitions/reformat'},
         'wipe': {'$ref': '#/definitions/wipe'},
         'type': {'const': 'disk'},
         'ptable': {'$ref': '#/definitions/ptable'},
@@ -322,6 +324,7 @@ RAID = {
         'mdname': {'$ref': '#/definitions/name'},  # XXX: Docs need updating
         'metadata': {'type': ['string', 'number']},
         'preserve': {'$ref': '#/definitions/preserve'},
+        'reformat': {'$ref': '#/definitions/reformat'},
         'ptable': {'$ref': '#/definitions/ptable'},
         'spare_devices': {'$ref': '#/definitions/devices'},
         'container': {'$ref': '#/definitions/id'},
diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
index 8cb2784..71a574e 100644
--- a/curtin/commands/block_meta.py
+++ b/curtin/commands/block_meta.py
@@ -583,7 +583,9 @@ def disk_handler(info, storage_config):
             'Invalid partition table type: %s in %s' % (ptable, info))
 
     disk = get_path_to_storage_volume(info.get('id'), storage_config)
-    if config.value_as_boolean(info.get('preserve')):
+    preserve = config.value_as_boolean(info.get('preserve'))
+    reformat = config.value_as_boolean(info.get('reformat'))
+    if preserve and not reformat:
         # Handle preserve flag, verifying if ptable specified in config
         if ptable and ptable != PTABLE_UNSUPPORTED:
             current_ptable = block.get_part_table_type(disk)

Follow ups