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

Validate providerID for user-assigned IDs in webhook #3618

Merged

Conversation

mboersma
Copy link
Contributor

@mboersma mboersma commented Jun 9, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

Adds ProviderID to the validation of user-assigned identities called by the AzureMachine webhook. Also moves ParseResourceID() to util/azure to avoid circular import errors.

Which issue(s) this PR fixes:

Inspired by this comment.
Refs #3597

Special notes for your reviewer:

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Validate providerID for user-assigned IDs in webhook

@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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 9, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 9, 2023
}
for _, identity := range userAssignedIdentities {
if identity.ProviderID != "" {
if _, err := arm.ParseResourceID(strings.TrimPrefix(identity.ProviderID, "azure://")); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't use the azure.ParseResourceID() func added in #3616 because it would cause a circular import error.

Copy link
Contributor

@CecileRobertMichon CecileRobertMichon Jun 12, 2023

Choose a reason for hiding this comment

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

The azure.go file itself doesn't import the api package, I wonder if we should move all azure "util" functions to its own package so we can use the same logic in both places

Copy link
Contributor

Choose a reason for hiding this comment

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

@mboersma thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I actually tried moving the ParseResourceID() function to util/azure and that would work. I'll try to update this PR later today.

@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Patch coverage: 76.00% and project coverage change: -0.11 ⚠️

Comparison is base (b6e1474) 53.73% compared to head (ddd2641) 53.62%.

❗ Current head ddd2641 differs from pull request most recent head 8e39922. Consider uploading reports for the commit 8e39922 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3618      +/-   ##
==========================================
- Coverage   53.73%   53.62%   -0.11%     
==========================================
  Files         185      185              
  Lines       18589    18554      -35     
==========================================
- Hits         9988     9949      -39     
- Misses       8059     8063       +4     
  Partials      542      542              
Impacted Files Coverage Δ
azure/defaults.go 8.06% <ø> (-1.46%) ⬇️
azure/services/natgateways/spec.go 4.08% <0.00%> (ø)
azure/services/virtualmachines/client.go 0.00% <0.00%> (ø)
azure/types.go 16.27% <0.00%> (ø)
azure/scope/machinepool.go 32.31% <50.00%> (ø)
azure/services/scalesetvms/scalesetvms.go 63.41% <66.66%> (ø)
api/v1beta1/azuremachine_validation.go 83.86% <100.00%> (+0.31%) ⬆️
azure/converters/identity.go 100.00% <100.00%> (ø)
azure/scope/machine.go 51.12% <100.00%> (ø)
azure/services/scalesets/scalesets.go 69.83% <100.00%> (ø)
... and 3 more

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@nawazkh
Copy link
Member

nawazkh commented Jun 12, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 12, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 8530d3e60adc4844637313779ba212f8aec239a9

@mboersma
Copy link
Contributor Author

/milestone v1.10

@k8s-ci-robot k8s-ci-robot added this to the v1.10 milestone Jun 15, 2023
@mboersma mboersma force-pushed the is-your-provider-id-valid-sir branch from 0451032 to d7a5b34 Compare June 15, 2023 18:51
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 15, 2023
@k8s-ci-robot k8s-ci-robot requested a review from nawazkh June 15, 2023 18:51
@mboersma
Copy link
Contributor Author

mboersma commented Jun 15, 2023

/hold

I rebased this on #3612 so moving ParseResourceID() wasn't too confusing. I'll rebase again on main after that merges.

Edit: re-rebased, but kept as two commits for now, pending review.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 15, 2023
@mboersma mboersma force-pushed the is-your-provider-id-valid-sir branch from d7a5b34 to ddd2641 Compare June 15, 2023 19:46
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 19, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: d8769afe6e58020cde9d2fecd67043f8d8a62add

@mboersma mboersma force-pushed the is-your-provider-id-valid-sir branch from ddd2641 to 8e39922 Compare June 19, 2023 16:25
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 19, 2023
@mboersma
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 19, 2023
@CecileRobertMichon
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 19, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: a1fb2c71aaf86ad764fbe2d9b5c870c132e168c3

@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 Jun 19, 2023
@k8s-ci-robot k8s-ci-robot merged commit 41d1a58 into kubernetes-sigs:main Jun 19, 2023
@mboersma mboersma deleted the is-your-provider-id-valid-sir branch June 19, 2023 18:07
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants