Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Deduplicate endpoints for ingress that has port defined #2321

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

StrongMonkey
Copy link
Contributor

@StrongMonkey StrongMonkey commented Nov 4, 2023

Checklist

  • The title of this PR would make a good line in Acorn's Release Note's Changelog
  • The title of this PR ends with a link to the main issue being address in parentheses, like: This is a title (#1216). Here's an example
  • All relevant issues are referenced in the PR description. NOTE: don't use GitHub keywords that auto-close issues
  • Commits follow contributing guidance
  • Automated tests added to cover the changes. If tests couldn't be added, an explanation is provided in the Verification and Testing section
  • Changes to user-facing functionality, API, CLI, and upgrade impacts are clearly called out in PR description
  • PR has at least two approvals before merging (or a reasonable exception, like it's just a docs change)

In case of NLB port allocation, the service.status.ingress already have ports allocated. So we shouldn't need to read ports from service.spec.ports, as it will cause duplicated endpoints. So, deduplicate the endpoints to make sure each endpoint is unique

acorn-io/aws-load-balancer-controller#2

Related issue: https://github.com/acorn-io/manager/issues/1568 https://github.com/acorn-io/manager/issues/1567

@StrongMonkey StrongMonkey changed the title Don't loop over ports if status.ingress has port defined Deduplicate endpoints for ingress that has port defined Nov 7, 2023
set[fmt.Sprintf("%v://%v", ep.Protocol, ep.Address)] = ep
}

var result []v1.Endpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

nit to avoid multiple allocations:

Suggested change
var result []v1.Endpoint
result := make([]v1.Endpoint, 0, len(set))

pkg/controller/appstatus/endpoints.go Outdated Show resolved Hide resolved
@StrongMonkey StrongMonkey merged commit c337c56 into acorn-io:main Nov 7, 2023
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants