Skip to content

lvm: exclude missing PVs but mark VGs are partial if they have one#165

Merged
ogayot merged 1 commit intocanonical:mainfrom
ogayot:missing-pv
Feb 24, 2026
Merged

lvm: exclude missing PVs but mark VGs are partial if they have one#165
ogayot merged 1 commit intocanonical:mainfrom
ogayot:missing-pv

Conversation

@ogayot
Copy link
Copy Markdown
Member

@ogayot ogayot commented Feb 19, 2026

Previously when dealing with a VG that had missing PV(s), probert storage would return something like:

  "lvm": {
    "logical_volumes": { [...] },
    "physical_volumes": {"ubuntu-vg": ["/dev/sda", "[unknown]"]},
    "volume_groups": {
      "ubuntu-vg": {
        "name": "ubuntu-vg", "devices": ["/dev/sda", "[unknown]"],
        "size": "234567890B"
      }
    }

And that would fail curtin storage-config validation because [unknown] does not correspond to a valid block dev.
And while curtin could explicitly treat [unknown], it feels better to handle it at probert's level.

We now remove [unknown] entries (which correspond to missing PVs) but mark a VG that has missing PVs as "partial: true":

  "lvm": {
    "logical_volumes": { [...] },
    "physical_volumes": {"ubuntu-vg": ["/dev/sda"]},
    "volume_groups": {
      "ubuntu-vg": {
        "name": "ubuntu-vg", "devices": ["/dev/sda"],
        "size": "234567890B", "partial": true
      }
    }

This should prevent curtin from failing to validate the storage config. If need be, we can add special handling for VGs that have partial: true in Subiquity and/or curtin.

LP:#2142196

Copy link
Copy Markdown
Collaborator

@Chris-Peterson444 Chris-Peterson444 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments but this looks good to me. I agree this sounds like a better fix for probert rather than curtin. Thanks!

VGS_REPORT = [
{
"vg_name": "vg1",
"pv_name": "/dev/vda5",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is there a reason to not put a newline between these two entries (here and elsewhere)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, besides saving a few lines. But I'll have them on their own lines.

probert/lvm.py Outdated
Comment on lines +165 to +171
# If the PV is missing the value is set typically set to "missing"
# but LVM2 checks for empty strings.
if report['pv_missing']:
missing_pvs += 1

if not report['pv_missing']:
devices.add(report.get('pv_name'))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what is the nuance with "...but LVM2 checks for empty strings" ?

Reading this I expect that the pv_missing key is always there and we only care if it's not empty, right?

So could this check be the following instead?

Suggested change
# If the PV is missing the value is set typically set to "missing"
# but LVM2 checks for empty strings.
if report['pv_missing']:
missing_pvs += 1
if not report['pv_missing']:
devices.add(report.get('pv_name'))
# If the PV is missing the value is set typically set to "missing"
# but LVM2 checks for empty strings.
if report['pv_missing']:
missing_pvs += 1
else:
devices.add(report.get('pv_name'))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly. I must have reordered instructions and didn't realize I was basically in a if something else ... construct.

Fixed, thanks!

probert/lvm.py Outdated
'devices': sorted(list(devices)),
'size': size})
'size': size,
'partial': missing_pvs >= 1})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'partial': missing_pvs >= 1})
'partial': missing_pvs > 0})

I find this slightly easier to read

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks!

Previously when dealing with a VG that had missing PV(s), probert storage would
return something like:

  "lvm": {
    "logical_volumes": { [...] },
    "physical_volumes": {"ubuntu-vg": ["/dev/sda", "[unknown]"]},
    "volume_groups": {
      "ubuntu-vg": {
        "name": "ubuntu-vg", "devices": ["/dev/sda", "[unknown]"],
        "size": "234567890B"
      }
    }

We now remove [unknown] entries (which correspond to missing PVs) but mark a VG
that has missing PVs as "partial: true":

  "lvm": {
    "logical_volumes": { [...] },
    "physical_volumes": {"ubuntu-vg": ["/dev/sda"]},
    "volume_groups": {
      "ubuntu-vg": {
        "name": "ubuntu-vg", "devices": ["/dev/sda"],
        "size": "234567890B", "partial": true
      }
    }

This should prevent curtin from failing to validate the storage config. If need
be, we can add special handling for VGs that have "partial: true".

LP: #2142196

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
@ogayot ogayot merged commit 4929e5f into canonical:main Feb 24, 2026
2 checks passed
@ogayot ogayot deleted the missing-pv branch February 24, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants