Skip to content

Commit

Permalink
ceph: reject ceph dm devices
Browse files Browse the repository at this point in the history
Since rook#4219, lv devices are now
presented to ceph-volume when preparing the device.
So on this initial run, this won't fail because the dm hasn't been
created yet but if an orchestration is re-triggered, the prepare pod
ensures idempotency with the ceph-volume batch command.
Unfortunately, c-v seems to have a bug where it doesn't read the dm to
detect whether or not they are ceph members already.
Ceph bug: https://tracker.ceph.com/issues/43209

Signed-off-by: Sébastien Han <seb@redhat.com>
  • Loading branch information
leseb authored and RAJAT SINGH committed Dec 17, 2019
1 parent 9aa1bfb commit 55fa560
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pkg/util/sys/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import (
)

const (
DiskType = "disk"
SSDType = "ssd"
PartType = "part"
CryptType = "crypt"
LVMType = "lvm"
LinearType = "linear"
sgdisk = "sgdisk"
mountCmd = "mount"
DiskType = "disk"
SSDType = "ssd"
PartType = "part"
CryptType = "crypt"
LVMType = "lvm"
LinearType = "linear"
sgdisk = "sgdisk"
mountCmd = "mount"
cephLVPrefix = "ceph--"
)

type Partition struct {
Expand Down Expand Up @@ -146,6 +147,9 @@ func GetDevicePartitions(device string, executor exec.Executor) (partitions []Pa
p.Filesystem = v
}

partitions = append(partitions, p)
} else if strings.HasPrefix(name, cephLVPrefix) && props["TYPE"] == LVMType {
p := Partition{Name: name}
partitions = append(partitions, p)
}
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/util/sys/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ NAME="sda3" SIZE="1073741824" TYPE="part" PKNAME="sda"
NAME="usr" SIZE="1065345024" TYPE="crypt" PKNAME="sda3"
NAME="sda1" SIZE="134217728" TYPE="part" PKNAME="sda"
NAME="sda6" SIZE="134217728" TYPE="part" PKNAME="sda"`, nil
case run == 14:
return `NAME="dm-0" SIZE="100000" TYPE="lvm" PKNAME=""
NAME="ceph--89fa04fa--b93a--4874--9364--c95be3ec01c6-osd--data--70847bdb--2ec1--4874--98ba--d87d4860a70d" SIZE="31138512896" TYPE="lvm" PKNAME=""`, nil
}
return "", nil
},
Expand All @@ -193,6 +196,10 @@ NAME="sda6" SIZE="134217728" TYPE="part" PKNAME="sda"`, nil
assert.Equal(t, uint64(0x400000), unused)
assert.Equal(t, 7, len(partitions))

partitions, unused, err = GetDevicePartitions("dm-0", executor)
assert.Nil(t, err)
assert.Equal(t, 1, len(partitions))

partitions, unused, err = GetDevicePartitions("sdx", executor)
assert.Nil(t, err)
assert.Equal(t, 0, len(partitions))
Expand Down

0 comments on commit 55fa560

Please sign in to comment.