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

fix(api-server): skip display-name label for service insight #11508

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/api-server/service_insight_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package api_server

import (
"fmt"
"maps"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -55,6 +56,7 @@ func (s *serviceInsightEndpoints) findResource(request *restful.Request, respons
res := out.(*rest_unversioned.Resource)
res.Meta.Name = service
res.Spec = stat
removeDisplayNameLabel(res)
if err := response.WriteAsJson(res); err != nil {
core.Log.Error(err, "Could not write the response")
}
Expand Down Expand Up @@ -145,6 +147,7 @@ func (s *serviceInsightEndpoints) expandInsights(serviceInsightList *mesh.Servic
res := out.(*rest_unversioned.Resource)
res.Meta.Name = serviceName
res.Spec = service
removeDisplayNameLabel(res)
restItems = append(restItems, out)
}
}
Expand Down Expand Up @@ -196,3 +199,13 @@ func (s *serviceInsightEndpoints) paginateResources(request *restful.Request, re
restList.Next = nextLink(request, nextOffset)
return nil
}

// Since the value of label "kuma.io/display-name" is same with the ServiceInsight resource name,
// in which it looks weird for the API to each service. Ref: https://github.com/kumahq/kuma/issues/9729
func removeDisplayNameLabel(resource *rest_unversioned.Resource) {
tmpMeta := resource.GetMeta()
maps.DeleteFunc(tmpMeta.Labels, func(key string, val string) bool {
return key == v1alpha1.DisplayName
})
resource.Meta = tmpMeta
}
2 changes: 2 additions & 0 deletions pkg/api-server/testdata/service-insights/get.input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ name: mesh-1
type: ServiceInsight
mesh: mesh-1
name: all-services-mesh-1
labels:
kuma.io/display-name: all-services-mesh-1 # add display name manually to test if it's removed in the response
services:
backend:
status: partially_degraded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ name: mesh-1
type: ServiceInsight
mesh: mesh-1
name: all-services-mesh-1
labels:
kuma.io/display-name: all-services-mesh-1 # add display name manually to test if it's removed in the response
services:
frontend:
status: partially_degraded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ name: mesh-1
type: ServiceInsight
mesh: mesh-1
name: all-services-mesh-1
labels:
kuma.io/display-name: all-services-mesh-1 # add display name manually to test if it's removed in the response
services:
frontend:
status: partially_degraded
Expand Down
Loading