Skip to content

Commit 597833b

Browse files
authored
Merge pull request #2249 from hasethuraman/hari/set-trusted-ep-if-notinazcopy
fix: snapshot restore and volume clone failure in some new sovereign …
2 parents 7b8858c + 5b15d10 commit 597833b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pkg/blob/blob.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ type Driver struct {
268268
waitForAzCopyTimeoutMinutes int
269269
// azcopy for provide exec mock for ut
270270
azcopy *util.Azcopy
271+
272+
// if azcopy has to trust the driver's supplying endpoint
273+
requiredAzCopyToTrust bool
271274
}
272275

273276
// NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
@@ -327,6 +330,12 @@ func NewDriver(options *DriverOptions, kubeClient kubernetes.Interface, cloud *s
327330
klog.Fatalf("%v", err)
328331
}
329332

333+
requiredAzCopyToTrust := d.getStorageEndPointSuffix() != "" && !strings.Contains(azcopyTrustedSuffixesAAD, d.getStorageEndPointSuffix())
334+
if requiredAzCopyToTrust {
335+
klog.V(2).Infof("storage endpoint suffix %s is not in azcopy trusted suffixes, azcopy will trust it temporarily during volume clone and snapshot restore", d.getStorageEndPointSuffix())
336+
}
337+
d.requiredAzCopyToTrust = requiredAzCopyToTrust
338+
330339
d.mounter = &mount.SafeFormatAndMount{
331340
Interface: mount.New(""),
332341
Exec: utilexec.New(),

pkg/blob/controllerserver.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ const (
6161
authorizationPermissionMismatch = "AuthorizationPermissionMismatch"
6262

6363
createdByMetadata = "createdBy"
64+
65+
// refer https://github.com/Azure/azure-storage-azcopy/wiki/azcopy
66+
azcopyTrustedSuffixesAAD = "*.core.windows.net;*.core.chinacloudapi.cn;*.core.cloudapi.de;*.core.usgovcloudapi.net;*.storage.azure.net"
6467
)
6568

6669
// CreateVolume provisions a volume
@@ -869,6 +872,11 @@ func (d *Driver) copyVolume(ctx context.Context, req *csi.CreateVolumeRequest, a
869872

870873
// execAzcopyCopy exec azcopy copy command
871874
func (d *Driver) execAzcopyCopy(srcPath, dstPath string, azcopyCopyOptions, authAzcopyEnv []string) ([]byte, error) {
875+
// Use --trusted-microsoft-suffixes option to avoid failure caused by
876+
if d.requiredAzCopyToTrust {
877+
azcopyCopyOptions = append(azcopyCopyOptions, fmt.Sprintf("--trusted-microsoft-suffixes=%s", d.getStorageEndPointSuffix()))
878+
}
879+
872880
cmd := exec.Command("azcopy", "copy", srcPath, dstPath)
873881
cmd.Args = append(cmd.Args, azcopyCopyOptions...)
874882
if len(authAzcopyEnv) > 0 {

0 commit comments

Comments
 (0)