Skip to content

Commit

Permalink
Merge pull request #1675 from umagnus/add_azcopy_sas_flag
Browse files Browse the repository at this point in the history
chore: add flag for azcopy use sas token by default
  • Loading branch information
k8s-ci-robot committed Jan 19, 2024
2 parents ee91b6f + 3307293 commit c252e78
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ type Driver struct {

kubeconfig string
endpoint string

// azcopy use sas token by default
azcopyUseSasToken bool
}

// NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
Expand Down Expand Up @@ -297,6 +300,7 @@ func NewDriver(options *DriverOptions) *Driver {
driver.azcopy = &fileutil.Azcopy{}
driver.kubeconfig = options.KubeConfig
driver.endpoint = options.Endpoint
driver.azcopyUseSasToken = options.AzcopyUseSasToken

var err error
getter := func(key string) (interface{}, error) { return nil, nil }
Expand Down
2 changes: 2 additions & 0 deletions pkg/azurefile/azurefile_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type DriverOptions struct {
SasTokenExpirationMinutes int
KubeConfig string
Endpoint string
AzcopyUseSasToken bool
}

func (o *DriverOptions) AddFlags() *flag.FlagSet {
Expand Down Expand Up @@ -81,6 +82,7 @@ func (o *DriverOptions) AddFlags() *flag.FlagSet {
fs.IntVar(&o.SasTokenExpirationMinutes, "sas-token-expiration-minutes", 1440, "sas token expiration minutes during volume cloning")
fs.StringVar(&o.KubeConfig, "kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
fs.StringVar(&o.Endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")
fs.BoolVar(&o.AzcopyUseSasToken, "azcopy-use-sas-token", true, "Whether SAS token should be used in azcopy based on volume clone and snapshot restore")

return fs
}
2 changes: 1 addition & 1 deletion pkg/azurefile/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
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)
}
if req.GetVolumeContentSource() != nil {
accountSASToken, authAzcopyEnv, err := d.getAzcopyAuth(ctx, accountName, accountKey, storageEndpointSuffix, accountOptions, secret, secretName, secretNamespace, false)
accountSASToken, authAzcopyEnv, err := d.getAzcopyAuth(ctx, accountName, accountKey, storageEndpointSuffix, accountOptions, secret, secretName, secretNamespace, d.azcopyUseSasToken)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to getAzcopyAuth on account(%s) rg(%s), error: %v", accountOptions.Name, accountOptions.ResourceGroup, err)
}
Expand Down

0 comments on commit c252e78

Please sign in to comment.