-
Notifications
You must be signed in to change notification settings - Fork 87
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 validation for loadbalancer port against 6443 and to avoid duplicate names #1746
Add validation for loadbalancer port against 6443 and to avoid duplicate names #1746
Conversation
Hi @KeerthanaAP. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
✅ Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
433e48c
to
1f97063
Compare
/retest-required |
ptal @Karthik-K-N |
@@ -81,6 +81,7 @@ type VPCLoadBalancerSpec struct { | |||
// +listType=map | |||
// +listMapKey=port | |||
// +optional | |||
// ++kubebuilder:validation:UniqueItems=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do mind sharing some reference about this tag usage.
Since its slice and for now we have only Port within it. what should be unique, Is port? in future we add another field name say PortName along with port then what should be unique is it port or port and portName combination?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// +kubebuilder:validation:UniqueItems = <bool>
specifies that all items in this list must be unique.
As mentioned it validates the ports. All the ports should be unique. if we add another field like PortName, it will fail only if both the fields (portName and port) are same.
1f97063
to
5079456
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM Thanks, Is there any way to improve the error message
spec.vpcSubnets[1]: Duplicate value: map[string]interface {}{"Name":"capi-powervs-keerthana-vpcsubnet"}
to remove map[string]interface {}
5079456
to
bb43dd2
Compare
I followed the same error msg format that we get when we apply the kubebuilder tag Example: or
|
Thanks for clarifying |
@mkumatag @Prajyot-Parab ptal. |
update release notes field please. |
Done. Updated the release notes. |
func (r *IBMPowerVSCluster) validateIBMPowerVSClusterLoadBalancerPort() (allErrs field.ErrorList) { | ||
for i, loadbalancer := range r.Spec.LoadBalancers { | ||
for j, listerner := range loadbalancer.AdditionalListeners { | ||
if listerner.Port == int64(DefaultAPIServerPort) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if this port is set Cluster.Spec.ClusterNetwork.APIServerPort
? will this comparison with DefaultAPIServerPort
still hold good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it won't hold good, if user has set Cluster.Spec.ClusterNetwork.APIServerPort
we should make sure that that port is not set here in listner.
We usually find the apiserver port like this
cluster-api-provider-ibmcloud/cloud/scope/powervs_cluster.go
Lines 336 to 342 in 81e93e2
// APIServerPort returns the APIServerPort to use when creating the ControlPlaneEndpoint. | |
func (s *PowerVSClusterScope) APIServerPort() int32 { | |
if s.Cluster.Spec.ClusterNetwork != nil && s.Cluster.Spec.ClusterNetwork.APIServerPort != nil { | |
return *s.Cluster.Spec.ClusterNetwork.APIServerPort | |
} | |
return infrav1beta2.DefaultAPIServerPort | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont have access to cluster resource here in webhook, So we need verify this one scenario in controller code only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then adding this check here for the DefaultAPIServerPort
may mislead the user, lets drop this change here and introduce in the controller itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most of the time the apiserver will be running in 6443 only, so i think we can keep it here and can add a check in controller only if the apiserver port is not 6443.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Will add this as error msg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the error msg.
Updated output:
Conditions:
Last Transition Time: 2024-05-27T17:01:33Z
Message: capi-powervs-keerthana-new-loadbalancer2 port (6443) cannot be used as additional Listener port value, as its already configured by system for default listener
Reason: LoadBalancerReconciliationFailed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, Lets hear others opinion on as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about this one - #1746 (comment)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. As the error strings should not be capitalized, Can we update it as below.
Conditions:
Last Transition Time: 2024-05-29T07:03:15Z
Message: port 6443 for the capi-powervs-keerthana-new-loadbalancer2 load balancer cannot be used as an additional listener port, as it is already assigned to the API server
Reason: LoadBalancerReconciliationFailed
bb43dd2
to
94dbb22
Compare
@KeerthanaAP can you make the changes by tomorrow sometime? we are planning to cut a release soon |
572b09e
to
d8e1605
Compare
c58e4da
to
af434d1
Compare
…o avoid duplicates.
af434d1
to
643d878
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: KeerthanaAP, mkumatag 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 |
Added validation for loadbalancer port against 6443 as its already used, kubebuilder tag to avoid duplicate ports and validation to avoid duplicate loadbalancer, vpcsubnet names.
Validation output:
What this PR does / why we need it:
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 #1663
Special notes for your reviewer:
/area provider/ibmcloud
Release note: