-
Notifications
You must be signed in to change notification settings - Fork 1
fix(storage): drop invalid lvcreate --kernel flag breaking LVM-thin clone/restore (BUG-043) + n-rst harness (BUG-044) #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Andrei Kvapil (kvaps)
merged 2 commits into
main
from
fix/bug-043-lvm-clone-kernel-flag
Jun 14, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -346,6 +346,52 @@ func TestThinCreateSnapshot(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| // TestThinRestoreVolumeFromSnapshotIssuesThinSnapshotLvcreate is the | ||
| // BUG-043 regression pin. The clone / snapshot-restore seed path on | ||
| // LVM-thin must drive a plain thin-snapshot `lvcreate --snapshot | ||
| // --setactivationskip n --activate y --name <tgt> <vg>/<src-snap>` — | ||
| // the original code emitted a `--kernel` token, which is NOT a valid | ||
| // lvcreate option (`lvcreate: unrecognized option '--kernel'`, exit 3) | ||
| // on LVM >= 2.03. With that flag the destination backing LV was never | ||
| // created, so DRBD never came up and clone/restore onto LVM-thin pools | ||
| // never converged to UpToDate. The negative assertion (no `--kernel`) | ||
| // is load-bearing; the positive assertion pins the activation | ||
| // semantics so the cloned LV is actually usable (skip-activation | ||
| // cleared, activated). | ||
| func TestThinRestoreVolumeFromSnapshotIssuesThinSnapshotLvcreate(t *testing.T) { | ||
| fx := storage.NewFakeExec() | ||
| // Target LV not yet present → restore proceeds past the | ||
| // idempotency short-circuit. | ||
| fx.Expect("lvs --config devices { filter=['r|^/dev/drbd|','r|^/dev/zd|'] } --noheadings -o lv_name vg/pvc-2_00000", | ||
| storage.FakeResponse{Stdout: []byte("")}) | ||
| // Source snapshot LV exists → clone source is found. | ||
| fx.Expect("lvs --config devices { filter=['r|^/dev/drbd|','r|^/dev/zd|'] } --noheadings -o lv_name vg/pvc-1_snap-1_00000", | ||
| storage.FakeResponse{Stdout: []byte(" pvc-1_snap-1_00000")}) | ||
|
|
||
| p := lvm.NewThin(lvm.ThinConfig{VolumeGroup: "vg", ThinPool: "thinpool"}, fx) | ||
|
|
||
| err := p.RestoreVolumeFromSnapshot(t.Context(), | ||
| storage.Volume{ResourceName: "pvc-2", VolumeNumber: 0}, | ||
| storage.Snapshot{ResourceName: "pvc-1", SnapshotName: "snap-1"}) | ||
| if err != nil { | ||
| t.Fatalf("RestoreVolumeFromSnapshot: %v", err) | ||
| } | ||
|
|
||
| want := "lvcreate --config devices { filter=['r|^/dev/drbd|','r|^/dev/zd|'] } --snapshot --setactivationskip n --activate y --name pvc-2_00000 vg/pvc-1_snap-1_00000" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the expected command string to include the udev-less activation configuration ( \twant := \"lvcreate --config devices { filter=['r|^/dev/drbd|','r|^/dev/zd|'] } activation { udev_sync=0 udev_rules=0 } --snapshot --setactivationskip n --activate y --name pvc-2_00000 vg/pvc-1_snap-1_00000\" |
||
| if !slices.Contains(fx.CommandLines(), want) { | ||
| t.Errorf("expected %q in calls; got %v", want, fx.CommandLines()) | ||
| } | ||
|
|
||
| // BUG-043: no lvcreate invocation may carry the invalid `--kernel` | ||
| // flag — it makes LVM >= 2.03 reject the command with exit 3. | ||
| for _, line := range fx.CommandLines() { | ||
| if strings.HasPrefix(line, "lvcreate ") && strings.Contains(line, "--kernel") { | ||
| t.Errorf("BUG-043: thin restore lvcreate must NOT pass the invalid "+ | ||
| "--kernel flag; got %q", line) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // TestThinExecError surfaces the wrapped exec error verbatim. | ||
| func TestThinExecError(t *testing.T) { | ||
| fx := storage.NewFakeExec() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this
lvcreatecommand explicitly activates the volume (--activate y), it should useArgsUdevlessinstead ofArgsto apply the udev-less activation workaround (activation { udev_sync=0 udev_rules=0 }). In a containerized environment without a udev daemon, activating a volume without this workaround can cause the command to hang or race during device node creation (as documented in Bug 269 and Bug 305).