Skip to content

Commit 2de487c

Browse files
authored
Merge pull request kubernetes#74182 from andyzhangx/azuredisk-snapshot-client
add azure disk snapshot client in azure cloud provider
2 parents 07a5488 + 3b37dc5 commit 2de487c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pkg/cloudprovider/providers/azure/azure.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
cloudprovider "k8s.io/cloud-provider"
3939
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure/auth"
4040

41+
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
4142
"github.com/Azure/go-autorest/autorest"
4243
"github.com/Azure/go-autorest/autorest/azure"
4344
"k8s.io/klog"
@@ -170,6 +171,7 @@ type Cloud struct {
170171
VirtualMachinesClient VirtualMachinesClient
171172
StorageAccountClient StorageAccountClient
172173
DisksClient DisksClient
174+
SnapshotsClient *compute.SnapshotsClient
173175
FileClient FileClient
174176
resourceRequestBackoff wait.Backoff
175177
metadata *InstanceMetadataService
@@ -344,6 +346,7 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {
344346
resourceRequestBackoff: resourceRequestBackoff,
345347

346348
DisksClient: newAzDisksClient(azClientConfig),
349+
SnapshotsClient: newSnapshotsClient(azClientConfig),
347350
RoutesClient: newAzRoutesClient(azClientConfig),
348351
SubnetsClient: newAzSubnetsClient(azClientConfig),
349352
InterfacesClient: newAzInterfacesClient(azClientConfig),

pkg/cloudprovider/providers/azure/azure_client.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,18 @@ func (az *azDisksClient) Get(ctx context.Context, resourceGroupName string, disk
13851385
return
13861386
}
13871387

1388+
func newSnapshotsClient(config *azClientConfig) *compute.SnapshotsClient {
1389+
snapshotsClient := compute.NewSnapshotsClientWithBaseURI(config.resourceManagerEndpoint, config.subscriptionID)
1390+
snapshotsClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
1391+
snapshotsClient.PollingDelay = 5 * time.Second
1392+
if config.ShouldOmitCloudProviderBackoff {
1393+
snapshotsClient.RetryAttempts = config.CloudProviderBackoffRetries
1394+
snapshotsClient.RetryDuration = time.Duration(config.CloudProviderBackoffDuration) * time.Second
1395+
}
1396+
configureUserAgent(&snapshotsClient.Client)
1397+
return &snapshotsClient
1398+
}
1399+
13881400
// azVirtualMachineSizesClient implements VirtualMachineSizesClient.
13891401
type azVirtualMachineSizesClient struct {
13901402
client compute.VirtualMachineSizesClient

0 commit comments

Comments
 (0)