Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ type Driver struct {
waitForAzCopyTimeoutMinutes int
// azcopy for provide exec mock for ut
azcopy *util.Azcopy

// if azcopy has to trust the driver's supplying endpoint
requiredAzCopyToTrust bool
}

// NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
Expand Down Expand Up @@ -326,6 +329,12 @@ func NewDriver(options *DriverOptions, kubeClient kubernetes.Interface, cloud *s
klog.Fatalf("%v", err)
}

requiredAzCopyToTrust := d.getStorageEndPointSuffix() != "" && !strings.Contains(azcopyTrustedSuffixesAAD, d.getStorageEndPointSuffix())
if requiredAzCopyToTrust {
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())
}
d.requiredAzCopyToTrust = requiredAzCopyToTrust

d.mounter = &mount.SafeFormatAndMount{
Interface: mount.New(""),
Exec: utilexec.New(),
Expand Down
8 changes: 8 additions & 0 deletions pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ const (
authorizationPermissionMismatch = "AuthorizationPermissionMismatch"

createdByMetadata = "createdBy"

// refer https://github.com/Azure/azure-storage-azcopy/wiki/azcopy
azcopyTrustedSuffixesAAD = "*.core.windows.net;*.core.chinacloudapi.cn;*.core.cloudapi.de;*.core.usgovcloudapi.net;*.storage.azure.net"
)

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

// execAzcopyCopy exec azcopy copy command
func (d *Driver) execAzcopyCopy(srcPath, dstPath string, azcopyCopyOptions, authAzcopyEnv []string) ([]byte, error) {
// Use --trusted-microsoft-suffixes option to avoid failure caused by
if d.requiredAzCopyToTrust {
azcopyCopyOptions = append(azcopyCopyOptions, fmt.Sprintf("--trusted-microsoft-suffixes=%s", d.getStorageEndPointSuffix()))
}

cmd := exec.Command("azcopy", "copy", srcPath, dstPath)
cmd.Args = append(cmd.Args, azcopyCopyOptions...)
if len(authAzcopyEnv) > 0 {
Expand Down
Loading