Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cmd/ndm_daemonset/probe/blkidprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func (bp *blkidProbe) FillBlockDeviceDetails(bd *blockdevice.BlockDevice) {
// Fortunately, the `libblkid` version in our base container (ubuntu 16.04)
// is `2.27.1`, will provide `PTUUID` tag, so we should fetch `PTUUID` from `blkid`.
if len(bd.PartitionInfo.PartitionTableUUID) == 0 {
bd.PartitionInfo.PartitionTableUUID = di.GetPartitionUUID()
bd.PartitionInfo.PartitionTableUUID = di.GetPartitionTableUUID()
}

// PARTUUID also is fetched using blkid, if udev is unable to get the data
if len(bd.PartitionInfo.PartitionEntryUUID) == 0 {
bd.PartitionInfo.PartitionEntryUUID = di.GetPartitionEntryUUID()
}
}
14 changes: 10 additions & 4 deletions pkg/blkid/blkid.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import (
const (
fsTypeIdentifier = "TYPE"
labelIdentifier = "LABEL"
partitionUUIDIdentifier = "PTUUID"
partitionTableUUIDIdentifier = "PTUUID"
partitionEntryUUIDIdentifier = "PARTUUID"
)

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

// GetPartitionUUID returns the partition UUID present on the disk by reading from the disk
// GetPartitionTableUUID returns the partition table UUID present on the disk by reading from the disk
// using libblkid
func (di *DeviceIdentifier) GetPartitionUUID() string {
return di.GetTagValue(partitionUUIDIdentifier)
func (di *DeviceIdentifier) GetPartitionTableUUID() string {
return di.GetTagValue(partitionTableUUIDIdentifier)
}

// GetPartitionEntryUUID returns the UUID of the partition, by reading from the disk using libblkid
func (di *DeviceIdentifier) GetPartitionEntryUUID() string {
return di.GetTagValue(partitionEntryUUIDIdentifier)
}

func (di *DeviceIdentifier) GetTagValue(tag string) string {
Expand Down