Skip to content

fix(k8s): the coder tier serves no second chat model #3485

Not planned

Description

@dan-petty

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:27b and no other model (OLLAMA_MAX_LOADED_MODELS 1, OLLAMA_KEEP_ALIVE -1). feat(k8s): implement with deepseek-v4.1-flash-1017 #3581 moves implement to deepseek-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.yaml states that a client that calls the tier directly with another model name makes Ollama unload qwen3.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 with ollama in its name.
  • No rule and no test names these lines. k8s/logging/loki-values.yaml has no ruler setting. The live Loki config holds only the local storage and the WAL directory of the ruler, and no alertmanager_url. The policy in k8s/logging/networkpolicy.yaml allows egress only in the namespace and to DNS, so the ruler has no path to Alertmanager (prometheus-alertmanager, port 9093, namespace monitoring). k8s/monitoring/networkpolicy.yaml admits nothing from logging on 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-fast logs 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.

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-fast log 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

  1. added
    source/agent
    type/bug
    scope/k8s
    status/new
    value/high
    effort/medium
    on Nov 4, 2026
  2. dan-petty commented on Nov 4, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

  3. added
    priority/p1-high
    on Nov 4, 2026
  4. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    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.

    • The proposal has no problem statement, no acceptance criterion with its requirement, scenario, WHEN and THEN, or no answer to the existing-tool question. State the problem, the requirements with their scenarios, and the open tool that covers the need or the cost of building it.
  5. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    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-48gib logs), and a controlled test on the live tier. The test went straight to the Ollama pod of ollama-48gib-fast (on condor) 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)

    Bucket end devops-coder mean (s) coder requests qwen3.8:27b requests qwen3.8:27b mean (s) coder loads 27b loads evictions mean active runner Jobs
    11-03 14:00 76 105 102 303 11 13 22 1.1
    11-03 16:00 62 188 17 457 16 16 33 1.8
    11-03 18:00 25 199 28 112 14 13 25 1.3
    11-03 20:00 56 168 29 431 17 17 35 1.9
    11-03 22:00 103 110 17 411 17 17 34 2.0
    11-04 00:00 135 141 25 406 10 10 20 2.0
    11-04 02:00 362 6 53 288 5 5 9 1.1
    11-04 04:00 42 64 104 249 5 4 7 0.75
    11-04 06:00 4.0 896 7 100 7 2 5 0.96
    11-04 08:00 to 12:00 7 to 18 227 to 396 0 - 4 to 5 0 0 0.7 to 0.8
    11-04 14:00 33 227 46 63 7 6 12 0.8
    11-04 16:00 to 18:00 9 to 18 482 to 487 6 to 0 - 4 to 7 1 2 0.8

    "Loads" count load_tensors: offloaded 49/49 (qwen3-coder:30b) and 66/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 logged Load failed ... timed out waiting for llama-server to start: context canceled and 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):

    Run Reply (s) Model load (s) Prompt read (s)
    P1 first (26k tokens) 6.1 0 4.8
    P1 again, P1 again 0.1, 0.1 0 0 (KV cache hit)
    P2, P1, P2, P1 alternating 6.5, 1.0, 0.8, 1.0 0 4.7, then 0

    Cause 1: one tiny qwen3.8:27b request between coder requests. This is the only change.

    Run Reply (s) Model load (s) Prompt read (s)
    27b request, 22 tokens, run 1 59.4 33.2 21.4
    coder P1 after it 60.0 32.6 23.1
    27b request, run 2 62.8 34.3 23.0
    coder P1 after it 110.6 83.3 23.4
    embedding request, then coder P1 (run 1) 56.6, then 93.2 65.9 23.4
    embedding request, then coder P1 (run 2) 57.3, then 330.0 302.1 23.9

    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.

    Run Reply (s)
    one fresh 26k prompt 5.5
    two fresh 26k prompts at once 5.4 and 10.9
    two cached prompts at once 0.1 and 0.9

    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-48gib runs on condor (Ready=true in the whole window) and ollama-64gib on gemini (Ready=true). hawk runs the ollama-16gib tier only. So the node has no effect on the 48gib tier. Its effect is on the 16gib tier: all 30 gpt-oss:20b requests of the window failed. A person must weigh that and the node. Today kubectl shows hawk NotReady 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

    • 74 of 219 qwen3.8:27b requests in the last 24 h went to ollama-48gib-fast. The rest went to ollama-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 for qwen3.8:27b and 24 for gpt-oss:20b over 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.
    • Ollama emits evictions only as log lines. It has no Prometheus metric for them. So the alert in the acceptance criteria needs a new source (a Loki ruler rule, or a log-to-metric step in Alloy). That is a design choice.
    • Moving devops-chat and qwen3.8:27b off the tier lowers their window from 262144 to 160000 tokens and sends all of them to the V100 tier. DEFAULT_GATEWAY_ROUTES in src/devops_cli/ai/gateway.py and its test (fix(ai): the gateway failover routes name models that a serving tier holds #1969) name the default Ollama Service as the tier of devops-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.

  6. added
    status/ready
    and removed
    status/new
    on Nov 5, 2026
  7. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at d72ec47 (see proposed design in issue body).

    Moved to new items: #3578.

  8. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    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/main at 2db71f29 and 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.yaml and tests/ai/benchmark/test_k8s_llm_gateway.py.

    Period after the change

    Measure Before (measure comment, 11-03 and 11-04) After
    devops-coder requests 6 to 896 per 2 h 0 in the 12 h to 15:42Z
    devops-coder mean reply 4 to 362 s no requests
    Evictions, ollama-48gib and ollama-64gib (Loki) 24 and 1 in the 12 h to 11-04 14:00Z 0 and 0 in the 12 h to 11-05 15:30Z
    Evictions in the current pod logs since 02:43Z - 0 and 0
    Model loads in the current pod logs since 02:43Z 4 to 34 per 2 h on ollama-48gib 1 and 1
    Load failures on ollama-48gib since 02:43Z 21 in the window of the issue 0
    Timeout stops 6 from 11-03T23:47Z to 11-04T02:47Z 0 stop comments on the 11 items of the 13 runner Jobs since the change
    Runner Job time 2 to 3 h mean 0.35 h, longest 0.93 h, for the 12 Jobs that ended (1 was still running)

    The 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 ps shows one model on each tier: qwen3.8:27b, 100% GPU, context 262144, until Forever. The live environment of ollama-48gib sets OLLAMA_MAX_LOADED_MODELS 1 and OLLAMA_KEEP_ALIVE -1.

    The live ConfigMap devops-cli-config sets deepseek-v4.1-flash-1017 for the task implement and 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

    # Criterion State Evidence
    1 A measure comes first, and it gives the mean reply, timeout stops and evictions for each period, and the effect of the node Holds, with a gap The comment of 2026-11-05 changes one candidate at a time and gives the node effect. Its table has no column for timeout stops. The issue body gives the only count before the change, and this comment gives the count after it.
    2 If cause 1: no second chat model on the tier while implement uses it, and a test fails if one returns Holds, by a different route Implement left the tier, and each deployment on the tier now names qwen3.8:27b. So devops-chat, qwen3.8:27b and the fallback stay on the tier, and they cause no swap. test_the_48gib_and_64gib_tiers_load_qwen_alone_at_its_native_context passes. I added a second model to the deployments of ollama-48gib in a scratch run, and the test failed. devops ai gateway render reports that the config is up to date.
    3 If cause 2: a test holds one runner Job on the tier Does not apply The measure does not support cause 2.
    4 The client without a header names itself or gets a refusal, and end_user="None" shows 0 over 24 h Does not hold Over the 24 h to 15:42Z, end_user="None" shows about 15 qwen3-embedding:0.6b, 12 gpt-oss:20b and 5 qwen3.8:27b requests. Refine moved this part to #3578.
    5 A test holds an alert on tier evictions over a threshold Does not hold No rule and no test name Ollama evictions. k8s/logging/loki-values.yaml has no ruler setting. Grafana has no rule with evict in its name.

    What stays

    1. The eviction alert (criterion 5). The tier can still evict: ollama-profiles.yaml states that a client that calls the tier directly with another model name makes Ollama unload qwen3.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.
    2. The unnamed client (criterion 4), in fix(ai): name or refuse a gateway caller without an end-user header #3578. The body of fix(ai): name or refuse a gateway caller without an end-user header #3578 stops in the middle of a sentence, at {end_user=, so it does not state the criterion. A direct call of sanitize_text with that text keeps all of it, so that function is not the cause. I did not find the cause.
    3. The proposed design in this issue is out of date. It keeps the embedding model on 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 moves devops-chat and qwen3.8:27b to the 64 GiB tier and changes DEFAULT_GATEWAY_ROUTES, and these changes have no purpose now. This item is status/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.

  9. 13 remaining items

  10. dan-petty commented on Nov 18, 2026

    @dan-petty
    OwnerAuthor

    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.

  11. added
    status/new
    and removed
    status/blocked
    owner/agent
    on Nov 18, 2026
  12. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    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:

    • Loki ruler alerting rule unit test LogQL fixtures, results: 5
    • lokitool validate Loki ruler rules, results: 5
    • Grafana Loki alerting ruler LogQL alert rule documentation, results: 5
    • "loki" "test" alerting rules CLI "rules" validate github, results: 5
    • Loki ruler, results: 5
    • grafana loki logql, results: 5
    • lokitool, results: 5
    • Loki alerting rules Grafana documentation, results: 5
    • Loki ruler configuration docs, results: 5
    • grafana.com docs loki alerting, results: 5

    Sources:

  13. added
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 23, 2026
  14. dan-petty commented on Nov 23, 2026

    @dan-petty
    OwnerAuthor

    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.

  15. added
    status/new
    and removed
    status/in-progress
    on Nov 23, 2026
  16. dan-petty commented on Nov 24, 2026

    @dan-petty
    OwnerAuthor

    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 gate environment_freeze rejects 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.

  17. removed
    status/new
    owner/agent
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highscope/k8ssource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions