feat(reliability): risky-op preflight snapshots + detached rollback watchdog
This commit is contained in:
@@ -3526,6 +3526,8 @@ def _apply_radio1_ap(openap, wpa):
|
||||
|
||||
|
||||
def h_pineap_wifi_set_ap(ctx):
|
||||
import mk8_gate
|
||||
mk8_gate.enter('ap_change')
|
||||
body = ctx.body or {}
|
||||
wpa = body.get('wpa') or {}
|
||||
openap = body.get('open') or {}
|
||||
@@ -4350,6 +4352,8 @@ def _enterprise_boot_recover():
|
||||
|
||||
|
||||
def h_attacks_deploy(ctx):
|
||||
import mk8_gate
|
||||
mk8_gate.enter('attack_deploy')
|
||||
body = ctx.body or {}
|
||||
kind = (body.get('kind') or '').strip().lower()
|
||||
if kind not in ('wpa', 'open', 'enterprise'):
|
||||
@@ -4439,6 +4443,8 @@ def _radio1_ap_active():
|
||||
|
||||
|
||||
def h_attacks_stop(ctx):
|
||||
import mk8_gate
|
||||
mk8_gate.enter('attack_stop')
|
||||
kind = ((ctx.body or {}).get('kind') or '')
|
||||
stopped = []
|
||||
if kind in ('wpa', 'open'):
|
||||
@@ -4890,6 +4896,8 @@ def _disable_sta_uplink():
|
||||
keeps it off across reboots/wifi reloads; taking wlan0 down immediately
|
||||
frees phy0's channel for wlan0mon. Never runs `wifi reload` here — that
|
||||
tears down live APs and drops the monitors mid-assessment."""
|
||||
import mk8_gate
|
||||
mk8_gate.enter('uplink_disable')
|
||||
device_run(['uci', 'set', 'wireless.dummy_radio0.disabled=1'])
|
||||
device_run(['uci', 'commit', 'wireless'])
|
||||
for iface in ('wlan0',):
|
||||
@@ -7189,6 +7197,8 @@ ROUTER.add('POST', r'/api/mode/release', h_mode_release)
|
||||
|
||||
|
||||
def serve():
|
||||
import mk8_gate
|
||||
mk8_gate.ENABLED = True
|
||||
LIVE_STOP.clear()
|
||||
HEALTH_STOP.clear()
|
||||
_recon_hopper_stop.set()
|
||||
@@ -7255,6 +7265,26 @@ if __name__ == '__main__':
|
||||
except Exception as exc: # boot must never fail here
|
||||
print(json.dumps({'error': str(exc)}))
|
||||
sys.exit(0)
|
||||
if '--rollback-snapshot' in sys.argv:
|
||||
import mk8_gate
|
||||
mk8_gate.ENABLED = True
|
||||
name = sys.argv[sys.argv.index('--rollback-snapshot') + 1]
|
||||
import mk8_profiles
|
||||
result = mk8_profiles.restore(name)
|
||||
device_run(['wifi', 'reload'], timeout=90)
|
||||
import mk8_events
|
||||
mk8_events.log_event('rollback', sev='warn',
|
||||
msg='watchdog restored %s' % name,
|
||||
meta=result)
|
||||
print(json.dumps(result))
|
||||
sys.exit(0)
|
||||
if '--promote-snapshot' in sys.argv:
|
||||
import mk8_gate
|
||||
mk8_gate.ENABLED = True
|
||||
name = sys.argv[sys.argv.index('--promote-snapshot') + 1]
|
||||
import mk8_profiles
|
||||
print(json.dumps({'promoted': mk8_profiles.promote_lastknown_good()}))
|
||||
sys.exit(0)
|
||||
signal.signal(signal.SIGTERM, _request_shutdown)
|
||||
signal.signal(signal.SIGINT, _request_shutdown)
|
||||
serve()
|
||||
|
||||
Reference in New Issue
Block a user