oliver-zehentleitner / maity

runner: one file-lock helper for tools and serve; serve takes serve.lock before building the service

Sign in to report

tsk-zn4bnfwgpst3 Open

Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: duplication / design.

What is wrong

  • Two flock helpers: tools.locked (cli/src/maity/runner/tools.py:119-140, context manager, wait option, raises Busy, Windows no-op branch) and serve.hold_lock (cli/src/maity/runner/serve.py:306-318, returns a handle, raises Fatal, imports fcntl with no Windows guard). No other fcntl user in the runner.
  • serve() calls open_service (serve.py:406) before hold_lock (serve.py:407): a second serve, or one started while maity runner stop-all holds serve.lock (operate.py:156), first probes every harness, connects to every ssh target and builds Supervisor and Keeper, and only then is refused.

Proposal

  • One exclusive(path, *, wait) helper used by both modules.
  • In serve(), take the lock right after config.load, before open_service.

Effort / risk: S. Low.