Merge pull request #14645 from Papawy/cleanup-metadata-wal

osd: discover metadata and wal devices for raw device cleanup
This commit is contained in:
Travis Nielsen
2024-09-03 13:50:17 -06:00
committed by GitHub
2 changed files with 34 additions and 18 deletions
+19 -11
View File
@@ -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)
}
}
}
}
+15 -7
View File
@@ -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 {
@@ -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
@@ -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
@@ -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,