[PR #7050] [MERGED] Stop model before deletion if loaded (fixed #6957) #12293

Closed
opened 2026-04-12 23:54:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7050
Author: @alexmavr
Created: 9/30/2024
Status: Merged
Merged: 10/1/2024
Merged by: @pdevine

Base: mainHead: issue-6957


📝 Commits (3)

  • f9ef5aa stop model before deletion if loaded
  • 6c83260 Added tests for model stop during deletion
  • bd981cc Remove use of testify on routes_test

📊 Changes

4 files changed (+310 additions, -58 deletions)

View changed files

📝 cmd/cmd.go (+11 -0)
📝 cmd/cmd_test.go (+66 -0)
📝 server/routes.go (+6 -1)
📝 server/routes_test.go (+227 -57)

📄 Description

This PR adds the same logic as StopHandler before model removal. If the model is not loaded, no error is raised.

I also added a few tests on the server DeleteHandler, and fixed an error formatting bug where ollama rm would return a "file not found" error for the manifest file instead of a proper error message if the model does not exist

Fixes #6957

Tested with:

$ ./ollama run localhost/phi/phi:latest
$ ./ollama ps
NAME                        ID              SIZE      PROCESSOR    UNTIL
localhost/phi/phi:latest    e2fd6321a5fe    5.5 GB    100% GPU     4 minutes from now
$ ./ollama rm localhost/phi/phi:latest
deleted 'localhost/phi/phi:latest'
$ ./ollama ps
NAME    ID    SIZE    PROCESSOR    UNTIL

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/7050 **Author:** [@alexmavr](https://github.com/alexmavr) **Created:** 9/30/2024 **Status:** ✅ Merged **Merged:** 10/1/2024 **Merged by:** [@pdevine](https://github.com/pdevine) **Base:** `main` ← **Head:** `issue-6957` --- ### 📝 Commits (3) - [`f9ef5aa`](https://github.com/ollama/ollama/commit/f9ef5aabac714dbb6ff335018e1816e9829a40db) stop model before deletion if loaded - [`6c83260`](https://github.com/ollama/ollama/commit/6c832606fdf2f7359bf2a7b0fe23a4245d901c4e) Added tests for model stop during deletion - [`bd981cc`](https://github.com/ollama/ollama/commit/bd981cc2a5e30f3b15ce6fc35e89c7657f6190a3) Remove use of testify on routes_test ### 📊 Changes **4 files changed** (+310 additions, -58 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+11 -0) 📝 `cmd/cmd_test.go` (+66 -0) 📝 `server/routes.go` (+6 -1) 📝 `server/routes_test.go` (+227 -57) </details> ### 📄 Description This PR adds the same logic as `StopHandler` before model removal. If the model is not loaded, no error is raised. I also added a few tests on the server DeleteHandler, and fixed an error formatting bug where `ollama rm` would return a "file not found" error for the manifest file instead of a proper error message if the model does not exist Fixes #6957 Tested with: ``` $ ./ollama run localhost/phi/phi:latest $ ./ollama ps NAME ID SIZE PROCESSOR UNTIL localhost/phi/phi:latest e2fd6321a5fe 5.5 GB 100% GPU 4 minutes from now $ ./ollama rm localhost/phi/phi:latest deleted 'localhost/phi/phi:latest' $ ./ollama ps NAME ID SIZE PROCESSOR UNTIL ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-12 23:54:30 -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#12293