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

🌱 Webhooks: make MDT.replicas and autoscaler mut. exclusive #10370

Conversation

neolit123
Copy link
Member

What this PR does / why we need it:

Add new validation functions in cluster.go
and clusterclass.go:

  • ValidateAutoscalerAnnotationsForCluster
  • ValidateAutoscalerAnnotationsForClusterClass

..ForCluster is called from validateTopology().
It makes sure that a given Topology does not contain
MachineDeploymentToplogy objects under Workers, that have
both a "replicas" field set to non-nil and autoscaler
min/max annotations present.

Also optionally it checks if there are annotations that are set
on the ClusterClass's MachineDeploymentClass for this
MachineDeploymentTopology.

..ForClusterClass accepts a list of Clusters that use
a certain ClusterClass. Inline, it uses the ..ForCluster
function and the same validation as above is performed.
It is called from validate() for a CC on update.

Additionally:

  • Add a new builder utility function
    MachineDeploymentTopologyBuilder#WithAnnotations().
  • Add 100% test coverage for the new validation functions.

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label labels Apr 3, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 3, 2024
@neolit123
Copy link
Member Author

/area clusterclass
/kind feature

@k8s-ci-robot k8s-ci-robot added area/clusterclass Issues or PRs related to clusterclass kind/feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/needs-area PR is missing an area label labels Apr 3, 2024
@neolit123 neolit123 changed the title internal/webhooks: make MDT.replicas and autoscaler mut. exclusive 🌱internal/webhooks: make MDT.replicas and autoscaler mut. exclusive Apr 3, 2024
@neolit123 neolit123 force-pushed the 1.7-add-mutex-for-autoscaler-and-replicas branch from 01f466e to 7bca522 Compare April 3, 2024 17:32
@neolit123
Copy link
Member Author

neolit123 commented Apr 3, 2024

/cc @sbueringer
you have to most context on this as we discussed on:
#10343
unclear, if i got everything right here.

@sbueringer
Copy link
Member

sbueringer commented Apr 4, 2024

Thx!
I'll wait a bit longer until the discussion on the issue is concluded. Please ping me again in case I'm not reviewing afterwards :)

Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Just a few smaller findings

internal/test/builder/builders.go Outdated Show resolved Hide resolved
internal/webhooks/cluster.go Outdated Show resolved Hide resolved
internal/webhooks/cluster.go Outdated Show resolved Hide resolved
internal/webhooks/cluster_test.go Outdated Show resolved Hide resolved
internal/webhooks/clusterclass_test.go Show resolved Hide resolved
Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

aside from @sbueringer 's questions, i think the logic makes sense to me.

internal/webhooks/cluster.go Outdated Show resolved Hide resolved
@neolit123 neolit123 force-pushed the 1.7-add-mutex-for-autoscaler-and-replicas branch from 7bca522 to 1edc35d Compare April 10, 2024 08:24
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Thank you!

Last one from my side

internal/webhooks/cluster.go Outdated Show resolved Hide resolved
Add new validation functions in cluster.go
and clusterclass.go:
- ValidateAutoscalerAnnotationsForCluster
- ValidateAutoscalerAnnotationsForClusterClass

..ForCluster is called from validateTopology().
It makes sure that a given Topology does not contain
MachineDeploymentToplogy objects under Workers, that have
both a "replicas" field set to non-nil and an autoscaler
min/max annotation present.

Also optionally it checks if there are annotations that are set
on the ClusterClass's MachineDeploymentClass for this
MachineDeploymentTopology.

..ForClusterClass accepts a list of Clusters that use
a certain ClusterClass. Inline, it uses the ..ForCluster
function and the same validation as above is performed.
It is called from validate() for a CC on update.

Additionally:
- Add a new builder utility function
  MachineDeploymentTopologyBuilder#WithAnnotations().
- Add 100% test coverage for the new validation functions.
@neolit123 neolit123 force-pushed the 1.7-add-mutex-for-autoscaler-and-replicas branch from 1edc35d to e035135 Compare April 10, 2024 16:04
@sbueringer
Copy link
Member

Thx!

/lgtm

/assign @fabriziopandini @chrischdi

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

LGTM label has been added.

Git tree hash: bc7169f6b5a5bef7f002b70c0d29f224c1e3aa91

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

/approve

Thanks for improving this! 🎉

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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 Apr 12, 2024
@k8s-ci-robot k8s-ci-robot merged commit 7485511 into kubernetes-sigs:main Apr 12, 2024
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.8 milestone Apr 12, 2024
@sbueringer sbueringer changed the title 🌱internal/webhooks: make MDT.replicas and autoscaler mut. exclusive 🌱 Webhooks: make MDT.replicas and autoscaler mut. exclusive Jul 19, 2024
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/clusterclass Issues or PRs related to clusterclass cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make the autoscaler annotations and the replicas field in cluster.spec.topology mutual exclusive
6 participants