Skip to content

post: report the mount lifecycle to the vm-agent at post time - #78

Open
piob-io wants to merge 4 commits into
mainfrom
devin/1788973104-mount-report
Open

piob-io wants to merge 4 commits into
mainfrom
devin/1788973104-mount-report

Conversation

@piob-io

@piob-io piob-io commented Sep 9, 2026

Copy link
Copy Markdown

Summary

The post step sends one structured report to the vm-agent so the host's per-mount lifecycle record can include what only the guest knows. The host record never depends on it: the report is additive, best-effort, and dropped silently if the agent is old or unreachable.

src/mount-report.ts (new) — same transport as the checkout action's /internal sender:

POST http://$BLACKSMITH_AGENT_ADDR:$BLACKSMITH_METRICS_HTTP_PORT/internal
{ metric_type: "stickydisk_mount_report", value: 1, vm_id, attributes: {}, payload: MountReport }

interface MountReport {
  expose_id, sticky_disk_key: string;
  setup_outcome: "mounted" | "setup_fallback";
  skip_reason: "" | "commit_false" | "early_deny" | "if_missing_existing" | "on_change_unchanged"
             | "prior_step_failure" | "step_check_error" | "setup_error" | "not_mounted" | "post_error";
  was_formatted: boolean;
  format_ms, mount_ms, unmount_ms: number;
}
  • skipped (returns false) when either env var is missing; resolves true only on a 2xx response, any other status is a failed send like a network error; every failure swallowed at core.debug, never surfaced to the job.
  • MOUNT_REPORT_TIMEOUT_MS = 1500. The agent is on the runner's local network, so a healthy round trip is milliseconds, and the post step sits on the customer's critical path: a stalled agent costs at most 1.5s (down from the initial 3s).
  • skip_reason is "" when the commit was requested.

src/post.ts — the report is built up front from state, each existing skip branch tags its skip_reason, and sendMountReport runs in a finally so exactly one report leaves per post run, including the early "not mounted" returns and the catch-all error path.

src/main.ts:

  • STICKYDISK_EXPOSE_ID is saved right after GetStickyDisk returns instead of after mount, so a guest-side format/mount failure still reports against the disk the host exposed (and the post step now sends shouldCommit=false for it rather than skipping the RPC).
  • mkfs/resize2fs and mount+chown durations are timed and saved as STICKYDISK_FORMAT_MS / STICKYDISK_MOUNT_MS.

Receiver side is in FastActions/fa#5523 (joins the report onto the buffered row by expose_id; sticky-disk-key fallback for failed exposes that have no expose id).

Tests (src/__tests__/mount-report.test.ts) cover env parsing, the envelope, a real local HTTP server receiving the POST, a local server answering 500, missing endpoint, refused connection, and a silent server hitting the timeout.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled. (Staging)


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Link to Devin session: https://app.devin.ai/sessions/9ad0c14a6daf4eadb0e5c47ecb6b8931
Open in Devin Desktop: https://app.devin.ai/desktop/session/9ad0c14a6daf4eadb0e5c47ecb6b8931?variant=devin
Requested by: @piob-io

The post step now sends one structured stickydisk_mount_report to the
vm-agent's /internal endpoint (BLACKSMITH_AGENT_ADDR +
BLACKSMITH_METRICS_HTTP_PORT, the channel the checkout action already
uses) with what only the guest knows: whether the disk was mounted or the
step fell back to a plain directory, why a commit was skipped (commit:
false, early deny, if-missing with an existing disk, on-change unchanged,
prior step failure, setup error, not mounted, post error) and the
format/mount/unmount durations. The host joins it into its per-mount
lifecycle row by expose id.

Exactly one report is sent per post run, from a finally block, so every
early return is covered. Sending is best-effort: it is skipped when the
endpoint is not configured, bounded by a 3s timeout, and every error is
swallowed at debug level. The main step saves the expose id as soon as
GetStickyDisk returns so a guest-side format/mount failure still reports
against the exposed disk, and saves the format/mount durations to state.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

sendMountReport resolved on any HTTP response, so a 4xx/5xx from the agent
was logged as a successful report. Non-2xx statuses now reject like a
network error: still swallowed, debug-only, never affecting the job.

The report timeout drops from 3000 ms to 1500 ms. The agent is on the
runner's local network and the post step is on the customer's critical
path, so a stalled agent should cost at most 1.5 s.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@piob-io
piob-io marked this pull request as ready for review September 9, 2026 20:52

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e3681a5. Configure here.

Comment thread src/main.ts
The format decision is known before the mount step runs, so a mount failure
after mkfs must not leave the post report claiming the disk was never
formatted. The if-missing check in post never sees this state on the
failure path: it returns early on setup_error before consulting it.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@piob-io
piob-io requested a review from ajwerner September 9, 2026 21:05
Comment thread src/post.ts Outdated
format_ms, mount_ms and unmount_ms are assigned in finally blocks so a
failed mkfs, mount or exhausted unmount retry still reports the time it
spent instead of zero, which the host row would read as the phase never
having run.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@ajwerner ajwerner left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the follow-up changes; failed-phase timings are preserved in the source and rebuilt action bundles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants