Implement best effort allocation
This commit is contained in:
parent
4c040bbf78
commit
8ba4831d9c
|
@ -5,7 +5,7 @@ from twisted.internet.threads import deferToThread
|
||||||
|
|
||||||
import main
|
import main
|
||||||
import modules.provision
|
import modules.provision
|
||||||
from utils.logging.debug import debug
|
from utils.logging.debug import debug, trace
|
||||||
from utils.logging.log import error, log, warn
|
from utils.logging.log import error, log, warn
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,22 +77,31 @@ def emptyChanAllocate(net, flist, relay, new):
|
||||||
chans_not_covered = toalloc - sum_free # 2148 - 250 = 1898
|
chans_not_covered = toalloc - sum_free # 2148 - 250 = 1898
|
||||||
relays_needed = chans_not_covered / chanfree[1] # 1898 / 250 = 7.592
|
relays_needed = chans_not_covered / chanfree[1] # 1898 / 250 = 7.592
|
||||||
correction = ceil(relays_needed)
|
correction = ceil(relays_needed)
|
||||||
debug(
|
if main.config["ChanKeep"]["Provision"]:
|
||||||
(
|
debug(
|
||||||
f"emptyChanAllocate() secondary allocation sum_free:{sum_free} "
|
(
|
||||||
f"chans_not_covered:{chans_not_covered} relays_needed:{relays_needed} "
|
f"emptyChanAllocate() secondary allocation sum_free:{sum_free} "
|
||||||
f"correction:{correction}"
|
f"chans_not_covered:{chans_not_covered} relays_needed:{relays_needed} "
|
||||||
|
f"correction:{correction}"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
debug(
|
||||||
debug(
|
(
|
||||||
(
|
f"emptyChanAllocate() not enough free channels: toalloc:{toalloc} "
|
||||||
f"emptyChanAllocate() not enough free channels: toalloc:{toalloc} "
|
f"free:{chanfree[0]} chanlimit:{chanfree[1]} correction:{correction}"
|
||||||
f"free:{chanfree[0]} chanlimit:{chanfree[1]} correction:{correction}"
|
)
|
||||||
)
|
)
|
||||||
)
|
warn("Ran out of channel spaces, provisioning additional %i relays for %s" % (correction, net))
|
||||||
warn("Ran out of channel spaces, provisioning additional %i relays for %s" % (correction, net))
|
modules.provision.provisionMultipleRelays(net, correction)
|
||||||
modules.provision.provisionMultipleRelays(net, correction)
|
return False
|
||||||
return False
|
else:
|
||||||
|
# We don't have enough spaces and we can't add any.
|
||||||
|
# Let's do the best we can in the circumstances.
|
||||||
|
debug(f"emptyChanAllocate() cannot create additional relays for {net}")
|
||||||
|
debug(f"emptyChanAllocate() {chans_not_covered} channels cannot be covered")
|
||||||
|
flist = flist[:sum_free]
|
||||||
|
debug(f"emptyChanAllocate() flist truncated to {sum_free}, length nis now {len(flist)}")
|
||||||
|
trace(f"emptyChanAllocate() best effort allocation: {flist}")
|
||||||
for i in chanfree[0].keys():
|
for i in chanfree[0].keys():
|
||||||
for x in range(chanfree[0][i]):
|
for x in range(chanfree[0][i]):
|
||||||
if not len(flist):
|
if not len(flist):
|
||||||
|
|
Loading…
Reference in New Issue