Skip to content

Commit

Permalink
modify comment
Browse files Browse the repository at this point in the history
  • Loading branch information
zhucan authored and zhuc committed Sep 10, 2019
1 parent e461816 commit f09c359
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,7 @@ func (p *csiProvisioner) ProvisionExt(options controller.ProvisionOptions) (*v1.
delReq := &csi.DeleteVolumeRequest{
VolumeId: rep.GetVolume().GetVolumeId(),
}
delReq.Secrets = provisionerCredentials
ctx, cancel := context.WithTimeout(context.Background(), p.timeout)
defer cancel()
_, err := p.csiClient.DeleteVolume(ctx, delReq)
err = cleanupVolume(p, delReq, provisionerCredentials)
if err != nil {
capErr = fmt.Errorf("%v. Cleanup of volume %s failed, volume is orphaned: %v", capErr, pvName, err)
}
Expand All @@ -570,16 +567,7 @@ func (p *csiProvisioner) ProvisionExt(options controller.ProvisionOptions) (*v1.
delReq := &csi.DeleteVolumeRequest{
VolumeId: rep.GetVolume().GetVolumeId(),
}
delReq.Secrets = provisionerCredentials
ctx, cancel := context.WithTimeout(context.Background(), p.timeout)
defer cancel()
for i := 0; i < deleteVolumeRetryCount; i++ {
_, err = p.csiClient.DeleteVolume(ctx, delReq)
if err == nil {
break
}
klog.Errorf("%v. cleanup of volume %s failed", sourceErr, pvName)
}
err = cleanupVolume(p, delReq, provisionerCredentials)
if err != nil {
sourceErr = fmt.Errorf("%v. cleanup of volume %s failed, volume is orphaned: %v", sourceErr, pvName, err)
}
Expand Down Expand Up @@ -1091,3 +1079,17 @@ func isFinalError(err error) bool {
// even start or failed. It is for sure not in progress.
return true
}

func cleanupVolume(p *csiProvisioner, delReq *csi.DeleteVolumeRequest, provisionerCredentials map[string]string) error {
var err error = nil
delReq.Secrets = provisionerCredentials
ctx, cancel := context.WithTimeout(context.Background(), p.timeout)
defer cancel()
for i := 0; i < deleteVolumeRetryCount; i++ {
_, err = p.csiClient.DeleteVolume(ctx, delReq)
if err == nil {
break
}
}
return err
}

0 comments on commit f09c359

Please sign in to comment.