mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 05:15:25 +02:00
fix(edgegroups): convert the related endpoint IDs to roaring bitmaps to increase performance BE-12053 (#903)
This commit is contained in:
parent
caf382b64c
commit
937456596a
32 changed files with 1041 additions and 133 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
portainer "github.com/portainer/portainer/api"
|
||||
"github.com/portainer/portainer/api/dataservices"
|
||||
"github.com/portainer/portainer/api/internal/endpointutils"
|
||||
"github.com/portainer/portainer/api/roar"
|
||||
)
|
||||
|
||||
type endpointSetType map[portainer.EndpointID]bool
|
||||
|
@ -49,22 +50,29 @@ func GetEndpointsByTags(tx dataservices.DataStoreTx, tagIDs []portainer.TagID, p
|
|||
return results, nil
|
||||
}
|
||||
|
||||
func getTrustedEndpoints(tx dataservices.DataStoreTx, endpointIDs []portainer.EndpointID) ([]portainer.EndpointID, error) {
|
||||
func getTrustedEndpoints(tx dataservices.DataStoreTx, endpointIDs roar.Roar[portainer.EndpointID]) ([]portainer.EndpointID, error) {
|
||||
var innerErr error
|
||||
|
||||
results := []portainer.EndpointID{}
|
||||
for _, endpointID := range endpointIDs {
|
||||
|
||||
endpointIDs.Iterate(func(endpointID portainer.EndpointID) bool {
|
||||
endpoint, err := tx.Endpoint().Endpoint(endpointID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
innerErr = err
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
if !endpoint.UserTrusted {
|
||||
continue
|
||||
return true
|
||||
}
|
||||
|
||||
results = append(results, endpoint.ID)
|
||||
}
|
||||
|
||||
return results, nil
|
||||
return true
|
||||
})
|
||||
|
||||
return results, innerErr
|
||||
}
|
||||
|
||||
func mapEndpointGroupToEndpoints(endpoints []portainer.Endpoint) map[portainer.EndpointGroupID]endpointSetType {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue