Skip to content

fix AzCluster_default and AzCluster_validation webhooks #5603

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

Merged
merged 3 commits into from
May 6, 2025

Conversation

nawazkh
Copy link
Member

@nawazkh nawazkh commented May 1, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

  • This PR removes unused defaulters and fixes code and tests for AzCluster_default and AzCluster_validation.

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 #

Special notes for your reviewer:

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
  • cherry-pick candidate

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. labels May 1, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 1, 2025
@nawazkh nawazkh requested a review from Copilot May 1, 2025 05:17
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 1, 2025
@nawazkh
Copy link
Member Author

nawazkh commented May 1, 2025

/label tide/merge-method-squash

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR primarily addresses code cleanup by removing unused defaulters and updating tests and validation functions. The key changes include:

  • Removal of the unused TestControlPlaneOutboundLBTemplateDefaults test case.
  • Refactoring test structures and parallel execution in validation tests.
  • Correction of typographical and indexing errors in defaulting and validation functions.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
api/v1beta1/azureclustertemplate_default_test.go Removed unused test for control plane outbound LB defaults.
api/v1beta1/azurecluster_validation_test.go Updated test struct and looping constructs for clarity.
api/v1beta1/azurecluster_validation.go Fixed index usage in security rules validation.
api/v1beta1/azurecluster_default.go Corrected function naming typo and constant usage in defaults.

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 1, 2025
Copy link

codecov bot commented May 1, 2025

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 53.27%. Comparing base (c3f0631) to head (8900eb1).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
api/v1beta1/azurecluster_validation.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5603      +/-   ##
==========================================
- Coverage   53.28%   53.27%   -0.02%     
==========================================
  Files         272      272              
  Lines       29537    29521      -16     
==========================================
- Hits        15739    15727      -12     
+ Misses      12983    12979       -4     
  Partials      815      815              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nawazkh nawazkh moved this from Todo to Needs Review in CAPZ Planning May 1, 2025
@nawazkh
Copy link
Member Author

nawazkh commented May 1, 2025

/test pull-cluster-api-provider-azure-e2e

@@ -456,25 +456,6 @@ func (lb *LoadBalancerClassSpec) setOutboundLBDefaults() {
}
}

func setControlPlaneOutboundLBDefaults(lb *LoadBalancerClassSpec, apiserverLBType LBType) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This function is not used in the webhooks

@@ -1169,93 +1169,6 @@ func TestNodeOutboundLBClassDefaults(t *testing.T) {
}
}

func TestControlPlaneOutboundLBTemplateDefaults(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This deleted test tested the unused function from above (https://github.com/kubernetes-sigs/cluster-api-provider-azure/pull/5603/files#r2072129130)

@nawazkh
Copy link
Member Author

nawazkh commented May 2, 2025

/test ls

@k8s-ci-robot
Copy link
Contributor

@nawazkh: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

/test pull-cluster-api-provider-azure-apiversion-upgrade
/test pull-cluster-api-provider-azure-build
/test pull-cluster-api-provider-azure-ci-entrypoint
/test pull-cluster-api-provider-azure-e2e
/test pull-cluster-api-provider-azure-e2e-aks
/test pull-cluster-api-provider-azure-test
/test pull-cluster-api-provider-azure-verify

The following commands are available to trigger optional jobs:

/test pull-cluster-api-provider-azure-apidiff
/test pull-cluster-api-provider-azure-apiserver-ilb
/test pull-cluster-api-provider-azure-capi-e2e
/test pull-cluster-api-provider-azure-conformance
/test pull-cluster-api-provider-azure-conformance-custom-builds
/test pull-cluster-api-provider-azure-conformance-dual-stack-with-ci-artifacts
/test pull-cluster-api-provider-azure-conformance-ipv6-with-ci-artifacts
/test pull-cluster-api-provider-azure-conformance-with-ci-artifacts
/test pull-cluster-api-provider-azure-conformance-with-ci-artifacts-dra
/test pull-cluster-api-provider-azure-e2e-optional
/test pull-cluster-api-provider-azure-e2e-workload-upgrade
/test pull-cluster-api-provider-azure-load-test-custom-builds
/test pull-cluster-api-provider-azure-perf-test-apiserver-availability
/test pull-cluster-api-provider-azure-windows-custom-builds
/test pull-cluster-api-provider-azure-windows-with-ci-artifacts

Use /test all to run the following jobs that were automatically triggered:

pull-cluster-api-provider-azure-apidiff
pull-cluster-api-provider-azure-build
pull-cluster-api-provider-azure-ci-entrypoint
pull-cluster-api-provider-azure-e2e
pull-cluster-api-provider-azure-e2e-aks
pull-cluster-api-provider-azure-test
pull-cluster-api-provider-azure-verify

In response to this:

/test ls

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-sigs/prow repository.

@nawazkh
Copy link
Member Author

nawazkh commented May 2, 2025

/test pull-cluster-api-provider-azure-e2e-optional

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

if err := validateSecurityRule(
rule,
fldPath.Index(i).Child("securityGroup").Child("securityRules").Index(i),
fldPath.Index(i).Child("securityGroup").Child("securityRules").Index(j),
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we had a bug here...

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

LGTM label has been added.

Git tree hash: c355ffc1591f57d9efb6740ee4dd185ce3b3db74

@mboersma
Copy link
Contributor

mboersma commented May 5, 2025

Could you /retitle this to be more descriptive of what it changes?

@nawazkh
Copy link
Member Author

nawazkh commented May 5, 2025

/retitle fix AzCluster_default and AzCluster_validation webhooks

@k8s-ci-robot k8s-ci-robot changed the title Auditing codebase fix AzCluster_default and AzCluster_validation webhooks May 5, 2025
@nawazkh nawazkh requested a review from mboersma May 5, 2025 20:41
@mboersma mboersma removed the request for review from jsturtevant May 6, 2025 17:06
@mboersma
Copy link
Contributor

mboersma commented May 6, 2025

/assign @willie-yao

Copy link
Contributor

@willie-yao willie-yao left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: willie-yao

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 May 6, 2025
@k8s-ci-robot k8s-ci-robot merged commit d3c0f03 into kubernetes-sigs:main May 6, 2025
27 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone May 6, 2025
@github-project-automation github-project-automation bot moved this from Needs Review to Done in CAPZ Planning May 6, 2025
@nawazkh
Copy link
Member Author

nawazkh commented May 6, 2025

Even though this PR is a cleanup type, one of the webhooks was behaving weirdly(bug), so it qualifies to be cherry-picked..
/cherry-pick release-1.18
/cherry-pick release-1.19

@nawazkh nawazkh deleted the audit_codebase branch May 6, 2025 20:57
@k8s-infra-cherrypick-robot

@nawazkh: new pull request created: #5616

In response to this:

Even though this PR is a cleanup type, one of the webhooks was behaving weirdly(bug), so it qualifies to be cherry-picked..
/cherry-pick release-1.18
/cherry-pick release-1.19

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-sigs/prow repository.

@k8s-infra-cherrypick-robot

@nawazkh: new pull request created: #5617

In response to this:

Even though this PR is a cleanup type, one of the webhooks was behaving weirdly(bug), so it qualifies to be cherry-picked..
/cherry-pick release-1.18
/cherry-pick release-1.19

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-sigs/prow repository.

jsturtevant pushed a commit to jsturtevant/cluster-api-provider-azure that referenced this pull request May 13, 2025
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants