Skip to content

Commit

Permalink
Merge pull request rook#14645 from Papawy/cleanup-metadata-wal
Browse files Browse the repository at this point in the history
osd: discover metadata and wal devices for raw device cleanup
  • Loading branch information
travisn authored Sep 3, 2024
2 parents c9d98d9 + 52ca68d commit 04eecf7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
30 changes: 19 additions & 11 deletions pkg/daemon/ceph/cleanup/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,29 @@ func (s *DiskSanitizer) executeSanitizeCommand(osdInfo oposd.OSDInfo, wg *sync.W
// On return, notify the WaitGroup that we’re done
defer wg.Done()

output, err := s.context.Executor.ExecuteCommandWithCombinedOutput(shredUtility, s.buildShredArgs(osdInfo.BlockPath)...)
if err != nil {
logger.Errorf("failed to sanitize osd disk %q. %s. %v", osdInfo.BlockPath, output, err)
}
for _, device := range []string{osdInfo.BlockPath, osdInfo.MetadataPath, osdInfo.WalPath} {
if device == "" {
continue
}

logger.Infof("%s\n", output)
logger.Infof("successfully sanitized osd disk %q", osdInfo.BlockPath)
output, err := s.context.Executor.ExecuteCommandWithCombinedOutput(shredUtility, s.buildShredArgs(device)...)

logger.Infof("%s\n", output)

// If the device is encrypted let's close it after sanitizing its content
if osdInfo.Encrypted {
err := osd.CloseEncryptedDevice(s.context, osdInfo.BlockPath)
if err != nil {
logger.Errorf("failed to close encrypted osd disk %q. %v", osdInfo.BlockPath, err)
logger.Errorf("failed to sanitize osd disk %q. %s. %v", device, output, err)
} else {
logger.Infof("successfully closed encrypted osd disk %q", osdInfo.BlockPath)
logger.Infof("successfully sanitized osd disk %q", device)
}

// If the device is encrypted let's close it after sanitizing its content
if osdInfo.Encrypted {
err := osd.CloseEncryptedDevice(s.context, device)
if err != nil {
logger.Errorf("failed to close encrypted osd disk %q. %v", device, err)
} else {
logger.Infof("successfully closed encrypted osd disk %q", device)
}
}
}
}
22 changes: 15 additions & 7 deletions pkg/daemon/ceph/osd/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ var (
)

type osdInfoBlock struct {
CephFsid string `json:"ceph_fsid"`
Device string `json:"device"`
OsdID int `json:"osd_id"`
OsdUUID string `json:"osd_uuid"`
Type string `json:"type"`
CephFsid string `json:"ceph_fsid"`
Device string `json:"device"`
DeviceDb string `json:"device_db"`
DeviceWal string `json:"device_wal"`
OsdID int `json:"osd_id"`
OsdUUID string `json:"osd_uuid"`
Type string `json:"type"`
}

type osdInfo struct {
Expand Down Expand Up @@ -993,6 +995,8 @@ func GetCephVolumeRawOSDs(context *clusterd.Context, clusterInfo *client.Cluster
// blockPath represents the path of the OSD block
// it can be the one passed from the function's call or discovered by the c-v list command
var blockPath string
var blockMetadataPath string
var blockWalPath string

// If block is passed, check if it's an encrypted device, this is needed to get the correct
// device path and populate the OSDInfo for that OSD
Expand Down Expand Up @@ -1123,8 +1127,12 @@ func GetCephVolumeRawOSDs(context *clusterd.Context, clusterInfo *client.Cluster
// If no block is specified let's take the one we discovered
if setDevicePathFromList {
blockPath = osdInfo.Device
blockMetadataPath = osdInfo.DeviceDb
blockWalPath = osdInfo.DeviceWal
} else {
blockPath = block
blockMetadataPath = metadataBlock
blockWalPath = walBlock
}

osdStore := osdInfo.Type
Expand All @@ -1139,8 +1147,8 @@ func GetCephVolumeRawOSDs(context *clusterd.Context, clusterInfo *client.Cluster
// Thus in the activation sequence we might activate the wrong OSD and have OSDInfo messed up
// Hence, let's use the PVC name instead which will always remain consistent
BlockPath: blockPath,
MetadataPath: metadataBlock,
WalPath: walBlock,
MetadataPath: blockMetadataPath,
WalPath: blockWalPath,
SkipLVRelease: true,
LVBackedPV: lvBackedPV,
CVMode: cvMode,
Expand Down

0 comments on commit 04eecf7

Please sign in to comment.