configure community filter cutoff
This commit is contained in:
parent
01491ec0b4
commit
6fe7856808
@ -69,22 +69,28 @@ const (
|
||||
// DefaultHTTPTimeout is the time in seconds after which the
|
||||
// server will timeout.
|
||||
DefaultHTTPTimeout = 120
|
||||
|
||||
// DefaultPrefixLookupCommunityFilterCutoff is the number of
|
||||
// routes after which the community filter will not be
|
||||
// available.
|
||||
DefaultPrefixLookupCommunityFilterCutoff = 100000
|
||||
)
|
||||
|
||||
// A ServerConfig holds the runtime configuration
|
||||
// for the backend.
|
||||
type ServerConfig struct {
|
||||
Listen string `ini:"listen_http"`
|
||||
HTTPTimeout int `ini:"http_timeout"`
|
||||
EnablePrefixLookup bool `ini:"enable_prefix_lookup"`
|
||||
NeighborsStoreRefreshInterval int `ini:"neighbors_store_refresh_interval"`
|
||||
NeighborsStoreRefreshParallelism int `ini:"neighbors_store_refresh_parallelism"`
|
||||
RoutesStoreRefreshInterval int `ini:"routes_store_refresh_interval"`
|
||||
RoutesStoreRefreshParallelism int `ini:"routes_store_refresh_parallelism"`
|
||||
StoreBackend string `ini:"store_backend"`
|
||||
DefaultAsn int `ini:"asn"`
|
||||
EnableNeighborsStatusRefresh bool `ini:"enable_neighbors_status_refresh"`
|
||||
StreamParserThrottle int `ini:"stream_parser_throttle"`
|
||||
Listen string `ini:"listen_http"`
|
||||
HTTPTimeout int `ini:"http_timeout"`
|
||||
EnablePrefixLookup bool `ini:"enable_prefix_lookup"`
|
||||
PrefixLookupCommunityFilterCutoff int `ini:"prefix_lookup_community_filter_cutoff"`
|
||||
NeighborsStoreRefreshInterval int `ini:"neighbors_store_refresh_interval"`
|
||||
NeighborsStoreRefreshParallelism int `ini:"neighbors_store_refresh_parallelism"`
|
||||
RoutesStoreRefreshInterval int `ini:"routes_store_refresh_interval"`
|
||||
RoutesStoreRefreshParallelism int `ini:"routes_store_refresh_parallelism"`
|
||||
StoreBackend string `ini:"store_backend"`
|
||||
DefaultAsn int `ini:"asn"`
|
||||
EnableNeighborsStatusRefresh bool `ini:"enable_neighbors_status_refresh"`
|
||||
StreamParserThrottle int `ini:"stream_parser_throttle"`
|
||||
}
|
||||
|
||||
// PostgresConfig is the configuration for the database
|
||||
@ -928,10 +934,11 @@ func LoadConfig(file string) (*Config, error) {
|
||||
|
||||
// Map sections
|
||||
server := ServerConfig{
|
||||
HTTPTimeout: DefaultHTTPTimeout,
|
||||
StoreBackend: "memory",
|
||||
RoutesStoreRefreshParallelism: 1,
|
||||
NeighborsStoreRefreshParallelism: 1,
|
||||
HTTPTimeout: DefaultHTTPTimeout,
|
||||
PrefixLookupCommunityFilterCutoff: DefaultPrefixLookupCommunityFilterCutoff,
|
||||
StoreBackend: "memory",
|
||||
RoutesStoreRefreshParallelism: 1,
|
||||
NeighborsStoreRefreshParallelism: 1,
|
||||
}
|
||||
if err := parsedConfig.Section("server").MapTo(&server); err != nil {
|
||||
return nil, err
|
||||
|
@ -38,6 +38,11 @@ func TestLoadConfigs(t *testing.T) {
|
||||
t.Error("expcted to find example community 1:23 with 'some tag'",
|
||||
"but got:", label)
|
||||
}
|
||||
|
||||
// Check prefix lookup cutoff
|
||||
if config.Server.PrefixLookupCommunityFilterCutoff != 123 {
|
||||
t.Error("Expected PrefixLookupCommunityFilterCutoff to be 123")
|
||||
}
|
||||
}
|
||||
|
||||
// TestSourceConfig checks that the proper backend type was identified for each
|
||||
|
7
pkg/config/testdata/alice.conf
vendored
7
pkg/config/testdata/alice.conf
vendored
@ -18,6 +18,13 @@ enable_prefix_lookup = true
|
||||
enable_neighbors_status_refresh = false
|
||||
# this ASN is used as a fallback value in the RPKI feature and for route
|
||||
# filtering evaluation with large BGP communities
|
||||
#
|
||||
# Prefix lookup community filter cutoff defines an upper limit
|
||||
# of returned routes for which the community filters list is
|
||||
# available. If the number of routes exceeds this limit, the
|
||||
# communities filters become available if there is a specific
|
||||
# route server selected.
|
||||
prefix_lookup_community_filter_cutoff = 123
|
||||
|
||||
# how many route servers will be refreshed at the same time
|
||||
# if set to 0 (or for the matter of fact 1), refresh will be
|
||||
|
@ -78,9 +78,10 @@ func (s *Server) apiLookupPrefixGlobal(
|
||||
imported := make(api.LookupRoutes, 0, totalResults)
|
||||
filtered := make(api.LookupRoutes, 0, totalResults)
|
||||
|
||||
// TODO: Make configurable
|
||||
communityFilterCutoff := 100000
|
||||
canFilterCommunities := totalResults <= communityFilterCutoff
|
||||
// Check if we should calculate community filter
|
||||
// cardinalities.
|
||||
filterCutoff := s.cfg.Server.PrefixLookupCommunityFilterCutoff
|
||||
canFilterCommunities := totalResults <= filterCutoff
|
||||
|
||||
// In case there is a source filter applied, we can filter communities
|
||||
if filtersApplied.HasGroup(api.SearchKeySources) {
|
||||
@ -89,7 +90,8 @@ func (s *Server) apiLookupPrefixGlobal(
|
||||
|
||||
filtersNotAvailable := []string{}
|
||||
if !canFilterCommunities {
|
||||
filtersNotAvailable = append(filtersNotAvailable, api.SearchKeyCommunities)
|
||||
filtersNotAvailable = append(
|
||||
filtersNotAvailable, api.SearchKeyCommunities)
|
||||
}
|
||||
|
||||
// Now, as we have allocated even more space process routes by, splitting,
|
||||
|
@ -54,6 +54,15 @@ func (s *Server) Start(ctx context.Context) {
|
||||
|
||||
httpTimeout := time.Duration(s.cfg.Server.HTTPTimeout) * time.Second
|
||||
log.Println("Web server HTTP timeout set to:", httpTimeout)
|
||||
log.Println("Listening on:", s.cfg.Server.Listen)
|
||||
|
||||
if s.cfg.Server.EnablePrefixLookup {
|
||||
log.Println("Prefix Lookup (Search): enabled")
|
||||
log.Println("Prefix Lookup Community Filter Cutoff:",
|
||||
s.cfg.Server.PrefixLookupCommunityFilterCutoff)
|
||||
} else {
|
||||
log.Println("Prefix Lookup (Search): disabled")
|
||||
}
|
||||
|
||||
s.Server = &http.Server{
|
||||
Addr: s.cfg.Server.Listen,
|
||||
|
Loading…
x
Reference in New Issue
Block a user