Repository navigation
Description
Problem
Nothing tells a person when the Ollama tier ollama-48gib-fast evicts its model. An eviction loses the KV cache, and a swap cost 55 to 330 s in the measure on this issue.
- feat(k8s): serve qwen3.8:27b alone on the 48 and 64 GiB tiers #3572 makes the tier load
qwen3.8:27band no other model (OLLAMA_MAX_LOADED_MODELS1,OLLAMA_KEEP_ALIVE-1). feat(k8s): implement with deepseek-v4.1-flash-1017 #3581 movesimplementtodeepseek-v4.1-flash-1017. Loki shows 110 eviction lines on the tier in the 24 h before the restart at 2026-11-05T02:43Z, some of them from the test traffic of the measure, and 0 from the restart to 17:10Z. - The tier can still evict.
k8s/llm/profiles/ollama-profiles.yamlstates that a client that calls the tier directly with another model name makes Ollama unloadqwen3.8:27b. - Ollama writes an eviction as a log line, for example
llama-server model predicted to exceed available memory, evicting, in the Loki stream{service_name="ollama-48gib"}. Prometheus has no metric withollamain its name. - No rule and no test names these lines.
k8s/logging/loki-values.yamlhas no ruler setting. The live Loki config holds only the local storage and the WAL directory of the ruler, and noalertmanager_url. The policy ink8s/logging/networkpolicy.yamlallows egress only in the namespace and to DNS, so the ruler has no path to Alertmanager (prometheus-alertmanager, port 9093, namespacemonitoring).k8s/monitoring/networkpolicy.yamladmits nothing fromloggingon that port.
Expected
An alert fires when the tier logs more eviction lines than a threshold in a window. The source of the alert is a Loki ruler rule. The routes, the tiers and the runner Jobs do not change.
Acceptance criteria
- A Loki ruler rule fires when
ollama-48gib-fastlogs more eviction lines than a configured threshold in a window, and the alert reaches Alertmanager. - A test holds an alert on tier evictions over a threshold.
Other criteria
Comment 6662364302 gives the evidence for each.
- Moved to fix(ai): name or refuse a gateway caller without an end-user header #3578: criterion 4, "The client that sends no header names itself or gets a refusal, and
litellm_proxy_total_requests_metric_total{end_user="None"}shows 0 over 24 h." - Holds, with a small gap: the measure comes first. It supports cause 1 and it does not support cause 2. Its table has no timeout stops, and the issue text before this edit and comment 6662364302 give those counts.
- Holds by a different route (feat(k8s): serve qwen3.8:27b alone on the 48 and 64 GiB tiers #3572, feat(k8s): implement with deepseek-v4.1-flash-1017 #3581): implement left the tier, no second chat model loads on it, and
test_the_48gib_and_64gib_tiers_load_qwen_alone_at_its_native_contextfails if one returns. - Does not apply: the test for one runner Job on the tier, because the measure does not support cause 2.
Existing tool considered
The Loki ruler, which reads the log lines that Loki already stores, and the Alertmanager of the monitoring namespace.
promtool, which runs the other rule tests of this repository, cannot run this rule: promtool check rules refuses a LogQL expression with parse error: unexpected character: '|'. The Loki alerting page names lokitool and the Cortex rules action, and it names no rule unit test. So the plan must name how a test evaluates the rule.
Order
The measure that #3064 needs is in comment 6646957139. This item does not hold #3064.
Related
Related: #3567, #3573, #3578, #3064
Proposed design
This section holds the part of the refine round at d72ec470 that stays. #3572 and #3581 made the other parts out of date (comment 6662364302).
Problem statement
The ollama-48gib-fast tier can still evict its model when a client calls the tier directly with another model name, and no alert tells a person. The change adds an eviction alert.
Acceptance criteria
Requirement: Tier eviction alert
A Loki ruler rule SHALL fire when ollama-48gib-fast logs more eviction lines than a configured threshold in a window.
Scenario: Eviction log lines trigger the alert
- WHEN A test feeds the rule a fixture with more eviction lines than the threshold.
- THEN The rule returns a firing alert for
ollama-48gib-fast.
Existing Tool Considered
No alternatives check has run. LiteLLM lacks an Ollama eviction metric. The eviction alert therefore uses a Loki ruler rule. The unnamed caller moved to #3578.
Key questions
- Which source feeds the eviction alert?: Use a Loki ruler rule on the
ollama-48gib-fastlog lines. Ollama has no Prometheus metric for evictions. Loki already holds the log lines. (proposed)- Chosen: Loki ruler rule. The evictions are log lines and Loki already stores them.
- Rejected: Alloy log-to-metric step. It adds a metric pipeline and cardinality for a rare event.
- Rejected: Prometheus metric from Ollama. Ollama emits no Prometheus metric for evictions.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-18: in-use.
The repository already uses this tool.
Tool: grafana/loki (https://github.com/grafana/loki), AGPL-3.0, last activity 2026-11-18, maintained.
Reason: The Loki ruler evaluates LogQL alert rules on stored log lines and can send to Alertmanager, so the alert itself is covered; no maintained LogQL rule unit-test tool exists, and promtool cannot parse the pipe, so the test criterion is not.
Covers:
- Evaluates LogQL alert rules against stored log lines
- Counts matching eviction lines in a time window
- Forwards firing alerts to Alertmanager when configured
Lacks:
- No LogQL rule unit-test harness; promtool rejects pipe syntax
- No maintained CLI to validate or unit-test LogQL rules
- Ruler and Alertmanager egress must be configured by hand
Activity
dan-petty commentedon Nov 4, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(k8s)scope of the title gives the scope.Production implement Jobs take 2 to 3 h with 161 evictions and 21 load failures on the coder tier.Directly reduces implement Job runtime and removes timeout stops.The measure must change one candidate cause at a time before the route or runner fix is chosen.Both fix Ollama tier model routing and evictions, but #1064 keeps the embedder on 48gib-slow while this item removes a second chat model from 48gib-fast.devops-cli-service commentedon Nov 4, 2026
Refine cannot set this item to Ready at 67d3f47 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
dan-petty commentedon Nov 5, 2026
Measure (2026-11-05)
Sources: Prometheus (
litellm_request_total_latency_metric,litellm_proxy_total_requests_metric_total,kube_job_status_active,kube_node_status_condition), Loki (ollama-48giblogs), and a controlled test on the live tier. The test went straight to the Ollama pod ofollama-48gib-fast(oncondor) through a port-forward. It sent 26k-token prompts with 4 output tokens. In the swap runs only the test used the tier (see the Loki load lines from 00:57Z to 01:13Z on 11-05).1. Production windows (2 h buckets, bucket end time, UTC)
"Loads" count
load_tensors: offloaded 49/49(qwen3-coder:30b) and66/66(qwen3.8:27b). The coder and the 27b load in step: each 27b request after a coder request is a swap pair. The two models do not fit together on 48 GiB (Ollama predicts 69.7 GiB for the 27b, and the coder holds 37 GB). At 11-04 00:07Z the tier loggedLoad failed ... timed out waiting for llama-server to start: context canceledand a 499 after 46m40s. The window has 21 such lines.The 27b swaps and the runner Jobs fall at the same time after 11-04 04:00Z. The windows alone cannot separate cause 1 from cause 2. The controlled test below does.
2. One variable at a time (live tier, test traffic only)
Coder alone (control):
Cause 1: one tiny qwen3.8:27b request between coder requests. This is the only change.
One 27b request turns a coder reply of 0.1 s to 6 s into 60 s to 330 s. It also loses the KV cache: the prompt read goes from 0 or 4.8 s to 23 s. The 27b request itself needs 59 to 63 s for 22 tokens. The 302 s load fits a model file that is out of the page cache. The 21 load failures fit that too. The two embedding runs also evicted the coder. So the tier did not keep the embedder beside the coder while the 27b was in memory. The test cannot say if it does after a clean start, so I make no claim about the embedder.
Cause 2: a second Job at the same time, no 27b.
A second Job adds the service time of one request. It causes no model load and no cache loss, because the slot keeps more than one prompt cached. Two Jobs alone cannot make a mean of 362 s or 824 s.
Cause 3:
hawk(Ready=Unknown).kube_node_status_condition{condition="Ready",status="unknown",node="hawk"}is 1 in the whole window.ollama-48gibruns oncondor(Ready=true in the whole window) andollama-64gibongemini(Ready=true).hawkruns theollama-16gibtier only. So the node has no effect on the 48gib tier. Its effect is on the 16gib tier: all 30gpt-oss:20brequests of the window failed. A person must weigh that and the node. TodaykubectlshowshawkNotReady since 2026-11-04T20:50Z.3. Result
The measure supports cause 1 as a mechanism: a second chat model on the tier costs 55 to 330 s per swap and loses the KV cache, and the production swap counts follow the slow periods. It does not support cause 2 as the cause of the slow replies. Cause 3 does not touch this tier.
The counterexample of 11-04 13:51Z to 13:56Z fits this: the tier had a burst of 27b requests (46 in the bucket that ends 14:00Z), so evictions occurred. The coder had few requests in that burst.
4. What stays open
qwen3.8:27brequests in the last 24 h went toollama-48gib-fast. The rest went toollama-64gib-standard. That tier logged 1 eviction in 24 h. The 48gib tier logged 100, and about 25 of them come from my test.litellm_proxy_total_requests_metric_total{end_user="None"}is 165 forqwen3.8:27band 24 forgpt-oss:20bover the last 24 h (user=default_user_id, no key alias, no team). The gateway logs hold no request lines, so the metrics cannot name the client. I did not find it.devops-chatandqwen3.8:27boff the tier lowers their window from 262144 to 160000 tokens and sends all of them to the V100 tier.DEFAULT_GATEWAY_ROUTESinsrc/devops_cli/ai/gateway.pyand its test (fix(ai): the gateway failover routes name models that a serving tier holds #1969) name the default Ollama Service as the tier ofdevops-chat, so they change too.I wrote no code. A person must decide whether to accept the lower window and the tier move, and which source feeds the eviction alert.
devops-cli-service commentedon Nov 5, 2026
Status set to Ready at d72ec47 (see proposed design in issue body).
Moved to new items: #3578.
feat(k8s): serve qwen3.8:27b alone on the 48 and 64 GiB tiers (#3572)
dan-petty commentedon Nov 5, 2026
Answer from project standards, under the owner's instruction of 2026-11-05.
Question: Did #3572 and #3581 remove the cause, and do the acceptance criteria hold now?
Answer: The cause is gone on the live tier. The acceptance criteria do not all hold, so this item stays open. Two criteria stay, and one criterion has a small gap. The checks are from
origin/mainat2db71f29and from the live cluster at 2026-11-05T15:42Z.Source of the answer: the acceptance criteria of this issue,
k8s/llm/gateway/config.yaml,k8s/llm/profiles/ollama-profiles.yaml,k8s/devops/configmap.example.yamlandtests/ai/benchmark/test_k8s_llm_gateway.py.Period after the change
devops-coderrequestsdevops-codermean replyollama-48gibandollama-64gib(Loki)ollama-48gibollama-48gibsince 02:43ZThe stop count comes from the comments of those 11 items. The logs of the 13 Jobs also have no line with
no complete reply, but I have no proof that a stop writes that line to a Job log, so I do not count from them.ollama psshows one model on each tier:qwen3.8:27b, 100% GPU, context 262144, untilForever. The live environment ofollama-48gibsetsOLLAMA_MAX_LOADED_MODELS1 andOLLAMA_KEEP_ALIVE-1.The live ConfigMap
devops-cli-configsetsdeepseek-v4.1-flash-1017for the taskimplementand for each step of the ladder. In the 12 h to 15:42Z that group had 1267 requests with a mean of 19.5 s.Criteria
qwen3.8:27b. Sodevops-chat,qwen3.8:27band the fallback stay on the tier, and they cause no swap.test_the_48gib_and_64gib_tiers_load_qwen_alone_at_its_native_contextpasses. I added a second model to the deployments ofollama-48gibin a scratch run, and the test failed.devops ai gateway renderreports that the config is up to date.end_user="None"shows 0 over 24 hend_user="None"shows about 15qwen3-embedding:0.6b, 12gpt-oss:20band 5qwen3.8:27brequests. Refine moved this part to #3578.k8s/logging/loki-values.yamlhas no ruler setting. Grafana has no rule withevictin its name.What stays
ollama-profiles.yamlstates that a client that calls the tier directly with another model name makes Ollama unloadqwen3.8:27b. Ollama emits evictions only as log lines, so the alert needs a new source. Refine chose a Loki ruler rule. Loki has no ruler setting now, so that work includes it.{end_user=, so it does not state the criterion. A direct call ofsanitize_textwith that text keeps all of it, so that function is not the cause. I did not find the cause.ollama-48gib-fast, but feat(k8s): serve qwen3.8:27b alone on the 48 and 64 GiB tiers #3572 removed that deployment. The "Expected" section says the same. It also movesdevops-chatandqwen3.8:27bto the 64 GiB tier and changesDEFAULT_GATEWAY_ROUTES, and these changes have no purpose now. This item isstatus/ready, so a job can plan from that text. Recommendation: reduce the body to item 1 before a job takes it.The node with Ready=Unknown stays NotReady at the time of this check. Of the Ollama tiers, it runs only
ollama-16gib. I could not read that pod log, and Loki shows no eviction line for that tier, but a node in that state can send no logs. So I have no measure for that tier. Only a person changes hosts. #3064 is open, and its order note on this item stays.I changed no code.
13 remaining items
dan-petty commentedon Nov 18, 2026
This item cannot be built as written (AGENTS.md rule 2). The stage plan specifies tests in tests/prometheus/test_k8s_monitoring_alerting.py and tests/commands/k8s/test_k8s_logging_stack.py that read committed Kubernetes manifests and assert their values. Commit #6124 (issue #6119) took the Kubernetes manifest config-read count to zero, and docs/TESTING.md:61 records that no test asserts a value of a manifest or config file. The CI quality gate test-tree (tests/gate/tree_checks/config_values.py) fails when any new test reads a committed Kubernetes manifest, because tests/gate/tree_checks/config_reads.toml allows only zero new reads. CI schema and policy tools (k8s quality gate, kube-linter, kubeconform) check the form of Kubernetes manifests instead. The item is returned to New so refinement can revise the plan to conform with the project testing conventions.
devops-cli-service commentedon Nov 18, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (10)
Tools considered:
Searches run:
Sources:
dan-petty commentedon Nov 23, 2026
The issue cannot be built as written in this repository per AGENTS.md Rule 2.
Since step 11 of docs/HOMELAB_REPO_SWITCH.md (#6820), Argo CD reads the homelab environment from the private repository dan-petty/homelab. In devops-cli, all environment manifests under k8s/ (except k8s/devops and k8s/overlays/homelab/devops) are frozen, and CI gate environment_freeze (tests/gate/k8s_checks/environment_freeze.py) fails any pull request that modifies them.
The proposed Loki ruler rules and NetworkPolicy changes belong in a pull request of dan-petty/homelab rather than devops-cli.
dan-petty commentedon Nov 24, 2026
This issue cannot be built in this repository per AGENTS.md Rule 2. Since step 11 of docs/HOMELAB_REPO_SWITCH.md (#6820), Argo CD reads the homelab environment from the repository dan-petty/homelab. The environment manifests under
k8s/in this repository are frozen, and CI gateenvironment_freezerejects modifications to them. The proposed Loki ruler rules and NetworkPolicy changes belong in dan-petty/homelab. This item closes as not planned in devops-cli.