Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
devicemanager/lvm: Ask lvm not to clear newly created volume
Browse files Browse the repository at this point in the history
On non-alpine images, Due to some race conditions lvcreate fails to clear the
newly created block device as the result, volume creation fails.

https://linux-lvm.redhat.narkive.com/9Pu8Wro2/lvcreate-device-not-cleared-aborting-failed-to-wipe-start-of-new-lv

As we explicitly clearing the device in our code, we need not depend on lvm's
device clearing, hence this change ask's lvcreate not to zero the device.
  • Loading branch information
avalluri committed May 8, 2019
1 parent c1f09ba commit 69579bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/pmem-device-manager/pmd-lvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ func (lvm *pmemLvm) CreateDevice(name string, size uint64, nsmode string) error

for _, vg := range vgs {
if vg.free >= size {
// In some container environments clearing device fails with race condition.
// So, we ask lvm not to clear(-Zn) the newly created device, instead we do ourself in later stage.
// lvcreate takes size in MBytes if no unit
if _, err := pmemexec.RunCommand("lvcreate", "-L", strSz, "-n", name, vg.name); err != nil {
if _, err := pmemexec.RunCommand("lvcreate", "-Zn", "-L", strSz, "-n", name, vg.name); err != nil {
glog.V(3).Infof("lvcreate failed with error: %v, trying for next free region", err)
} else {
// clear start of device to avoid old data being recognized as file system
Expand Down

0 comments on commit 69579bd

Please sign in to comment.