Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure: Migrate to the new SDK version #16286

Merged
merged 8 commits into from
Feb 9, 2024

Conversation

hakman
Copy link
Member

@hakman hakman commented Jan 28, 2024

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. area/provider/azure Issues or PRs related to azure provider labels Jan 28, 2024
@hakman hakman force-pushed the azure-sdk-go-new-version branch from e28d696 to f656060 Compare January 28, 2024 12:18
@@ -207,7 +207,7 @@ func getStorageProfile(spec *kops.InstanceGroupSpec) (*compute.VirtualMachineSca
if spec.RootVolume != nil && spec.RootVolume.Type != nil {
storageAccountType = compute.StorageAccountTypes(*spec.RootVolume.Type)
} else {
storageAccountType = compute.StorageAccountTypesPremiumLRS
storageAccountType = compute.StorageAccountTypesStandardSSDLRS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this change is intentional then it may be worthy of a release note

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure is still Alpha, so not sure it's worth the effort.

return nil, fmt.Errorf("parsing public IP address ID: %s", err)
}
pips.Insert(pipID.PublicIPAddressName)
if loadBalancer.Properties != nil && loadBalancer.Properties.FrontendIPConfigurations != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the second != nil check here is redundant with the following range loop

func newNatGatewaysClientImpl(subscriptionID string, cred *azidentity.DefaultAzureCredential) (*NatGatewaysClientImpl, error) {
c, err := network.NewNatGatewaysClient(subscriptionID, cred, nil)
if err != nil {
return nil, fmt.Errorf("creating subnets client: %w", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, fmt.Errorf("creating subnets client: %w", err)
return nil, fmt.Errorf("creating nat gateways client: %w", err)

},
DiskSizeGB: e.SizeGB,
},
SKU: &compute.DiskSKU{
Name: to.Ptr(compute.DiskStorageAccountTypesStandardSSDLRS),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not configurable? It feels like it should be

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add the option in a future PR.

Comment on lines 116 to 119
var azErr *azcore.ResponseError
if errors.As(err, &azErr) {
if azErr.ErrorCode == "ContainerNotFound" || azErr.ErrorCode == "BlobNotFound" {
return nil, os.ErrNotExist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the bloberror package's HasCode function and these error code constants? Same with the other error checking in this file

https://github.com/Azure/azure-sdk-for-go/blob/ab4bfbc61843da34541746e017ab7aa2141d6461/sdk/storage/azblob/bloberror/error_codes.go#L66

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiice! 😄

// WriteTo writes the content of the blob to the writer.
func (p *AzureBlobPath) WriteTo(w io.Writer) (n int64, err error) {
ctx := context.TODO()
klog.Infof("Reading: %s - %s", p.container, p.key)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps drop all these klog statements to Debug


func newAzureClient(ctx context.Context) (*azureClient, error) {
func newAzureClient(ctx context.Context) (*azblob.Client, error) {
klog.Infof("New Azure Blob client")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, consider dropping to debug

// Please note that Instance Metadata Service is available only within a VM
// running in Azure (and when necessary role is attached to the VM).
func newAzureCredential(ctx context.Context, accountName string) (azblob.Credential, error) {
accountKey := os.Getenv("AZURE_STORAGE_KEY")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing this env var mentioned in the azure SDK at all, maybe we should still recognize it here?

https://github.com/search?q=repo%3AAzure%2Fazure-sdk-for-go+AZURE_STORAGE_KEY+&type=code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, not needed anymore.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 5, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hakman hakman force-pushed the azure-sdk-go-new-version branch from f656060 to cf9bd3d Compare February 9, 2024 03:14
@hakman hakman changed the title WIP azure: Migrate to the new SDK version azure: Migrate to the new SDK version Feb 9, 2024
@k8s-ci-robot k8s-ci-robot added area/documentation and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 9, 2024
@hakman
Copy link
Member Author

hakman commented Feb 9, 2024

@rifelpet Could you take one more look, please?

@hakman hakman requested a review from rifelpet February 9, 2024 03:20

// WriteTo writes the content of the blob to the writer.
func (p *AzureBlobPath) WriteTo(w io.Writer) (n int64, err error) {
return 0, fmt.Errorf("not implemented")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason not to implement this? it was implemented before

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used only in etcd-manager, not sure why.
I added it back for now. Thanks for the reminder.

@hakman hakman force-pushed the azure-sdk-go-new-version branch from cf9bd3d to f8ebec5 Compare February 9, 2024 03:58
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 9, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rifelpet

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 9, 2024
@hakman
Copy link
Member Author

hakman commented Feb 9, 2024

/test pull-kops-e2e-k8s-aws-calico

@kubernetes kubernetes deleted a comment from k8s-ci-robot Feb 9, 2024
@hakman
Copy link
Member Author

hakman commented Feb 9, 2024

/test pull-kops-e2e-k8s-aws-calico

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2024
@k8s-ci-robot k8s-ci-robot merged commit 54344d0 into kubernetes:master Feb 9, 2024
23 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Feb 9, 2024
@hakman hakman deleted the azure-sdk-go-new-version branch February 9, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/documentation area/provider/azure Issues or PRs related to azure provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants