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

Service LB SKU support(reconcile path) #7138

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kartickmsft
Copy link

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 26, 2024
Copy link

linux-foundation-easycla bot commented Sep 26, 2024

CLA Not Signed

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Sep 26, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kartickmsft
Once this PR has been reviewed and has the lgtm label, please assign lzhecheng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

Welcome @kartickmsft!

It looks like this is your first PR to kubernetes-sigs/cloud-provider-azure 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cloud-provider-azure has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 26, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @kartickmsft. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 26, 2024
Copy link

@david-kow david-kow left a comment

Choose a reason for hiding this comment

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

I'd opt for more return statements and less nesting, but LGTM overall


if az.useServiceLoadBalancer() {
//If Interger value of TargetPort is present in the service, use it as the backend port.
//We current don't support string(named Port).

Choose a reason for hiding this comment

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

What will happen if we hit this? Shouldn't we error out?

Copy link
Author

Choose a reason for hiding this comment

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

I think better to error out as we are overridding the customer intent.

@@ -409,7 +409,7 @@ func getLocalServiceBackendPoolName(serviceName string, ipv6 bool) string {
// getBackendPoolNameForService determine the expected backend pool name
// by checking the external traffic policy of the service.
func (az *Cloud) getBackendPoolNameForService(service *v1.Service, clusterName string, ipv6 bool) string {
if !isLocalService(service) || !az.useMultipleStandardLoadBalancers() {
if !isLocalService(service) || (!az.useMultipleStandardLoadBalancers() && !az.useServiceLoadBalancer()) {

Choose a reason for hiding this comment

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

Can we reverse this if? I think it will be much simpler to read.

@@ -409,7 +409,7 @@ func getLocalServiceBackendPoolName(serviceName string, ipv6 bool) string {
// getBackendPoolNameForService determine the expected backend pool name
// by checking the external traffic policy of the service.
func (az *Cloud) getBackendPoolNameForService(service *v1.Service, clusterName string, ipv6 bool) string {
if !isLocalService(service) || !az.useMultipleStandardLoadBalancers() {

Choose a reason for hiding this comment

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

Didn't we say that we should ignore local/not local for service sku? Now the name will vary based on that setting

@@ -409,7 +409,7 @@ func getLocalServiceBackendPoolName(serviceName string, ipv6 bool) string {
// getBackendPoolNameForService determine the expected backend pool name
// by checking the external traffic policy of the service.
func (az *Cloud) getBackendPoolNameForService(service *v1.Service, clusterName string, ipv6 bool) string {
if !isLocalService(service) || !az.useMultipleStandardLoadBalancers() {
if !isLocalService(service) || (!az.useMultipleStandardLoadBalancers() && !az.useServiceLoadBalancer()) {
return getBackendPoolName(clusterName, ipv6)
}
return getLocalServiceBackendPoolName(getServiceName(service), ipv6)

Choose a reason for hiding this comment

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

Can service name be longer than allowed backend pool name? Should we use uuid instead?

/* Remove all addresses from the backend pool and add the addresses from all the
endpoint-slices pertaining to a service.*/
if strings.EqualFold(ptr.Deref(backendPool.Name, ""), lbBackendPoolName) &&
backendPool.BackendAddressPoolPropertiesFormat != nil {

Choose a reason for hiding this comment

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

Can we escape early to avoid nesting? Also, should we handle the error case that "if" checks here?

pkg/provider/azure_loadbalancer_backendpool.go Outdated Show resolved Hide resolved
klog.V(6).Infof("bpi.EnsureHostsInPool: adding ip address %s", address)
podIPsToBeAdded = append(podIPsToBeAdded, address)
endpointsliceName = strings.ToLower(fmt.Sprintf("%s/%s", ES.Namespace, ES.Name))
endpointSliceNames = append(endpointSliceNames,endpointsliceName)

Choose a reason for hiding this comment

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

Should this be added for every address?

Copy link
Author

@kartickmsft kartickmsft Oct 1, 2024

Choose a reason for hiding this comment

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

A new property is used in the Address for the slice/ipgroup name if we use the old createOrUpdateBackendPool API. I think we don't need to populate this field if we the updateBackendIpGroup API.

var changed bool
addresses := *backendPool.LoadBalancerBackendAddresses
for _, ipAddress := range podIPAddresses {
if !hasIPAddressInBackendPool(backendPool, ipAddress) {

Choose a reason for hiding this comment

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

Can we do a duplicate check earlier instead of scanning the pool with each add?

}

backendPrivateIPv4s, backendPrivateIPv6s := utilsets.NewString(), utilsets.NewString()
for _, bp := range *lb.BackendAddressPools {

Choose a reason for hiding this comment

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

Can we reduce nesting a little in this func?

Copy link
Author

Choose a reason for hiding this comment

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

sure

endpoint-slices pertaining to a service.*/
if strings.EqualFold(ptr.Deref(backendPool.Name, ""), lbBackendPoolName) &&
backendPool.BackendAddressPoolPropertiesFormat != nil {
if backendPool.LoadBalancerBackendAddresses == nil {

Choose a reason for hiding this comment

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

Do we need these checks? removeNodeIPAddressesFromBackendPool checks already and addPodIPAddressesToBackendPool inits it as well.

@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/needs-kind do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

3 participants