mirror of
https://github.com/Av0idD4rk/firegex.git
synced 2026-10-23 16:31:00 +00:00
Write pending block counters before an export
A backup taken within a second of a block missed it. The backup test also snapshotted while NFQUEUE blocks were still being reported, which failed the 5.0.0 release run; it now waits until two reads agree.
This commit is contained in:
parent
79a2e1aacb
commit
8df2512744
@ -421,6 +421,9 @@ async def reset_firegex(form: ResetRequest):
|
|||||||
@api.get('/export')
|
@api.get('/export')
|
||||||
async def export_db():
|
async def export_db():
|
||||||
"""Export all configuration databases as JSON"""
|
"""Export all configuration databases as JSON"""
|
||||||
|
# Block counters are written once a second; without this a backup misses the last ones.
|
||||||
|
from routers.services import firewall
|
||||||
|
firewall.flush_blocks()
|
||||||
dbs = {}
|
dbs = {}
|
||||||
if not os.path.exists('db'):
|
if not os.path.exists('db'):
|
||||||
return dbs
|
return dbs
|
||||||
|
|||||||
@ -130,8 +130,15 @@ def test_a_deleted_service_comes_back_whole_and_filtering(api, protected, filter
|
|||||||
_filters_as_configured(channel)
|
_filters_as_configured(channel)
|
||||||
|
|
||||||
# Read through the services API first, which writes the counters still waiting: what
|
# Read through the services API first, which writes the counters still waiting: what
|
||||||
# is compared afterwards includes them.
|
# is compared afterwards includes them. Until two reads agree, because on NFQUEUE a
|
||||||
|
# block reaches the backend after the client has already seen the refusal — one
|
||||||
|
# counted between this snapshot and the export failed the 5.0.0 release run.
|
||||||
before = _snapshot(api, service_id)
|
before = _snapshot(api, service_id)
|
||||||
|
for _ in range(10):
|
||||||
|
time.sleep(SETTLE)
|
||||||
|
before, settled = _snapshot(api, service_id), before
|
||||||
|
if before == settled:
|
||||||
|
break
|
||||||
backup = api.export_backup()
|
backup = api.export_backup()
|
||||||
|
|
||||||
assert api.services_delete(service_id)
|
assert api.services_delete(service_id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user