Skip to content

[Core] Prioritize real downloads over validation replay#662

Open
op109lvb wants to merge 3 commits into
mainfrom
prioritize-download
Open

[Core] Prioritize real downloads over validation replay#662
op109lvb wants to merge 3 commits into
mainfrom
prioritize-download

Conversation

@op109lvb

Copy link
Copy Markdown
Collaborator

What this PR does

Splits model-agent normal work into separate download and validation-only FIFO lanes, then places already-Ready OCI models with existing local artifacts behind real download work.

It also snapshots models that were already Ready on this node before reconciliation marks restart replay tasks as Updating, and adds tests for queue ordering, delete superseding, startup classification, and demotion behavior.

Why we need it

After model-agent restart, many already-downloaded models can be replayed as download tasks just to revalidate local artifacts. Those validation-heavy tasks can block real downloads for new models.

This change keeps real downloads ahead of validation replay without moving real download work onto the high-priority worker.

Fixes #

How to test

  • go test -count=1 ./pkg/modelagent
  • E2E tests

Checklist

  • Tests added/updated (if applicable)
  • Docs updated (if applicable)
  • make test passes locally

@github-actions github-actions Bot added model-agent Model agent changes tests Test changes labels Jul 11, 2026
Comment thread pkg/modelagent/gopher.go Outdated
Comment thread pkg/modelagent/gopher_test.go Outdated
@op109lvb
op109lvb force-pushed the prioritize-download branch from c1539b0 to 6d93431 Compare July 14, 2026 18:01
Comment thread pkg/modelagent/gopher.go Outdated
}

func (s *Gopher) Run(stopCh <-chan struct{}, numWorker int, numHighPriorityWorker int) {
s.captureStartupReadyModels(context.Background())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

captureStartupReadyModels(context.Background()) does a live ConfigMaps().Get() as the first statement of Run() — the reconciler, dispatcher, and every worker wait on it. The failure path already degrades gracefully to an empty snapshot (today's behavior), so a context.WithTimeout is free insurance against a throttled API server stalling startup. Relatedly, on a cold node the ConfigMap doesn't exist yet, so getConfigMap logs at Errorf and this logs Warnf — an alarming pair for a normal first boot. Consider special-casing apierrors.IsNotFound.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed. Startup snapshot now uses a fixed 5s startup-only timeout, and NotFound is treated as a cold start with info level logging instead of warning/error noise.

Comment thread pkg/modelagent/gopher.go Outdated
if task.TaskType == Delete {
s.cancelActiveDownload(task)
}
if s.deferStartupReadyValidationIfLocalPathExists(task) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This classifier is redundant.
For task sits in a normal lane. the funtion markValidationOnlyIfStartupReady() in #201 already classified it on that enqueue. The deferStartupReadyValidationIfLocalPathExists call the same function markValidationOnlyIfStartupReady() and it will return false because task.NormalValidationOnly is true.
For task demote from high lane. markValidationOnlyIfStartupReady in demoteToNormalPriority and markValidationOnlyIfStartupReady() in #201 already classified it during demote's re-enqueue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Startup revalidation is now classified before enqueue, and the queue itself defers RevalidationReplay behind normal downloads, so the worker-side requeue wrapper is no longer needed.
Addressed

Comment thread pkg/modelagent/gopher.go Outdated
Comment thread pkg/modelagent/gopher.go Outdated
Comment thread pkg/modelagent/gopher.go Outdated
Comment thread pkg/modelagent/gopher.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model-agent Model agent changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants