noqt commited on
Commit
ad8aaed
·
1 Parent(s): 67d7250

Harden startup readiness and bounded tree capture

Browse files
Files changed (1) hide show
  1. scripts/install.py +8 -2
scripts/install.py CHANGED
@@ -206,12 +206,18 @@ def main() -> int:
206
  started = run(["/usr/bin/systemctl", "enable", "--now", "lumi-eggcracker.service"])
207
  if checked.returncode or started.returncode or started_watchdog.returncode:
208
  raise RuntimeError((checked.stderr + started.stderr + started_watchdog.stderr).strip() or "cannot start supervisor")
209
- deadline = time.monotonic() + 15
 
 
 
 
210
  while time.monotonic() < deadline and not all(path.exists() for path in (QUERY_SOCKET, OPERATOR_SOCKET, ADMIN_SOCKET, HEARTBEAT_SOCKET)):
211
  time.sleep(0.02)
212
  for path, mode, gid in ((QUERY_SOCKET, 0o660, operator.pw_gid), (OPERATOR_SOCKET, 0o660, operator.pw_gid), (ADMIN_SOCKET, 0o600, 0), (HEARTBEAT_SOCKET, 0o600, 0)):
 
 
213
  metadata = path.stat()
214
- if not path.exists() or stat.S_IMODE(metadata.st_mode) != mode or metadata.st_uid != 0 or metadata.st_gid != gid:
215
  raise RuntimeError("socket ownership contract failed")
216
  print(json.dumps({"result": "INSTALLED", "service": "lumi-eggcracker.service", "workload_uid": account.pw_uid}, sort_keys=True))
217
  return 0
 
206
  started = run(["/usr/bin/systemctl", "enable", "--now", "lumi-eggcracker.service"])
207
  if checked.returncode or started.returncode or started_watchdog.returncode:
208
  raise RuntimeError((checked.stderr + started.stderr + started_watchdog.stderr).strip() or "cannot start supervisor")
209
+ # A cold bounded discovery scan may take several seconds on a loaded
210
+ # qualification host. Wait long enough for the supervisor to complete
211
+ # that startup scan, while still failing before an operator mistakes a
212
+ # non-starting installation for a ready one.
213
+ deadline = time.monotonic() + 45
214
  while time.monotonic() < deadline and not all(path.exists() for path in (QUERY_SOCKET, OPERATOR_SOCKET, ADMIN_SOCKET, HEARTBEAT_SOCKET)):
215
  time.sleep(0.02)
216
  for path, mode, gid in ((QUERY_SOCKET, 0o660, operator.pw_gid), (OPERATOR_SOCKET, 0o660, operator.pw_gid), (ADMIN_SOCKET, 0o600, 0), (HEARTBEAT_SOCKET, 0o600, 0)):
217
+ if not path.exists() or path.is_symlink():
218
+ raise RuntimeError(f"required Eggcracker socket was not created: {path}")
219
  metadata = path.stat()
220
+ if stat.S_IMODE(metadata.st_mode) != mode or metadata.st_uid != 0 or metadata.st_gid != gid:
221
  raise RuntimeError("socket ownership contract failed")
222
  print(json.dumps({"result": "INSTALLED", "service": "lumi-eggcracker.service", "workload_uid": account.pw_uid}, sort_keys=True))
223
  return 0