mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #74182 from andyzhangx/azuredisk-snapshot-client
add azure disk snapshot client in azure cloud provider
This commit is contained in:
		@@ -38,6 +38,7 @@ import (
 | 
				
			|||||||
	cloudprovider "k8s.io/cloud-provider"
 | 
						cloudprovider "k8s.io/cloud-provider"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/cloudprovider/providers/azure/auth"
 | 
						"k8s.io/kubernetes/pkg/cloudprovider/providers/azure/auth"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
 | 
				
			||||||
	"github.com/Azure/go-autorest/autorest"
 | 
						"github.com/Azure/go-autorest/autorest"
 | 
				
			||||||
	"github.com/Azure/go-autorest/autorest/azure"
 | 
						"github.com/Azure/go-autorest/autorest/azure"
 | 
				
			||||||
	"k8s.io/klog"
 | 
						"k8s.io/klog"
 | 
				
			||||||
@@ -170,6 +171,7 @@ type Cloud struct {
 | 
				
			|||||||
	VirtualMachinesClient   VirtualMachinesClient
 | 
						VirtualMachinesClient   VirtualMachinesClient
 | 
				
			||||||
	StorageAccountClient    StorageAccountClient
 | 
						StorageAccountClient    StorageAccountClient
 | 
				
			||||||
	DisksClient             DisksClient
 | 
						DisksClient             DisksClient
 | 
				
			||||||
 | 
						SnapshotsClient         *compute.SnapshotsClient
 | 
				
			||||||
	FileClient              FileClient
 | 
						FileClient              FileClient
 | 
				
			||||||
	resourceRequestBackoff  wait.Backoff
 | 
						resourceRequestBackoff  wait.Backoff
 | 
				
			||||||
	metadata                *InstanceMetadataService
 | 
						metadata                *InstanceMetadataService
 | 
				
			||||||
@@ -344,6 +346,7 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {
 | 
				
			|||||||
		resourceRequestBackoff: resourceRequestBackoff,
 | 
							resourceRequestBackoff: resourceRequestBackoff,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		DisksClient:                     newAzDisksClient(azClientConfig),
 | 
							DisksClient:                     newAzDisksClient(azClientConfig),
 | 
				
			||||||
 | 
							SnapshotsClient:                 newSnapshotsClient(azClientConfig),
 | 
				
			||||||
		RoutesClient:                    newAzRoutesClient(azClientConfig),
 | 
							RoutesClient:                    newAzRoutesClient(azClientConfig),
 | 
				
			||||||
		SubnetsClient:                   newAzSubnetsClient(azClientConfig),
 | 
							SubnetsClient:                   newAzSubnetsClient(azClientConfig),
 | 
				
			||||||
		InterfacesClient:                newAzInterfacesClient(azClientConfig),
 | 
							InterfacesClient:                newAzInterfacesClient(azClientConfig),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1385,6 +1385,18 @@ func (az *azDisksClient) Get(ctx context.Context, resourceGroupName string, disk
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func newSnapshotsClient(config *azClientConfig) *compute.SnapshotsClient {
 | 
				
			||||||
 | 
						snapshotsClient := compute.NewSnapshotsClientWithBaseURI(config.resourceManagerEndpoint, config.subscriptionID)
 | 
				
			||||||
 | 
						snapshotsClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
 | 
				
			||||||
 | 
						snapshotsClient.PollingDelay = 5 * time.Second
 | 
				
			||||||
 | 
						if config.ShouldOmitCloudProviderBackoff {
 | 
				
			||||||
 | 
							snapshotsClient.RetryAttempts = config.CloudProviderBackoffRetries
 | 
				
			||||||
 | 
							snapshotsClient.RetryDuration = time.Duration(config.CloudProviderBackoffDuration) * time.Second
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						configureUserAgent(&snapshotsClient.Client)
 | 
				
			||||||
 | 
						return &snapshotsClient
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// azVirtualMachineSizesClient implements VirtualMachineSizesClient.
 | 
					// azVirtualMachineSizesClient implements VirtualMachineSizesClient.
 | 
				
			||||||
type azVirtualMachineSizesClient struct {
 | 
					type azVirtualMachineSizesClient struct {
 | 
				
			||||||
	client            compute.VirtualMachineSizesClient
 | 
						client            compute.VirtualMachineSizesClient
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user