Skip to content

feat(ingest): add cancel subcommand - #223

Merged
eddietejeda merged 1 commit into
mainfrom
feat/ingest-cancel
Jul 14, 2026
Merged

eddietejeda merged 1 commit into
mainfrom
feat/ingest-cancel

Conversation

@eddietejeda

Copy link
Copy Markdown
Contributor

Summary

  • Adds hotdata ingest cancel <id> — calls POST /jobs/{id}/cancel on the worker
  • Fixes status --wait / trigger-import --wait to terminate cleanly when a job is cancelled (was spinning forever because cancelled fell through normalize_status to the running branch)
  • cancelled exits with code 1, same as failed

Behaviour

hotdata ingest cancel <id>
# → status: cancelled
# → Drain may still be running — track with: hotdata ingest status <id> --wait

hotdata ingest status <id> --wait
# → polls; prints "cancelled: cancelled by user" and exits 1 once settled

Row-count progress (1,234,567 rows loaded so far — orders: 800k, items: 434k) already surfaces in the --wait spinner via the detail field the worker now populates during loading — no additional CLI change needed.

Test plan

  • hotdata ingest cancel <running-import-id> prints cancelled status and hint
  • hotdata ingest status <id> --wait after cancel exits 1 without spinning
  • hotdata ingest cancel <unknown-id> surfaces the 404 from the worker
  • hotdata ingest status <id> one-shot still exits 2 while cancelled (non-terminal on the server side)

POST /jobs/{id}/cancel marks an import cancelled without requiring a
rerun. The server uses a non-terminal 'cancelled' status to keep the
rerun in-flight guard active while the dltHub drain finishes.

- Add IngestCancelAck struct and cancel() client method
- Add `hotdata ingest cancel <id>` subcommand
- normalize_status: add 'cancelled' arm (was falling through to running)
- status_exit_code / poll_ingest: treat cancelled as terminal (exit 1)
  so `status --wait` terminates cleanly instead of spinning forever
Comment thread src/commands/ingest.rs
render(output, &machine, || {
use crossterm::style::Stylize;
let label = |l: &str| format!("{:<14}", l).dark_grey().to_string();
println!("{}{}", label("status:"), util::color_status(&ack.status));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: util::color_status (src/util.rs) has no arm for cancelled, so it falls through to the yellow "in-flight" color here and in one-shot status. But cancelled is now a terminal state (exit 1) and poll_ingest prints its message in red. Consider adding cancelled to color_status so the status cell doesn't render a settled job in the in-flight color. (not blocking)

Comment thread src/commands/ingest.rs
match normalize_status(status).0 {
"done" => 0,
"failed" => 1,
"failed" | "cancelled" => 1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: the adjacent unit tests (status_exit_codes_close_over_stage_states, statuses_normalize_to_the_closed_set) cover every other status but not the new cancelled branch. Adding assert_eq!(status_exit_code("cancelled"), 1) and assert_eq!(normalize_status("cancelled"), ("cancelled", None)) would lock in this behavior. (not blocking)

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved. Two non-blocking nits left inline.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 6.66667% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/commands/ingest.rs 8.00% 23 Missing ⚠️
src/client/ingest.rs 0.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@eddietejeda
eddietejeda merged commit b0a907b into main Jul 14, 2026
14 checks passed
@eddietejeda
eddietejeda deleted the feat/ingest-cancel branch July 14, 2026 19:42
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.

1 participant