Skip to content

Commit a409eae

Browse files
committed
Revert "fix: only copy volume to different account if storageAccount is specified"
This reverts commit a8ab407.
1 parent a8ab407 commit a409eae

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

pkg/blob/controllerserver.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
440440
if err != nil {
441441
return nil, status.Errorf(codes.Internal, "failed to getAzcopyAuth on account(%s) rg(%s), error: %v", accountOptions.Name, accountOptions.ResourceGroup, err)
442442
}
443-
if err := d.copyVolume(req, accountSASToken, authAzcopyEnv, account, validContainerName, storageEndpointSuffix); err != nil {
443+
if err := d.copyVolume(req, accountSASToken, authAzcopyEnv, accountName, validContainerName, storageEndpointSuffix); err != nil {
444444
return nil, err
445445
}
446446
} else {
@@ -755,7 +755,7 @@ func (d *Driver) DeleteBlobContainer(ctx context.Context, subsID, resourceGroupN
755755
})
756756
}
757757

758-
// CopyBlobContainer copies a blob container, if dstAccountName is empty, then copy in the same account
758+
// CopyBlobContainer copies a blob container
759759
func (d *Driver) copyBlobContainer(req *csi.CreateVolumeRequest, accountSasToken string, authAzcopyEnv []string, dstAccountName, dstContainerName, storageEndpointSuffix string) error {
760760
var sourceVolumeID string
761761
if req.GetVolumeContentSource() != nil && req.GetVolumeContentSource().GetVolume() != nil {
@@ -766,11 +766,8 @@ func (d *Driver) copyBlobContainer(req *csi.CreateVolumeRequest, accountSasToken
766766
if err != nil {
767767
return status.Error(codes.NotFound, err.Error())
768768
}
769-
if dstAccountName == "" {
770-
dstAccountName = srcAccountName
771-
}
772-
if srcAccountName == "" || srcContainerName == "" || dstContainerName == "" {
773-
return fmt.Errorf("One or more of srcAccountName(%s), srcContainerName(%s), dstContainerName(%s) are empty", srcAccountName, srcContainerName, dstContainerName)
769+
if srcAccountName == "" || srcContainerName == "" || dstAccountName == "" || dstContainerName == "" {
770+
return fmt.Errorf("One or more of srcAccountName(%s), srcContainerName(%s), dstAccountName(%s), dstContainerName(%s) are empty", srcAccountName, srcContainerName, dstAccountName, dstContainerName)
774771
}
775772

776773
srcPath := fmt.Sprintf("https://%s.blob.%s/%s", srcAccountName, storageEndpointSuffix, srcContainerName)

pkg/blob/controllerserver_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ func TestCopyVolume(t *testing.T) {
16251625
VolumeContentSource: &volumecontensource,
16261626
}
16271627

1628-
expectedErr := fmt.Errorf("One or more of srcAccountName(srcAccount), srcContainerName(), dstContainerName(dstContainer) are empty")
1628+
expectedErr := fmt.Errorf("One or more of srcAccountName(srcAccount), srcContainerName(), dstAccountName(dstAccount), dstContainerName(dstContainer) are empty")
16291629
err := d.copyVolume(req, "", nil, "dstAccount", "dstContainer", "core.windows.net")
16301630
if !reflect.DeepEqual(err, expectedErr) {
16311631
t.Errorf("Unexpected error: %v", err)
@@ -1655,7 +1655,7 @@ func TestCopyVolume(t *testing.T) {
16551655
VolumeContentSource: &volumecontensource,
16561656
}
16571657

1658-
expectedErr := fmt.Errorf("One or more of srcAccountName(unit-test), srcContainerName(), dstContainerName(dstContainer) are empty")
1658+
expectedErr := fmt.Errorf("One or more of srcAccountName(unit-test), srcContainerName(), dstAccountName(dstAccount), dstContainerName(dstContainer) are empty")
16591659
err := d.copyVolume(req, "", nil, "dstAccount", "dstContainer", "core.windows.net")
16601660
if !reflect.DeepEqual(err, expectedErr) {
16611661
t.Errorf("Unexpected error: %v", err)
@@ -1685,7 +1685,7 @@ func TestCopyVolume(t *testing.T) {
16851685
VolumeContentSource: &volumecontensource,
16861686
}
16871687

1688-
expectedErr := fmt.Errorf("One or more of srcAccountName(f5713de20cde511e8ba4900), srcContainerName(fileshare), dstContainerName() are empty")
1688+
expectedErr := fmt.Errorf("One or more of srcAccountName(f5713de20cde511e8ba4900), srcContainerName(fileshare), dstAccountName(), dstContainerName() are empty")
16891689
err := d.copyVolume(req, "", nil, "", "", "core.windows.net")
16901690
if !reflect.DeepEqual(err, expectedErr) {
16911691
t.Errorf("Unexpected error: %v", err)

0 commit comments

Comments
 (0)