ips: prevent panic when no pools match filters

This commit is contained in:
ionutboangiu
2025-08-07 10:00:17 +03:00
committed by Dan Christian Bogos
parent 262f1dafa3
commit 82cfff3cff

View File

@@ -338,6 +338,9 @@ func filterAndSortPools(ctx *context.Context, tenant string, pools []*utils.IPPo
weights[pool.ID] = weight
filteredPools = append(filteredPools, pool)
}
if len(filteredPools) == 0 {
return nil, utils.ErrNotFound
}
// Sort by weight (higher values first).
slices.SortFunc(filteredPools, func(a, b *utils.IPPool) int {