Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
772a115
Share SSH monitoring connections and persist host retry backoff
sox8502 Oct 22, 2026
ee67264
Fix explicit reconnect, growing logs, and long SSH setup
sox8502 Oct 22, 2026
97df5cd
Require idle SSH monitors before dev-slot data cleanup
sox8502 Oct 22, 2026
d2ee43a
Merge remote-tracking branch 'origin/main' into daniel/or-558-shared-ssh
sox8502 Oct 22, 2026
39cb2e4
Show SSH connection and run monitoring diagnostics
sox8502 Oct 22, 2026
aca6872
Preserve quoted SSH known-hosts filename lists
sox8502 Oct 22, 2026
b06a279
Merge remote-tracking branch 'origin/main' into daniel/or-558-shared-ssh
sox8502 Oct 22, 2026
6d046a0
Merge remote-tracking branch 'origin/main' into daniel/or-558-shared-ssh
sox8502 Oct 22, 2026
18157f6
Include shared SSH log files in run artifact cleanup
sox8502 Oct 22, 2026
575f8fa
Support Python 3.6 remote SSH helpers
sox8502 Oct 22, 2026
74d4901
Merge remote-tracking branch 'origin/main' into daniel/or-558-shared-ssh
sox8502 Oct 22, 2026
cc13526
Finish Slurm runs despite unavailable logs
sox8502 Oct 22, 2026
55af17d
Validate SSH log chunks during concurrent rewrites
sox8502 Oct 22, 2026
778114b
Merge origin/main and preserve shared SSH monitoring compatibility
sox8502 Oct 23, 2026
6025952
Detect full-prefix log rewrites and isolate legacy SSH monitors
sox8502 Oct 23, 2026
1e6c37d
Preserve whitespace in interactive SSH credentials
sox8502 Oct 23, 2026
21906b7
Reuse verified log digests and ignore unrelated obsolete SSH routes
sox8502 Oct 23, 2026
ca8fb01
Merge latest main and rebuild the reviewed dashboard
sox8502 Oct 23, 2026
99e8a39
Keep pinned SSH connections stable across unrelated config edits
sox8502 Oct 23, 2026
5cfb903
Merge current main and migrate saved SSH connection bindings
sox8502 Oct 23, 2026
cde56e5
Merge current main and isolate Slurm status read failures
sox8502 Oct 23, 2026
13b0bdf
Merge current main and close SSH retry and Slurm completion gaps
sox8502 Oct 23, 2026
6bee71f
Stream large SSH command input through bounded upload frames
sox8502 Oct 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Validate SSH log chunks during concurrent rewrites
  • Loading branch information
sox8502 committed Oct 22, 2026
commit 55af17d64576d75975d864d47dd7858ec8c84ec5
52 changes: 52 additions & 0 deletions scripts/test_ssh_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,58 @@ def test_setup_and_upload_are_not_limited_by_monitoring_deadline(self):
self.assertEqual(len(execute.call_args[0]), 2)


class LogReadRaceTest(unittest.TestCase):
def test_rewrite_during_collection_is_retried_but_append_is_allowed(self):
spec = importlib.util.spec_from_file_location("ssh_helper", HELPER)
helper = importlib.util.module_from_spec(spec)
with patch.object(sys, "dont_write_bytecode", True):
spec.loader.exec_module(helper)
with tempfile.TemporaryDirectory() as home:
path = Path(home) / "log"
original = b"a" * helper.CHUNK
replacement = b"b" * (helper.CHUNK * 2)
real_open = open

class ChangingFile:
def __init__(self, file, change):
self.file = file
self.change = change

def __enter__(self):
return self

def __exit__(self, *args):
self.file.close()

def __getattr__(self, name):
return getattr(self.file, name)

def read(self, size):
data = self.file.read(size)
if self.change:
change, self.change = self.change, None
with real_open(path, change) as writer:
writer.write(replacement)
return data

with patch.dict(os.environ, {"HOME": home}):
for mode in ("wb", "ab"):
with self.subTest(mode=mode):
path.write_bytes(original)
with patch.object(helper, "open", side_effect=lambda *args, **kwargs:
ChangingFile(real_open(*args, **kwargs), mode), create=True):
if mode == "wb":
with self.assertRaisesRegex(RuntimeError, "changed during collection"):
helper.log_chunk({"dir": ""})
else:
chunk = helper.log_chunk({"dir": ""})
self.assertEqual(base64.b64decode(chunk["data"]), original)
self.assertFalse(chunk["eof"])
retry = helper.log_chunk({"dir": ""})
expected = replacement if mode == "wb" else original
self.assertEqual(base64.b64decode(retry["data"]), expected[:helper.CHUNK])


class HelperTest(unittest.TestCase):
def setUp(self):
self.home = tempfile.TemporaryDirectory()
Expand Down
16 changes: 11 additions & 5 deletions src/jobs/ssh/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,32 @@ def execute(command, source=None, timeout=None):
def log_chunk(request):
path = os.path.join(os.path.expanduser("~"), request["dir"], "log")
try:
file = open(path, "rb")
file = open(path, "rb", buffering=0)
except FileNotFoundError:
return {"missing": True}
with file:
stat = os.fstat(file.fileno())
identity = "%s:%s" % (stat.st_dev, stat.st_ino)
offset = request.get("offset", 0)
reset = request.get("identity") != identity or stat.st_size < offset
prefix = b""
if not reset and offset:
file.seek(max(0, offset - 64))
reset = hashlib.sha256(file.read(min(64, offset))).hexdigest() != request.get("boundary")
prefix = file.read(min(64, offset))
reset = hashlib.sha256(prefix).hexdigest() != request.get("boundary")
if reset:
offset = 0
prefix = b""
file.seek(offset)
data = file.read(CHUNK)
end = offset + len(data)
file.seek(max(0, end - 64))
boundary = hashlib.sha256(file.read(min(64, end))).hexdigest()
collected = prefix + data
file.seek(offset - len(prefix))
if file.read(len(collected)) != collected:
raise RuntimeError("Remote log changed during collection; retrying.")
boundary = hashlib.sha256(collected[-64:]).hexdigest()
return {"identity": identity, "reset": reset, "offset": offset,
"data": encode(data), "boundary": boundary, "size": stat.st_size, "eof": end >= stat.st_size}
"data": encode(data), "boundary": boundary, "size": stat.st_size, "eof": end >= os.fstat(file.fileno()).st_size}


def slurm_status(jobs):
Expand Down
Loading