[GH-ISSUE #12093] Add dry_run option to /api/pull endpoint to pre-check feasibility (disk space > model size) #8035

Open
opened 2026-04-12 20:16:48 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @charlesatzzish on GitHub (Aug 26, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12093

Motivation

Currently, when running ollama pull <model> via the API, the daemon begins downloading immediately. If there isn’t enough disk space, the process fails after partially downloading potentially several gigabytes.

This has two major downsides:

  1. Poor user experience: wasted bandwidth, wasted time, and late error messages.
  2. System stability risks: if Ollama fills a disk to 100%, the OS can become unstable. For example:
    • Logs and temporary files can’t be written.
    • Databases or config files risk corruption if writes are interrupted.
    • On macOS, Finder/Dock and other services can hang when free space hits zero.
    • In extreme cases, the computer may freeze or crash and fail to reboot.
    • On macOS, rm may fail to run if no disk space available making it impossible to delete the partial download.

Proposal

Introduce a dry_run (boolean) parameter to the existing /api/pull endpoint:

POST /api/pull
{
  "model": "llama3.2:3b-instruct",
  "dry_run": true
}

Instead of downloading the model, Ollama would:

  1. Look up the model manifest in the registry to compute total required size.
  2. Check free disk space in the models directory (~/.ollama/models or $OLLAMA_MODELS).
  3. Return a JSON response indicating whether the pull could succeed without filling the disk.

Example Responses

If sufficient space:

{
  "can_pull": true,
  "needed_bytes": 8350214144,
  "free_bytes": 21474836480
}

If insufficient space:

{

  "can_pull": false,
  "reason": "not enough disk space",
  "needed_bytes": 8350214144,
  "free_bytes": 4294967296
}

Advantages

  1. Protects system stability: avoids scenarios where a pull fills the entire disk and destabilizes the OS.
  2. Improves UX: fail fast before wasting multi-GB downloads.
  3. Minimal API surface: no new endpoint; just an optional parameter on /api/pull.
  4. Extensible: in future, dry_run could also check other requirements (e.g. network, registry reachability).
  5. Safe: read-only operation, doesn’t expose arbitrary system details.

Alternatives considered

  1. A standalone /api/system/disk endpoint → rejected as too broad in scope.
  2. /api/pull gives an error if there is not enough free disk space before starting download → changes current functionality, may break existing apps.

  3. App implements its own file system checks → not possible with a simple web ui that has no file system access
  4. Doing nothing → leaves users vulnerable to wasted downloads and potential severe and unrecoverable system crashes.

Request for feedback

Would maintainers accept a PR that adds this dry_run option to /api/pull?

I’d be happy to implement it and provide tests/documentation.

Thank you for your kind consideration.

Originally created by @charlesatzzish on GitHub (Aug 26, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12093 ### Motivation Currently, when running `ollama pull <model>` via the API, the daemon begins downloading immediately. If there isn’t enough disk space, the process fails *after* partially downloading potentially several gigabytes. This has two major downsides: 1. **Poor user experience**: wasted bandwidth, wasted time, and late error messages. 2. **System stability risks**: if Ollama fills a disk to 100%, the OS can become unstable. For example: - Logs and temporary files can’t be written. - Databases or config files risk corruption if writes are interrupted. - On macOS, Finder/Dock and other services can hang when free space hits zero. - In extreme cases, the computer may freeze or crash and fail to reboot. - On macOS, rm may fail to run if no disk space available making it impossible to delete the partial download. ### Proposal Introduce a `dry_run` (boolean) parameter to the existing `/api/pull` endpoint: ``` POST /api/pull { "model": "llama3.2:3b-instruct", "dry_run": true } ``` Instead of downloading the model, Ollama would: 1. Look up the model manifest in the registry to compute total required size. 2. Check free disk space in the models directory (~/.ollama/models or $OLLAMA_MODELS). 3. Return a JSON response indicating whether the pull could succeed without filling the disk. Example Responses If sufficient space: ``` { "can_pull": true, "needed_bytes": 8350214144, "free_bytes": 21474836480 } ``` If insufficient space: ``` { "can_pull": false, "reason": "not enough disk space", "needed_bytes": 8350214144, "free_bytes": 4294967296 } ``` ### Advantages 1. Protects system stability: avoids scenarios where a pull fills the entire disk and destabilizes the OS. 2. Improves UX: fail fast before wasting multi-GB downloads. 3. Minimal API surface: no new endpoint; just an optional parameter on /api/pull. 4. Extensible: in future, dry_run could also check other requirements (e.g. network, registry reachability). 5. Safe: read-only operation, doesn’t expose arbitrary system details. ### Alternatives considered 1. A standalone /api/system/disk endpoint → rejected as too broad in scope. 2. /api/pull gives an error if there is not enough free disk space before starting download → changes current functionality, may break existing apps.
 3. App implements its own file system checks → not possible with a simple web ui that has no file system access 4. Doing nothing → leaves users vulnerable to wasted downloads and potential severe and unrecoverable system crashes. ### Request for feedback Would maintainers accept a PR that adds this dry_run option to /api/pull? I’d be happy to implement it and provide tests/documentation. Thank you for your kind consideration.
GiteaMirror added the feature request label 2026-04-12 20:16:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#8035