fix(reliability): recreate missing pineapd section; honest uci-set reporting
This commit is contained in:
@@ -31,8 +31,24 @@ def _pool_size():
|
||||
return len(out.split())
|
||||
|
||||
|
||||
def _ensure_pineapd_section():
|
||||
"""Stock daemon rewrites and profile restores can drop the whole
|
||||
`config pineapd` section; every @pineapd[0] option write fails with
|
||||
'Invalid argument' until it exists again."""
|
||||
rc, out, err = device_run(['uci', '-q', 'get',
|
||||
'pineapd.@pineapd[0].logrecon'])
|
||||
if rc == 0:
|
||||
return False
|
||||
device_run(['uci', 'add', 'pineapd', 'pineapd'])
|
||||
device_run(['uci', 'commit', 'pineapd'])
|
||||
return True
|
||||
|
||||
|
||||
def reconcile(clear_pool=True):
|
||||
changed = _apply_uci_wanted(_wanted())
|
||||
changed = []
|
||||
if _ensure_pineapd_section():
|
||||
changed.append('pineapd.@pineapd[0] (section recreated)')
|
||||
changed += _apply_uci_wanted(_wanted())
|
||||
pool_cleared = False
|
||||
if clear_pool and _pool_size() > POOL_CLEAR_MAX:
|
||||
device_run(['uci', 'delete', 'pineapd.@ssidpool[0].ssid'])
|
||||
@@ -51,6 +67,7 @@ def guard_report():
|
||||
if cached is not None and now - _GR_CACHE['t'] < GR_TTL_SECONDS:
|
||||
return cached
|
||||
from server import _pending_uci
|
||||
_ensure_pineapd_section()
|
||||
pending = _pending_uci(_wanted())
|
||||
report = {'in_sync': not pending, 'pending': pending,
|
||||
'pool_size': _pool_size()}
|
||||
|
||||
Reference in New Issue
Block a user