oliver-zehentleitner / maity

runner: one 'this placement gets a test cluster' predicate for the supervisor's two checks and adapters.pg_launch

Sign in to report

tsk-rk8jmkbyy04t Proposed

Audit round 4 (tsk-hgnbapyw7hnh), read at 0a1b832e. Kind: duplication (a rule written three times).

What is wrong

  • Whether a placement gets the test cluster (#2032) is decided in three places with slightly different terms:
  • runner/supervisor.py:1264-1269 (the log line): scratch is not None and not workspace.scratch_in_tmp(harness.id) and adapters.gets_test_cluster(harness.id) and adapters.pg_dir(scratch) is None.
  • runner/supervisor.py:1430-1433 (draw the password file): holder is not None and scratch is not None and not workspace.scratch_in_tmp(harness.id) and adapters.gets_test_cluster(harness.id) and target.as_user.here and adapters.pg_dir(scratch) is not None (here is already implied by holder, see 1422).
  • runner/adapters.py:325-341 (pg_launch): beside and gets_test_cluster(...), pg_dir(...), ctx.pg_pass, ctx.as_user.here.
  • 'scratch beside the clone' is itself written two ways: adapters.py:356 (ctx.harness.id not in TMP_SCRATCH_HARNESSES) vs workspace.scratch_in_tmp (workspace.py:147-150) used by the supervisor.

Proposal

  • One function in adapters, e.g. test_cluster_dir(harness_id, scratch, here) -> Path | None, that holds the harness, tmp-scratch, socket-length and host conditions; the supervisor's two checks and pg_launch call it (pg_launch then only adds ctx.pg_pass). adapters.launch uses workspace.scratch_in_tmp.

Effort / risk: S. Low-medium: the security review of #2032 rests on the conditions; test_adapters and test_supervisor pin each case.