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

pkg/endpoint: return NamedPorts model consistently #11490

Merged
merged 1 commit into from
May 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/endpoint/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,17 @@ func (e *Endpoint) GetHealthModel() *models.EndpointHealth {
// Must be called with e.Mutex locked.
func (e *Endpoint) getNamedPortsModel() (np models.NamedPorts) {
k8sPorts := e.k8sPorts
// keep named ports ordered to avoid the unnecessary updates to
// kube-apiserver
names := make([]string, 0, len(k8sPorts))
for name := range k8sPorts {
names = append(names, name)
}
sort.Strings(names)

np = make(models.NamedPorts, 0, len(k8sPorts))
for name, value := range k8sPorts {
for _, name := range names {
value := k8sPorts[name]
np = append(np, &models.Port{
Name: name,
Port: value.Port,
Expand Down