mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
refactor(edgegroup): optimize edge group search performance [BE-11716] (#579)
This commit is contained in:
parent
1edc56c0ce
commit
7e5db1f55e
1 changed files with 7 additions and 9 deletions
|
@ -13,21 +13,19 @@ func EdgeGroupRelatedEndpoints(edgeGroup *portainer.EdgeGroup, endpoints []porta
|
||||||
return edgeGroup.Endpoints
|
return edgeGroup.Endpoints
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endpointGroupsMap := map[portainer.EndpointGroupID]*portainer.EndpointGroup{}
|
||||||
|
for i, group := range endpointGroups {
|
||||||
|
endpointGroupsMap[group.ID] = &endpointGroups[i]
|
||||||
|
}
|
||||||
|
|
||||||
endpointIDs := []portainer.EndpointID{}
|
endpointIDs := []portainer.EndpointID{}
|
||||||
for _, endpoint := range endpoints {
|
for _, endpoint := range endpoints {
|
||||||
if !endpointutils.IsEdgeEndpoint(&endpoint) {
|
if !endpointutils.IsEdgeEndpoint(&endpoint) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var endpointGroup portainer.EndpointGroup
|
endpointGroup := endpointGroupsMap[endpoint.GroupID]
|
||||||
for _, group := range endpointGroups {
|
if edgeGroupRelatedToEndpoint(edgeGroup, &endpoint, endpointGroup) {
|
||||||
if endpoint.GroupID == group.ID {
|
|
||||||
endpointGroup = group
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if edgeGroupRelatedToEndpoint(edgeGroup, &endpoint, &endpointGroup) {
|
|
||||||
endpointIDs = append(endpointIDs, endpoint.ID)
|
endpointIDs = append(endpointIDs, endpoint.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue