Keep OPNsense telemetry when the script worker cannot start and build it for FreeBSD 14.1
A worker linked on the FreeBSD 15 test guest needs FBSD_1.9 and does not load on OPNsense 24.7; the agent then retried the job session every 30 s and never sent a heartbeat or inventory. The agent now pauses script capabilities for an hour and reconnects without them. tools/dev_opnsense_worker.py links the worker against the official FreeBSD 14.1 pkgbase libraries. The installer checks that the worker loads before binding it and reports success only after a heartbeat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,9 +20,13 @@ STATE = Path('/var/db/discovery-agent')
|
||||
CA = '/usr/local/etc/discovery-agent/ca.pem'
|
||||
HOST = 'discovery.ease-technologies.de'
|
||||
MEDIA = 'application/x-protobuf'
|
||||
VERSION = '0.1.0-opnsense.6'
|
||||
VERSION = '0.1.0-opnsense.7'
|
||||
WORKER = Path('/usr/local/libexec/discovery-agent/rmm-opnsense-jobs')
|
||||
BINDING = Path('/usr/local/etc/discovery-agent/job-binding.json')
|
||||
# A worker that cannot start (e.g. built for a newer FreeBSD) must not stop
|
||||
# heartbeat and inventory. Script capabilities pause until this moment.
|
||||
WORKER_RETRY = 3600
|
||||
worker_paused_until = 0.0
|
||||
|
||||
|
||||
def post(ctx, path, data, media):
|
||||
@@ -177,11 +181,12 @@ def session(db, identity, boot, instance):
|
||||
|
||||
|
||||
def run_channel(db, identity, boot, instance, stack):
|
||||
global worker_paused_until
|
||||
ctx = context()
|
||||
ctx.load_cert_chain(STATE/'device.pem', STATE/'device.key')
|
||||
generation = 0
|
||||
jobs = None
|
||||
enabled = BINDING.is_file() and WORKER.is_file()
|
||||
enabled = BINDING.is_file() and WORKER.is_file() and time.monotonic() >= worker_paused_until
|
||||
|
||||
def send(kind, payload, captured=None):
|
||||
# A lost inventory ACK replays the exact durable envelope, including its
|
||||
@@ -249,8 +254,13 @@ def run_channel(db, identity, boot, instance, stack):
|
||||
p.stdout.close()
|
||||
stack.callback(close)
|
||||
jobs = Jobs(p)
|
||||
if jobs.read()!=b'ready':
|
||||
raise ValueError('job worker unavailable')
|
||||
try:
|
||||
ready = jobs.read()==b'ready'
|
||||
except ValueError:
|
||||
ready = False
|
||||
if not ready:
|
||||
worker_paused_until = time.monotonic()+WORKER_RETRY
|
||||
raise ValueError('job worker unavailable; scripts paused, telemetry continues')
|
||||
last = None
|
||||
previous = None
|
||||
check_cert = time.monotonic()+12*3600
|
||||
|
||||
Reference in New Issue
Block a user