Repository navigation
ci(dev-daily): the Blacksmith pick and re-run alternate skip a label that started nothing #28480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
288e38a
316c1a6
a56635a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -514,6 +514,66 @@ def blacksmith_stalled(queued: int, waited: float) -> bool: | |||||||||
| return queued > 0 and waited >= BLACKSMITH_STALL_MINUTES | ||||||||||
|
|
||||||||||
|
|
||||||||||
| # blacksmith_dead(): a Blacksmith label that ran nothing and started no job for this long before the | ||||||||||
| # snapshot was made is dead, not just busy. blacksmith-12vcpu-macos-26 started no job from 2026-10-28 | ||||||||||
| # 20:32Z on and again from about 2026-10-29 19:40Z (2026-10-30 18:37Z snapshot: 180 queued, oldest | ||||||||||
| # 1399 min, none running, absent from label_started), while blacksmith-6vcpu-macos-26, stalled by the | ||||||||||
| # queue rule too (77 queued, oldest 552 min), ran 5 and started one at 18:39Z. | ||||||||||
| BLACKSMITH_DEAD_MINUTES = 60 | ||||||||||
| # A snapshot too old for the stall rule still proves a label dead for this long: the label it saw dead | ||||||||||
| # for an hour was not revived by the time a later pick reads it in most cases, and a wrong call only | ||||||||||
| # keeps a job on the label that last showed life. | ||||||||||
| BLACKSMITH_DEAD_EVIDENCE_MINUTES = 6 * 60 | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def blacksmith_dead(snapshot: Mapping[str, Any] | None, label: str, now: Any = None) -> bool: | ||||||||||
| """Whether the queue janitor's snapshot shows `label` dead: nothing running on it, and no runner took a job | ||||||||||
| asking for it in the BLACKSMITH_DEAD_MINUTES before the snapshot was made (its `label_started` map, | ||||||||||
| queue_janitor.label_started(); a label it does not list started nothing among the in-flight runs). | ||||||||||
|
|
||||||||||
| The stall rule alone cannot tell a dead label from a busy one: both have a job waiting past | ||||||||||
| BLACKSMITH_STALL_MINUTES. A snapshot without `label_started` (an older janitor), a truncated one (its listing | ||||||||||
| missed in-flight runs, so it can miss a running job or a start: any `truncated` but false, as | ||||||||||
| pr_runner_pool.snapshot_truncated() reads it), an undated one or one older than BLACKSMITH_DEAD_EVIDENCE_MINUTES | ||||||||||
| by `now` (a datetime; the wall clock when None) proves nothing. A complete listing still carries `unread_runs` | ||||||||||
| (runs whose jobs could not be read, nearly every sweep), which may hide a start too; that is accepted, since a | ||||||||||
| wrong call only sends the job to a label that showed life. An idle healthy label looks dead too: callers | ||||||||||
| prefer a label that shows life and fall back to their own order when none does, so the only cost is not | ||||||||||
| choosing a label with no evidence for it.""" | ||||||||||
| import datetime as dt | ||||||||||
|
|
||||||||||
| if not isinstance(snapshot, Mapping): | ||||||||||
| return False | ||||||||||
| pools, starts = snapshot.get("pools"), snapshot.get("label_started") | ||||||||||
| if not isinstance(pools, Mapping) or not isinstance(starts, Mapping): | ||||||||||
| return False | ||||||||||
| if "truncated" in snapshot and snapshot.get("truncated") is not False: | ||||||||||
| return False | ||||||||||
|
|
||||||||||
| def moment(value: Any) -> dt.datetime | None: | ||||||||||
| try: | ||||||||||
| parsed = dt.datetime.fromisoformat(str(value or "").replace("Z", "+00:00")) | ||||||||||
| except ValueError: | ||||||||||
| return None | ||||||||||
| return parsed if parsed.tzinfo is not None else None | ||||||||||
|
|
||||||||||
| generated = moment(snapshot.get("generated_at")) | ||||||||||
| if generated is None: | ||||||||||
| return False | ||||||||||
| now = now if isinstance(now, dt.datetime) and now.tzinfo is not None else dt.datetime.now(dt.timezone.utc) | ||||||||||
| if (now - generated).total_seconds() / 60 > BLACKSMITH_DEAD_EVIDENCE_MINUTES: | ||||||||||
| return False | ||||||||||
| entry = pools.get(label) | ||||||||||
| try: | ||||||||||
| running = int(entry.get("running", 0)) if isinstance(entry, Mapping) else 0 | ||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||||||||||
| except (TypeError, ValueError): | ||||||||||
| return False | ||||||||||
| if running > 0: | ||||||||||
| return False | ||||||||||
| started = moment(starts.get(label)) | ||||||||||
| return started is None or (generated - started).total_seconds() / 60 >= BLACKSMITH_DEAD_MINUTES | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Treat a missing
With Return Suggested fix
Update the Committable suggestion
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| def stalled(queued: int, running: int, oldest_queued_minutes: int, age: float = 0.0) -> bool: | ||||||||||
| """blacksmith_stalled() on the snapshot, or IDLE_STALL_MINUTES (as the snapshot saw it) with | ||||||||||
| nothing running.""" | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: manaflow-ai/cmux
Length of output: 2686
Script executed:
Repository: manaflow-ai/cmux
Length of output: 23348
Script executed:
Repository: manaflow-ai/cmux
Length of output: 11302
Script executed:
Repository: manaflow-ai/cmux
Length of output: 5695
Keep dead-label evidence past the 45-minute snapshot cutoff.
GitHub.snapshot()returns None for any artifact older thanMAX_SNAPSHOT_MINUTES(45). This line's evidence read therefore never sees a snapshot that is 45 to 360 minutes old. With a 6vcpu first pick, a snapshot that is 50 minutes old and shows the 12vcpu label dead is discarded, andalternateoffers that label on re-run. Give this evidence read its own six-hour limit, and correct the comment at line 236.