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

fix: format azure compute gallery image ID #2747

Merged
merged 4 commits into from
Nov 8, 2022

Conversation

supershal
Copy link
Contributor

What type of PR is this?

/kind bug
What this PR does / why we need it:
Invalid formatting of compute gallery image id results in Azure machine fails to reconcile when compute gallery image is used.

E1020 05:16:10.545726       1 controller.go:326]  "msg"="Reconciler error" "error"="failed to reconcile AzureMachine: failed to reconcile AzureMachine service virtualmachine: failed to create resource e2e-azure-test-3661259/e2e-azure-test-3661259-control-plane-npm7k (service: virtualmachine): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=403 -- Original Error: Code=\"LinkedAuthorizationFailed\" Message=\"The client has permission to perform action 'Microsoft.Compute/galleries/images/versions/read' on scope '/subscriptions/*****-****-****-****-*******/resourceGroups/e2e-azure-test-3661259/providers/Microsoft.Compute/virtualMachines/e2e-azure-test-3661259-control-plane-npm7k', however the linked subscription '%!s(*string=0xc0010f00e0)' was not found. \"" "azureMachine"={"name":"e2e-azure-test-3661259-control-plane-npm7k","namespace":"default"} "controller"="azuremachine" "controllerGroup"="infrastructure.cluster.x-k8s.io" "controllerKind"="AzureMachine" "name"="e2e-azure-test-3661259-control-plane-npm7k" "namespace"="default" "reconcileID"="db366495-2601-4701-8b2c-cd2a41bc43e7"

The SubscriptionID and ResrouceGroup fields are string pointers in AzureComputeGalleryImage
When creating the compute gallery image id, they should be dereferenced to string.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2746

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Added unit test to verify the bug fix.
before bugfix:

go test -timeout 30s -run ^Test_ComputeImageToSDK$ sigs.k8s.io/cluster-api-provider-azure/azure/converters

--- FAIL: Test_ComputeImageToSDK (0.00s)
    --- FAIL: Test_ComputeImageToSDK/Should_returned_parsed_compute_gallery_image_id (0.00s)
        /gitrepos/cluster-api-provider-azure/azure/converters/image_test.go:169: 
            Expected
                <*compute.ImageReference | 0xc00037f140>: {
                    Publisher: nil,
                    Offer: nil,
                    Sku: nil,
                    Version: nil,
                    ExactVersion: nil,
                    SharedGalleryImageID: nil,
                    CommunityGalleryImageID: nil,
                    ID: "/subscriptions/%!s(*string=0xc000428960)/resourceGroups/%!s(*string=0xc000428950)/providers/Microsoft.Compute/galleries/my-gallery/images/my-image/versions/my-version",
                }
            to equal
                <*compute.ImageReference | 0xc00037f540>: {
                    Publisher: nil,
                    Offer: nil,
                    Sku: nil,
                    Version: nil,
                    ExactVersion: nil,
                    SharedGalleryImageID: nil,
                    CommunityGalleryImageID: nil,
                    ID: "/subscriptions/my-subscription-id/resourceGroups/my-resourcegroup/providers/Microsoft.Compute/galleries/my-gallery/images/my-image/versions/my-version",
                }
FAIL
FAIL	sigs.k8s.io/cluster-api-provider-azure/azure/converters	0.701s
FAIL

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

fix formatting of compute gallery image id

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Oct 21, 2022
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 21, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Oct 21, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @supershal!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-azure 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-azure has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 21, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @supershal. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 21, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 21, 2022
Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

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

/lgtm

Thank you for finding and fixing this @supershal!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 24, 2022
@mboersma
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 24, 2022
@dlipovetsky
Copy link
Contributor

Thanks for adding the unit test @supershal!

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 27, 2022
@supershal supershal requested review from mboersma and dlipovetsky and removed request for devigned, jackfrancis and mboersma October 27, 2022 20:26
@supershal supershal requested review from mboersma and removed request for dlipovetsky October 27, 2022 20:27
@supershal
Copy link
Contributor Author

/retest

Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

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

Looks good, just had a nitpick about the error message string.

azure/converters/image.go Outdated Show resolved Hide resolved
Co-authored-by: Matt Boersma <Matt.Boersma@microsoft.com>
Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

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

/lgtm
/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Oct 31, 2022
@mboersma
Copy link
Contributor

mboersma commented Nov 1, 2022

/assign @CecileRobertMichon

@CecileRobertMichon
Copy link
Contributor

/lgtm
/approve
/cherry-pick release-1.4
/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

@CecileRobertMichon: once the present PR merges, I will cherry-pick it on top of release-1.4 in a new PR and assign it to you.

In response to this:

/lgtm
/approve
/cherry-pick release-1.4
/cherry-pick release-1.5

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.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon

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 Nov 1, 2022
@supershal
Copy link
Contributor Author

/retest

2 similar comments
@supershal
Copy link
Contributor Author

/retest

@supershal
Copy link
Contributor Author

/retest

@CecileRobertMichon
Copy link
Contributor

/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

@CecileRobertMichon: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.5

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.

@k8s-ci-robot k8s-ci-robot merged commit e76faa3 into kubernetes-sigs:main Nov 8, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.6 milestone Nov 8, 2022
@k8s-infra-cherrypick-robot

@CecileRobertMichon: new pull request created: #2793

In response to this:

/lgtm
/approve
/cherry-pick release-1.4
/cherry-pick release-1.5

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.

@k8s-infra-cherrypick-robot

@CecileRobertMichon: new pull request created: #2794

In response to this:

/cherry-pick release-1.5

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.

cfullen11 pushed a commit to newrelic-forks/cluster-api-provider-azure that referenced this pull request Dec 9, 2022
* Add unit test to verify formatting of compute gallery image id

* fix: format azure compute gallery image ID

* add nil check for SharedGallery and ComputeGallery

* Fix error message text to use actual field names

Co-authored-by: Matt Boersma <Matt.Boersma@microsoft.com>

Co-authored-by: Matt Boersma <Matt.Boersma@microsoft.com>
cfullen11 pushed a commit to newrelic-forks/cluster-api-provider-azure that referenced this pull request Dec 9, 2022
* Add unit test to verify formatting of compute gallery image id

* fix: format azure compute gallery image ID

* add nil check for SharedGallery and ComputeGallery

* Fix error message text to use actual field names

Co-authored-by: Matt Boersma <Matt.Boersma@microsoft.com>

Co-authored-by: Matt Boersma <Matt.Boersma@microsoft.com>
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to reconcile AzureMachine when compute gallery image is used
6 participants