Skip to content

Commit a5a3d2e

Browse files
Clean up GCNV SAN driver to align with NAS (gcp_gcnv.go)
1 parent 30700d5 commit a5a3d2e

File tree

4 files changed

+1375
-1279
lines changed

4 files changed

+1375
-1279
lines changed

storage_drivers/gcp/api/gcnv.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -972,13 +972,14 @@ func (c Client) CreateVolume(ctx context.Context, request *VolumeCreateRequest)
972972

973973
Logc(ctx).WithFields(logFields).Info("Volume create request issued.")
974974

975-
if _, pollErr := poller.Poll(sdkCtx); pollErr != nil {
975+
waitCtx, waitCancel := context.WithTimeout(ctx, DefaultTimeout)
976+
defer waitCancel()
977+
gcnvVol, pollErr := poller.Wait(waitCtx)
978+
if pollErr != nil {
979+
Logc(ctx).WithFields(logFields).WithError(pollErr).Error("Error waiting for volume create operation to complete.")
976980
return nil, pollErr
977981
}
978-
// The volume doesn't exist yet, so forge the name & network IDs to enable conversion to a Volume struct
979-
newVol.Name = c.createVolumeID(cPool.Location, request.Name)
980-
newVol.Network = cPool.NetworkFullName
981-
return c.newVolumeFromGCNVVolume(ctx, newVol)
982+
return c.newVolumeFromGCNVVolume(ctx, gcnvVol)
982983
}
983984

984985
// UpdateNASVolume updates NAS-specific attributes of a volume: labels, unix permissions, and snapshot directory access.
@@ -1107,7 +1108,10 @@ func (c Client) DeleteVolume(ctx context.Context, volume *Volume) error {
11071108

11081109
Logc(ctx).WithFields(logFields).Debug("Volume delete request issued.")
11091110

1110-
if pollErr := poller.Poll(sdkCtx); pollErr != nil {
1111+
waitCtx, waitCancel := context.WithTimeout(ctx, DefaultTimeout)
1112+
defer waitCancel()
1113+
if pollErr := poller.Wait(waitCtx); pollErr != nil {
1114+
Logc(ctx).WithFields(logFields).WithError(pollErr).Error("Error waiting for volume delete operation to complete.")
11111115
return pollErr
11121116
}
11131117

storage_drivers/gcp/gcp_gcnv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ func (d *NASStorageDriver) Create(
676676
Logd(ctx, d.Name(), d.Config.DebugTraceFlags["method"]).WithFields(fields).Trace(">>>> Create")
677677
defer Logd(ctx, d.Name(), d.Config.DebugTraceFlags["method"]).WithFields(fields).Trace("<<<< Create")
678678

679-
// Update resource cache as needed
679+
// Update the resource cache as needed
680680
if err := d.API.RefreshGCNVResources(ctx); err != nil {
681681
return fmt.Errorf("could not update GCNV resource cache; %v", err)
682682
}

0 commit comments

Comments
 (0)