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

Add management cluster name validation to controller #4901

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

vivek-koppuru
Copy link
Member

@vivek-koppuru vivek-koppuru commented Feb 10, 2023

Issue #, if available:

Description of changes:
This is the same validation from #4596 except from the controller side. Made some minor refactoring as well as fix a mockgen issue due to golang/mock#494, from which I followed https://github.com/golang/mock#reflect-vendoring-error

Chose to do validation in controller instead of webhook as we have access to client there that will allow us to retrieve the older object.

Testing (if applicable):
functional testing and unit testing

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@vivek-koppuru
Copy link
Member Author

/hold

@eks-distro-bot eks-distro-bot added do-not-merge/hold size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 10, 2023
@vivek-koppuru vivek-koppuru self-assigned this Feb 10, 2023
@codecov
Copy link

codecov bot commented Feb 10, 2023

Codecov Report

Merging #4901 (7066352) into main (aa9278b) will increase coverage by 0.04%.
The diff coverage is 94.00%.

@@            Coverage Diff             @@
##             main    #4901      +/-   ##
==========================================
+ Coverage   71.61%   71.66%   +0.04%     
==========================================
  Files         419      420       +1     
  Lines       34198    34210      +12     
==========================================
+ Hits        24492    24515      +23     
+ Misses       8177     8167      -10     
+ Partials     1529     1528       -1     
Impacted Files Coverage Δ
pkg/controller/clusters/ipvalidator.go 86.36% <86.36%> (ø)
controllers/cluster_controller.go 76.99% <100.00%> (+2.23%) ⬆️
controllers/factory.go 96.31% <100.00%> (+0.01%) ⬆️
pkg/controller/clusters/validations.go 100.00% <100.00%> (+12.00%) ⬆️
pkg/workflows/upgrade.go 63.57% <0.00%> (-0.47%) ⬇️
pkg/api/v1alpha1/snowmachineconfig.go 93.68% <0.00%> (-0.20%) ⬇️
pkg/aws/snowballdevice.go 100.00% <0.00%> (ø)
pkg/api/v1alpha1/snowmachineconfig_types.go 52.83% <0.00%> (ø)
pkg/providers/snow/validator.go 95.38% <0.00%> (+0.34%) ⬆️
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@vivek-koppuru
Copy link
Member Author

/unhold

@@ -67,7 +67,7 @@ func newVsphereClusterReconcilerTest(t *testing.T, objs ...runtime.Object) *vsph
Add(anywherev1.VSphereDatacenterKind, reconciler).
Build()

r := controllers.NewClusterReconciler(cl, &registry, iam)
r := controllers.NewClusterReconciler(cl, &registry, iam, clusters.NewClusterValidator(cl))
Copy link
Member

Choose a reason for hiding this comment

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

should we use the mock cluster validator for the tests in this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohh looks like I missed this file, thanks for pointing it out!

Copy link
Member

@cxbrowne1207 cxbrowne1207 left a comment

Choose a reason for hiding this comment

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

/lgtm

Comment on lines +58 to +62
// ClusterValidator runs cluster level preflight validations before it goes to provider reconciler.
type ClusterValidator interface {
ValidateManagementClusterName(ctx context.Context, log logr.Logger, cluster *anywherev1.Cluster) error
}

Copy link
Member

@cxbrowne1207 cxbrowne1207 Feb 13, 2023

Choose a reason for hiding this comment

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

This may clash with the ClusterValidator located in the e2e tests, as it serves a similar purpose. The idea was to use it in the main code eventually, so we may have to merge them at some point

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it should be fine for now because they are independent enough, don't expect the interface to clash

Copy link
Member

@cxbrowne1207 cxbrowne1207 left a comment

Choose a reason for hiding this comment

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

Left a comment FYI

@vivek-koppuru
Copy link
Member Author

/approve

@eks-distro-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vivek-koppuru

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

@vivek-koppuru
Copy link
Member Author

/retest

1 similar comment
@vivek-koppuru
Copy link
Member Author

/retest

@eks-distro-bot eks-distro-bot merged commit dc7a07e into aws:main Feb 13, 2023
@vivek-koppuru vivek-koppuru deleted the name-valid branch January 26, 2024 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants