Skip to content

Commit d8ce826

Browse files
authored
Merge pull request #2229 from k8s-infra-cherrypick-robot/cherry-pick-2226-to-release-1.29
[release-1.29] fix: ignore ShareAlreadyExists error in snapshot restore and clone
2 parents 9bd2a0a + da1a71c commit d8ce826

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/azurefile/controllerserver.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,12 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
583583
d.volMap.Delete(volName)
584584
return d.CreateVolume(ctx, req)
585585
}
586-
return nil, status.Errorf(codes.Internal, "failed to create file share(%s) on account(%s) type(%s) subsID(%s) rg(%s) location(%s) size(%d), error: %v", validFileShareName, account, sku, subsID, resourceGroup, location, fileShareSize, err)
586+
if req.GetVolumeContentSource() != nil && strings.Contains(err.Error(), "ShareAlreadyExists") {
587+
// for snapshot restore and volume cloning, ignore ShareAlreadyExists error since the file share should be created first
588+
klog.Warningf("create file share(%s) on account(%s) type(%s) subID(%s) rg(%s) location(%s) size(%d), ignore ShareAlreadyExists error for snapshot restore and volume cloning, error: %v", validFileShareName, accountName, sku, subsID, resourceGroup, location, fileShareSize, err)
589+
} else {
590+
return nil, status.Errorf(codes.Internal, "failed to create file share(%s) on account(%s) type(%s) subsID(%s) rg(%s) location(%s) size(%d), error: %v", validFileShareName, account, sku, subsID, resourceGroup, location, fileShareSize, err)
591+
}
587592
}
588593
if req.GetVolumeContentSource() != nil {
589594
accountSASToken, authAzcopyEnv, err := d.getAzcopyAuth(ctx, accountName, accountKey, storageEndpointSuffix, accountOptions, secret, secretName, secretNamespace, false)

0 commit comments

Comments
 (0)