Expose two backend capabilities MCP previously omitted: - scheduler_checkpoint: control action "checkpoint" (CRIU) - scheduler_restart: POST /xce/v1/jobs/:id/restart (re-queues as a new job, resuming from the last checkpoint if one exists; returns new jobid) schedulerclient gains CheckpointJob/RestartJob (RestartJobResult, JobRestartRequest); Client interface updated. Both tools marked destructive (confirm required). tools/list now reports 17 tools. Unit tests added/updated in both modules — all pass. Backend endpoints are existing apiserver routes; no backend changes in this commit. Also syncs left_scheduler_work.md §八.4 (checkpoint/restart done; the only remaining MCP tool gap is scheduler_modify, blocked on a controller job-field-update opcode that does not exist yet). Co-Authored-By: Claude Code <noreply@anthropic.com>
68 lines
2.6 KiB
Go
68 lines
2.6 KiB
Go
package schedulerclient
|
|
|
|
import "context"
|
|
|
|
// ── Client interface ────────────────────────────────────────────────────────
|
|
|
|
// Client provides read and write access to the scheduler cluster through a
|
|
// scheduler-agnostic unified resource model (URM).
|
|
//
|
|
// Implementations talk to the apiserver's REST API and authenticate via
|
|
// either a Bearer JWT token or an XCE API Key (xce_ak_ prefix).
|
|
type Client interface {
|
|
// ── Jobs ──
|
|
|
|
// ListJobs returns jobs matching the given filter.
|
|
// An empty filter returns all visible jobs.
|
|
ListJobs(ctx context.Context, filter JobFilter) ([]*URMJob, *Page, error)
|
|
|
|
// GetJob returns a single job by its ID.
|
|
GetJob(ctx context.Context, id string) (*URMJob, error)
|
|
|
|
// GetJobLogs retrieves output logs for a job.
|
|
GetJobLogs(ctx context.Context, id string, opts LogOpts) ([]string, error)
|
|
|
|
// ── Queues ──
|
|
|
|
// ListQueues returns all visible queues with their current state.
|
|
ListQueues(ctx context.Context) ([]*URMQueue, error)
|
|
|
|
// ── Nodes ──
|
|
|
|
// ListNodes returns all visible compute nodes with resource usage.
|
|
ListNodes(ctx context.Context) ([]*URMNode, error)
|
|
|
|
// ── Metrics ──
|
|
|
|
// GetClusterMetrics returns a snapshot of overall cluster resource usage.
|
|
GetClusterMetrics(ctx context.Context) (*Metrics, error)
|
|
|
|
// ── Write operations (Phase 1) ──
|
|
|
|
// SubmitJob submits a job and returns its assigned ID.
|
|
SubmitJob(ctx context.Context, spec JobSpec) (*SubmitJobResult, error)
|
|
|
|
// CancelJob kills a job (action "kill", default SIGTERM).
|
|
CancelJob(ctx context.Context, id string) error
|
|
|
|
// HoldJob suspends a job (action "stop", default SIGTSTP).
|
|
HoldJob(ctx context.Context, id string) error
|
|
|
|
// ReleaseJob resumes a suspended job (action "resume", default SIGCONT).
|
|
ReleaseJob(ctx context.Context, id string) error
|
|
|
|
// CheckpointJob checkpoints a running job (action "checkpoint", CRIU).
|
|
CheckpointJob(ctx context.Context, id string) error
|
|
|
|
// RestartJob re-queues a finished job as a new job (resuming from its last
|
|
// checkpoint when one exists) and returns the new job's identity.
|
|
RestartJob(ctx context.Context, id string) (*RestartJobResult, error)
|
|
|
|
// ── Event stream (Phase 2) ──
|
|
|
|
// WatchJobs subscribes to the live job-event SSE stream and returns a
|
|
// channel of lifecycle events (job.created / job.updated / job.deleted /
|
|
// job.finished). The channel is closed when the context is cancelled or
|
|
// the stream ends. The caller is responsible for cancelling ctx.
|
|
WatchJobs(ctx context.Context) (<-chan JobEvent, error)
|
|
}
|