Skip to content

enhance status API#879

Closed
morgo wants to merge 2 commits into
block:mainfrom
morgo:enhance-status-api
Closed

enhance status API#879
morgo wants to merge 2 commits into
block:mainfrom
morgo:enhance-status-api

Conversation

@morgo

@morgo morgo commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Closes #844.

Summary

Surfaces resume-from-checkpoint outcome and the active throttler on the runner/Progress API so external clients (GUIs, automation) can summarize migration state without scraping logs.

Note: This branch originally also removed --strict mode, but that landed separately in #910. After rebasing onto main, this PR is scoped to the status-API enhancements only.

Runner getters (migration + move)

  • UsedResumeFromCheckpoint() bool
  • ResumeError() error — preserves typed status.Err* values for errors.Is matching

Both fields are guarded by a sync.RWMutex so concurrent reads via the getters cannot race with the setup() goroutine's write.

Throttler interface

Throttler gains a String() string method — empty when not throttled, descriptive when active. Implemented on:

  • Noop → always ""
  • Mock"mock throttler (always throttled)"
  • Replica"replica lag %dms exceeds tolerance %s"
  • CommitLatency"Aurora commit latency %s exceeds threshold %s"
  • ActiveThreads"Aurora active threads %d exceed vCPUs %d"
  • multiThrottler → joins non-empty children with ;

Progress struct

status.Progress gains a Throttler throttler.Throttler field. Guaranteed non-nil — both runners initialize r.throttler to &throttler.Noop{} so callers can dispatch on it without nil checks. Surfacing the throttler itself (rather than cherry-picking fields) means future throttler-specific data is available without amending Progress.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./pkg/throttler/... — green
  • CI to run the full -race suite against MySQL
  • Reviewer to sanity-check that Progress.Throttler (interface value in a returned struct) is acceptable shape for downstream consumers

🤖 Generated with Claude Code

@morgo morgo mentioned this pull request Jun 9, 2026
@morgo

morgo commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

Forking the strict removal to #910 while we experiment more with this.

morgo added a commit that referenced this pull request Jun 9, 2026
Removes the --strict CLI flag and the Migration.Strict field, along with
the strict branch in setup(), the WithStrict() test helper, the four
TestResumeFromCheckpoint*Strict* tests, and the corresponding sections of
docs/migrate.md and resume-from-checkpoint.md.

With --strict gone, a failed resume-from-checkpoint always logs the reason
and falls back to a fresh migration. The typed status.Err* values
(ErrMismatchedAlter, ErrBinlogNotFound, ErrCheckpointTooOld,
ErrCheckpointCollision) are still produced and logged internally; only the
strict consumer of them is removed.

This is a breaking change for anyone passing --strict: Kong will error on
the unknown flag. Per prior discussion the flag was already not-recommended.

Forked out of #879.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@morgo morgo changed the title enhance status API and remove strict mode enhance status API Jun 10, 2026
morgo and others added 2 commits June 9, 2026 19:35
Surfaces resume-from-checkpoint outcome and active throttler on the
runner/Progress API so external clients (GUIs, automation) can summarize
migration state without scraping logs. Closes block#844.

Runner getters (migration + move):
- UsedResumeFromCheckpoint() bool
- ResumeError() error (preserves typed status.Err* values for errors.Is)

Both fields are guarded by a sync.RWMutex so concurrent reads via the
getters cannot race with the setup() goroutine's write.

Throttler interface gains String() string — empty when not throttled,
descriptive when active. Implemented across Noop, Mock, Replica,
CommitLatency, ActiveThreads, multiThrottler (joins children with "; "),
and the test double.

status.Progress gains Throttler throttler.Throttler (never nil; both
runners initialize r.throttler to Noop). Surfacing the throttler itself
avoids needing a Progress-struct mapping when throttler types add new
data later.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The test compares Progress structs as literals; now that Progress.Throttler
is initialized to &throttler.Noop{} on the runner, the literals must include
it too.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

enhance status API

1 participant