Skip to content

Commit

Permalink
add fileshare client interface
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinForReal committed Jan 18, 2024
1 parent 1977c40 commit b461579
Show file tree
Hide file tree
Showing 11 changed files with 881 additions and 292 deletions.
34 changes: 17 additions & 17 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ type Driver struct {
appendNoResvPortOption bool
appendActimeoOption bool
printVolumeStatsCallLogs bool
fileClient *azureFileClient
mounter *mount.SafeFormatAndMount
server *grpc.Server
// lock per volume attach (only for vhd disk feature)
Expand Down Expand Up @@ -364,9 +363,6 @@ func (d *Driver) Run(ctx context.Context) error {
}
klog.V(2).Infof("cloud: %s, location: %s, rg: %s, VnetName: %s, VnetResourceGroup: %s, SubnetName: %s", d.cloud.Cloud, d.cloud.Location, d.cloud.ResourceGroup, d.cloud.VnetName, d.cloud.VnetResourceGroup, d.cloud.SubnetName)

// todo: set backoff from cloud provider config
d.fileClient = newAzureFileClient(&d.cloud.Environment, &retry.Backoff{Steps: 1})

d.mounter, err = mounter.NewSafeMounter(d.enableWindowsHostProcess)
if err != nil {
klog.Fatalf("Failed to get safe mounter. Error: %v", err)
Expand Down Expand Up @@ -435,19 +431,11 @@ func (d *Driver) getFileShareQuota(ctx context.Context, subsID, resourceGroupNam
if err != nil {
return -1, err
}
fileClient, err := d.fileClient.getFileSvcClient(accountName, accountKey)
if err != nil {
return -1, err
}
share := fileClient.GetShareReference(fileShareName)
exists, err := share.Exists()
fileClient, err := newAzureFileClient(&d.cloud.Environment, &retry.Backoff{Steps: 1}, accountName, accountKey)
if err != nil {
return -1, err
}
if !exists {
return -1, nil
}
return share.Properties.Quota, nil
return fileClient.GetFileShareQuota(ctx, fileShareName)
}

fileShare, err := d.cloud.GetFileShare(ctx, subsID, resourceGroupName, accountName, fileShareName)
Expand Down Expand Up @@ -913,7 +901,11 @@ func (d *Driver) CreateFileShare(ctx context.Context, accountOptions *azure.Acco
if rerr != nil {
return true, rerr
}
err = d.fileClient.CreateFileShare(accountName, accountKey, shareOptions)
fileClient, err := newAzureFileClient(&d.cloud.Environment, &retry.Backoff{Steps: 1}, accountName, accountKey)
if err != nil {
return true, err
}
err = fileClient.CreateFileShare(ctx, shareOptions)

Check failure on line 908 in pkg/azurefile/azurefile.go

View workflow job for this annotation

GitHub Actions / Go Lint

ineffectual assignment to err (ineffassign)
} else {
_, err = d.cloud.FileClient.WithSubscriptionID(accountOptions.SubscriptionID).CreateFileShare(ctx, accountOptions.ResourceGroup, accountOptions.Name, shareOptions, "")
}
Expand All @@ -935,7 +927,11 @@ func (d *Driver) DeleteFileShare(ctx context.Context, subsID, resourceGroup, acc
if rerr != nil {
return true, rerr
}
err = d.fileClient.deleteFileShare(accountName, accountKey, shareName)
fileClient, err := newAzureFileClient(&d.cloud.Environment, &retry.Backoff{Steps: 1}, accountName, accountKey)
if err != nil {
return true, err
}
err = fileClient.DeleteFileShare(ctx, shareName)

Check failure on line 934 in pkg/azurefile/azurefile.go

View workflow job for this annotation

GitHub Actions / Go Lint

ineffectual assignment to err (ineffassign)
} else {
err = d.cloud.DeleteFileShare(ctx, subsID, resourceGroup, accountName, shareName)
}
Expand Down Expand Up @@ -972,7 +968,11 @@ func (d *Driver) ResizeFileShare(ctx context.Context, subsID, resourceGroup, acc
if rerr != nil {
return true, rerr
}
err = d.fileClient.resizeFileShare(accountName, accountKey, shareName, sizeGiB)
fileClient, err := newAzureFileClient(&d.cloud.Environment, &retry.Backoff{Steps: 1}, accountName, accountKey)
if err != nil {
return true, err
}
err = fileClient.ResizeFileShare(ctx, shareName, sizeGiB)

Check failure on line 975 in pkg/azurefile/azurefile.go

View workflow job for this annotation

GitHub Actions / Go Lint

ineffectual assignment to err (ineffassign)
} else {
err = d.cloud.ResizeFileShare(ctx, subsID, resourceGroup, accountName, shareName, sizeGiB)
}
Expand Down
213 changes: 0 additions & 213 deletions pkg/azurefile/azurefile_client_test.go

This file was deleted.

Loading

0 comments on commit b461579

Please sign in to comment.