Skip to content

Commit

Permalink
disk/CreateVolume: remove protection against repeated create
Browse files Browse the repository at this point in the history
This protection is fragile, it cannot suvive CSI restart, and breaks the
detection of inconsistent create parameters between two requests with the same
name.
  • Loading branch information
huww98 committed Oct 1, 2023
1 parent 7f7d964 commit f0b4f3c
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions pkg/disk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,9 @@ func NewControllerServer(d *csicommon.CSIDriver, client *crd.Clientset) csi.Cont
// the map of req.Name and csi.Snapshot
var createdSnapshotMap = map[string]*csi.Snapshot{}

// the map of req.Name and csi.Volume
var createdVolumeMap = map[string]*csi.Volume{}

// the map of multizone and index
var storageClassZonePos = map[string]int{}

// the map of diskId and pvName
// diskId and pvName is not same under csi plugin
var diskIDPVMap = map[string]string{}

// SnapshotRequestMap snapshot request limit
var SnapshotRequestMap = map[string]int64{}

Expand All @@ -148,10 +141,6 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
log.Log.Errorf("CreateVolume: driver not support Create volume: %v", err)
return nil, err
}
if value, ok := createdVolumeMap[req.Name]; ok {
log.Log.Infof("CreateVolume: volume already be created pvName: %s, VolumeId: %s, volumeContext: %v", req.Name, value.VolumeId, value.VolumeContext)
return &csi.CreateVolumeResponse{Volume: value}, nil
}

snapshotID := ""
volumeSource := req.GetVolumeContentSource()
Expand Down Expand Up @@ -252,8 +241,6 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol

tmpVol := volumeCreate(diskType, diskID, volSizeBytes, volumeContext, diskVol.ZoneID, src)

diskIDPVMap[diskID] = req.Name
createdVolumeMap[req.Name] = tmpVol
return &csi.CreateVolumeResponse{Volume: tmpVol}, nil
}

Expand All @@ -278,11 +265,6 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
log.Log.Error(errMsg)
return nil, status.Error(codes.Internal, errMsg)
} else if disk == nil {
// TODO Optimize concurrent access problems
if value, ok := diskIDPVMap[req.VolumeId]; ok {
delete(createdVolumeMap, value)
delete(diskIDPVMap, req.VolumeId)
}
log.Log.Infof("DeleteVolume: disk(%s) already deleted", req.VolumeId)
return &csi.DeleteVolumeResponse{}, nil
}
Expand Down Expand Up @@ -328,10 +310,6 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
return nil, status.Errorf(codes.Internal, errMsg)
}

if value, ok := diskIDPVMap[req.VolumeId]; ok {
delete(createdVolumeMap, value)
delete(diskIDPVMap, req.VolumeId)
}
delVolumeSnap.Delete(req.GetVolumeId())
return &csi.DeleteVolumeResponse{}, nil
}
Expand Down

0 comments on commit f0b4f3c

Please sign in to comment.