Skip to content

Commit 672decc

Browse files
committed
Moving VG creation to Node Stage Volume to fix duplicate bugs during node reboot.
1 parent 0be5a10 commit 672decc

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

Diff for: cmd/gce-pd-csi-driver/main.go

-5
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,6 @@ func setupDataCache(ctx context.Context, nodeName string, nodeId string) error {
424424
return fmt.Errorf("Failed to Raid local SSDs, unable to setup Data Cache, got error %v", err)
425425
}
426426

427-
// Initializing data cache node (VG checks w/ raided lssd)
428-
if err := driver.InitializeDataCacheNode(nodeId); err != nil {
429-
return err
430-
}
431-
432427
klog.V(4).Infof("LSSD caching is setup for the Data Cache enabled node %s", nodeName)
433428
return nil
434429
}

Diff for: pkg/gce-pd-csi-driver/cache.go

+4-27
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ func setupCaching(devicePath string, req *csi.NodeStageVolumeRequest, nodeId str
7171
if vgExists {
7272
// Clean up Volume Group before adding the PD
7373
reduceVolumeGroup(volumeGroupName, true)
74+
info, err := common.RunCommand("" /* pipedCmd */, nil /* pipedCmdArg */, "vgextend", []string{volumeGroupName, raidedLocalSsdPath}...)
75+
if err != nil {
76+
return "", fmt.Errorf("errored while extending volume group to add localssd %v, error: %v: %s", raidedLocalSsdPath, err, info)
77+
}
7478
} else {
7579
err := createVg(volumeGroupName, raidedLocalSsdPath)
7680
if err != nil {
@@ -581,33 +585,6 @@ func fetchChunkSizeKiB(cacheSize string) (string, error) {
581585
return strconv.FormatInt(int64(chunkSize), 10) + "KiB", nil
582586
}
583587

584-
func InitializeDataCacheNode(nodeId string) error {
585-
raidedLocalSsdPath, err := fetchRAIDedLocalSsdPath()
586-
if err != nil {
587-
return err
588-
}
589-
volumeGroupName := getVolumeGroupName(nodeId)
590-
591-
vgExists := checkVgExists(volumeGroupName)
592-
// Check if the required volume group already exists
593-
if vgExists {
594-
// Clean up Volume Group before adding the PD
595-
reduceVolumeGroup(volumeGroupName, true)
596-
597-
// validate that raidedLSSD is part of VG
598-
err = validateRaidedLSSDinVG(volumeGroupName, raidedLocalSsdPath)
599-
if err != nil {
600-
return fmt.Errorf("failed validate local ssd in vg %v: %v", volumeGroupName, err)
601-
}
602-
} else {
603-
err := createVg(volumeGroupName, raidedLocalSsdPath)
604-
if err != nil {
605-
return err
606-
}
607-
}
608-
return nil
609-
}
610-
611588
func StartWatcher(nodeName string) {
612589
dirToWatch := "/dev/"
613590
watcher, err := fsnotify.NewWatcher()

0 commit comments

Comments
 (0)