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 webhook for CNI overlay #4097

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

nojnhuh
Copy link
Contributor

@nojnhuh nojnhuh commented Oct 6, 2023

What type of PR is this?
/kind bug
/area managedclusters

What this PR does / why we need it:

This PR fixes a bug in the AzureManagedControlPlane update webhook when checking spec.networkPluginMode. The intent is to disallow changing the networkPluginMode to overlay when spec.networkPolicy is already enabled without overlay. The bug was disallowing updates to AzureManagedControlPlane whenever overlay is specified and networkPolicy was specified without verifying that the update modifies networkPluginMode.

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 #4093

Special notes for your reviewer:

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Fixed a bug disallowing certain valid updates to AzureManagedControlPlane with Azure CNI overlay enabled

@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. area/managedclusters Issues related to managed AKS clusters created through the CAPZ ManagedCluster Type cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 6, 2023
@nojnhuh
Copy link
Contributor Author

nojnhuh commented Oct 6, 2023

/cherry-pick release-1.11
(overlay cannot be enabled in v1.10)

@k8s-infra-cherrypick-robot

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

In response to this:

/cherry-pick release-1.11
(overlay cannot be enabled in v1.10)

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.

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (5aba3bb) 57.61% compared to head (b5eb475) 57.61%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4097   +/-   ##
=======================================
  Coverage   57.61%   57.61%           
=======================================
  Files         188      188           
  Lines       19200    19202    +2     
=======================================
+ Hits        11062    11064    +2     
  Misses       7507     7507           
  Partials      631      631           
Files Coverage Δ
api/v1beta1/azuremanagedcontrolplane_webhook.go 89.12% <100.00%> (+0.03%) ⬆️

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

@@ -1583,6 +1584,29 @@ func TestAzureManagedControlPlane_ValidateUpdate(t *testing.T) {
},
wantErr: false,
},
{
name: "NetworkPolicy is allowed when NetworkPluginMode is not changed",
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a permutation we're not covering in UT:

  1. Old = some NetworkPolicy + overlay NetworkPlugin
  2. New = some different NetworkPolicy + overlay NetworkPlugin

I assume that AKS would reject that update, do we have the right webhooks to optimize for CAPZ UX?

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 already have webhook and test coverage for the immutability of NetworkPlugin which isn't affected by the value of NetworkPluginMode. Or do you think it's worth checking to see if some updates might actually be allowed when overlay is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

s/NetworkPlugin/NetworkPolicy/

Copy link
Contributor

Choose a reason for hiding this comment

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

The subtlety of this change just makes me want to cover every (potentially) artificial scenario.

If we're fixing a specific use case let's just ship this and then we can watch closely and fine-tune our webhooks as we observe edge cases. We're already in a place where the actual behaviors don't match AKS documentation so I think we're probably just gonna have to be reactive. :/

@jackfrancis
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 Oct 6, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2372ae2c7e2111ad15d566415527ab317bdc8739

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jackfrancis

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 Oct 6, 2023
@k8s-ci-robot k8s-ci-robot merged commit e8c1108 into kubernetes-sigs:main Oct 6, 2023
10 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.12 milestone Oct 6, 2023
@k8s-infra-cherrypick-robot

@nojnhuh: failed to push cherry-picked changes in GitHub: pushToNamedFork is not implemented in the v2 client

In response to this:

/cherry-pick release-1.11
(overlay cannot be enabled in v1.10)

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.

@nojnhuh nojnhuh deleted the overlay-webhook branch October 6, 2023 18:43
@nojnhuh
Copy link
Contributor Author

nojnhuh commented Oct 7, 2023

/cherry-pick release-1.11

@k8s-infra-cherrypick-robot

@nojnhuh: failed to push cherry-picked changes in GitHub: pushToNamedFork is not implemented in the v2 client

In response to this:

/cherry-pick release-1.11

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.

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/managedclusters Issues related to managed AKS clusters created through the CAPZ ManagedCluster Type 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Can't create cluster with Azure CNI Overlay and NetworkPolicy
4 participants