Skip to content

Commit 7c64d44

Browse files
authored
fix(blkid): add partition entry uuid to blkid probe (#657)
udev is not able to fetch the partition entry uuid in CentOS 7, since PARTUUID is not supported in libblkid 2.23. Use the libblkid from the base container to fetch the partition entry UUID if it was not filled in by udev. Signed-off-by: Akhil Mohan <akhil.mohan@datacore.com>
1 parent 42746e4 commit 7c64d44

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

cmd/ndm_daemonset/probe/blkidprobe.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ func (bp *blkidProbe) FillBlockDeviceDetails(bd *blockdevice.BlockDevice) {
6969
// Fortunately, the `libblkid` version in our base container (ubuntu 16.04)
7070
// is `2.27.1`, will provide `PTUUID` tag, so we should fetch `PTUUID` from `blkid`.
7171
if len(bd.PartitionInfo.PartitionTableUUID) == 0 {
72-
bd.PartitionInfo.PartitionTableUUID = di.GetPartitionUUID()
72+
bd.PartitionInfo.PartitionTableUUID = di.GetPartitionTableUUID()
73+
}
74+
75+
// PARTUUID also is fetched using blkid, if udev is unable to get the data
76+
if len(bd.PartitionInfo.PartitionEntryUUID) == 0 {
77+
bd.PartitionInfo.PartitionEntryUUID = di.GetPartitionEntryUUID()
7378
}
7479
}

pkg/blkid/blkid.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import (
3333
const (
3434
fsTypeIdentifier = "TYPE"
3535
labelIdentifier = "LABEL"
36-
partitionUUIDIdentifier = "PTUUID"
36+
partitionTableUUIDIdentifier = "PTUUID"
37+
partitionEntryUUIDIdentifier = "PARTUUID"
3738
)
3839

3940
type DeviceIdentifier struct {
@@ -52,10 +53,15 @@ func (di *DeviceIdentifier) GetOnDiskLabel() string {
5253
return di.GetTagValue(labelIdentifier)
5354
}
5455

55-
// GetPartitionUUID returns the partition UUID present on the disk by reading from the disk
56+
// GetPartitionTableUUID returns the partition table UUID present on the disk by reading from the disk
5657
// using libblkid
57-
func (di *DeviceIdentifier) GetPartitionUUID() string {
58-
return di.GetTagValue(partitionUUIDIdentifier)
58+
func (di *DeviceIdentifier) GetPartitionTableUUID() string {
59+
return di.GetTagValue(partitionTableUUIDIdentifier)
60+
}
61+
62+
// GetPartitionEntryUUID returns the UUID of the partition, by reading from the disk using libblkid
63+
func (di *DeviceIdentifier) GetPartitionEntryUUID() string {
64+
return di.GetTagValue(partitionEntryUUIDIdentifier)
5965
}
6066

6167
func (di *DeviceIdentifier) GetTagValue(tag string) string {

0 commit comments

Comments
 (0)