UnloadRemoteModel finds the node(s) hosting the given model and tells them to stop their backend process via NATS backend.stop event. The worker process handles: Free() → kill process. This is called by ModelLoader.deleteProcess() when process == nil (remote model).
(modelName string)
| 81 | // The worker process handles: Free() → kill process. |
| 82 | // This is called by ModelLoader.deleteProcess() when process == nil (remote model). |
| 83 | func (a *RemoteUnloaderAdapter) UnloadRemoteModel(modelName string) error { |
| 84 | ctx := context.Background() |
| 85 | nodes, err := a.registry.FindNodesWithModel(ctx, modelName) |
| 86 | if err != nil || len(nodes) == 0 { |
| 87 | xlog.Debug("No remote nodes found with model", "model", modelName) |
| 88 | return nil |
| 89 | } |
| 90 | |
| 91 | for _, node := range nodes { |
| 92 | xlog.Info("Sending NATS backend.stop to node", "model", modelName, "node", node.Name, "nodeID", node.ID) |
| 93 | if err := a.StopBackend(node.ID, modelName); err != nil { |
| 94 | xlog.Warn("Failed to send backend.stop", "node", node.Name, "error", err) |
| 95 | continue |
| 96 | } |
| 97 | // Remove every replica of this model on the node — the worker will |
| 98 | // handle the actual process cleanup. |
| 99 | a.registry.RemoveAllNodeModelReplicas(ctx, node.ID, modelName) |
| 100 | } |
| 101 | |
| 102 | return nil |
| 103 | } |
| 104 | |
| 105 | // InstallBackend sends a backend.install request-reply to a worker node. |
| 106 | // Idempotent on the worker: if the (modelID, replica) process is already |
nothing calls this directly
no test coverage detected