Skip to content

fix(gateway): apply service type and annotations - #260

Merged
edenreich merged 3 commits into
mainfrom
fix/issue-254-20260925-2214
Sep 25, 2026
Merged

edenreich merged 3 commits into
mainfrom
fix/issue-254-20260925-2214

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

reconcileService built the Gateway Service from only selector and ports, so spec.service.type and spec.service.annotations were silently ignored (the API server defaulted every Service to ClusterIP), and its update path only diffed ports and selector.

  • Set Spec.Type from spec.service.type (defaulting to ClusterIP) and the Service annotations from spec.service.annotations.
  • Update path now also diffs type and annotations, so later changes take effect.
  • Preserve the API-server-assigned nodePorts while the type still exposes them (prevents an update loop on NodePort/LoadBalancer Services), and stop copying the existing clusterIP when the type is ExternalName.
  • New unit tests cover create, the ClusterIP default, type/annotation updates, and nodePort preservation.

No CRD or API changes - the fields already existed. Annotations are treated as authoritative on the operator-owned Service (same pattern as the upstream Gateway/HTTPRoute reconcilers), so removing a key from the spec removes it from the Service.

Closes #254

@edenreich

Copy link
Copy Markdown
Contributor

@infer CI is failing - can you fix this?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Model: ollama_cloud/glm-5.3-flash · View Job

Todos

Pull Request

#260

✅ Infer Result: Success

CI is fixed and fully green on PR #260 - all 8 checks pass (Lint, Build, Generate & Verify Clean State, Unit Tests, E2E Tests, CodeQL x2, Analyze).

What was failing

The Lint job flagged a gocyclo violation: (*GatewayReconciler).reconcileService in internal/controller/gateway_controller.go had a cyclomatic complexity of 34, above the configured limit of 30. This was caused by the PR's new Service logic (type/annotation handling, nodePort preservation, ExternalName handling) accumulating in one function that already computed ports from server/TLS/telemetry settings.

What I changed (commit 219dac4)

  • Extracted the desired-Service construction (main-port derivation, metrics/HTTPS ports, service type + annotations from spec.service) into a new package-level helper desiredService(ctx, gateway).
  • reconcileService now only handles ownership, get/create/update, the ClusterIP/ExternalName handling, and nodePort preservation - pure code motion, no behavior change. Complexity drops to ~13 for reconcileService and ~19 for desiredService.

Verification

  • task lint: 0 issues
  • go build ./..., go vet ./...: clean
  • task test: all 161 envtest specs pass, including the existing unit tests for Service create, ClusterIP defaulting, type/annotation updates, and nodePort preservation
  • The active pre-commit hook also re-ran manifest/deepcopy generation, fmt, vet, and the full test suite before the commit landed, and "Generate & Verify Clean State" passes in CI, so generated manifests are still reproducible

No behavior changes, no CRD/API changes, no docs or downstream impact - this is a refactor-only commit on top of the existing fix(gateway): apply service type and annotations work.

Model: ollama_cloud/glm-5.3-flash · Exit Code: 0 · Duration: 11m 42s

Tokens: 1,137,437 in · 12,207 out · 1,149,644 total (21 requests)

Tool calls: 25 total · 100% success rate

Traces
Session: 1790377765-f0897fec

session (headless, success)                                                                       11m34s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.8s
├── execute_tool TodoWrite call_d8lg3s92                                                            71µs
├── execute_tool Bash call_9gozczb0                                                                487ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.1s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.1s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.1s
├── execute_tool Bash call_53yrh69e                                                                 2.1s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.7s
├── execute_tool Read call_iz4lknta                                                                291µs
├── chat ollama_cloud/glm-5.3-flash                                                                18.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      18.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    18.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            18.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                18.8s
├── execute_tool Grep call_ms0y3k90                                                                 57ms
├── chat ollama_cloud/glm-5.3-flash                                                                13.1s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      13.1s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    13.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            13.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                13.1s
├── execute_tool TodoWrite call_kk0st267                                                            68µs
├── execute_tool Grep call_6939s9rf                                                                776µs
├── chat ollama_cloud/glm-5.3-flash                                                                 7.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       7.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     7.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             7.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 7.8s
├── execute_tool Edit call_5jfphpp8                                                                  1ms
├── chat ollama_cloud/glm-5.3-flash                                                                 2.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.8s
├── execute_tool Bash call_e4lqr47q                                                                1m15s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.5s
├── execute_tool Bash call_6omuwnzg                                                                 5.9s
├── chat ollama_cloud/glm-5.3-flash                                                                 3.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.4s
├── execute_tool Bash call_7nsnthn7                                                                15.3s [error: tool_error]
├── chat ollama_cloud/glm-5.3-flash                                                                 4.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.3s
├── execute_tool TodoWrite call_gzomkikj                                                            67µs
├── execute_tool Bash call_t7p91n9v                                                                26.5s
├── chat ollama_cloud/glm-5.3-flash                                                                 2.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.6s
├── execute_tool Bash call_4d57986f                                                                17.2s
├── execute_tool Bash call_cy662pw3                                                                  3ms
├── chat ollama_cloud/glm-5.3-flash                                                                 2.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.3s
├── execute_tool Bash call_m5j7iwwj                                                                  5ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.2s
├── execute_tool Bash call_6ffd9orm                                                                22.9s
├── chat ollama_cloud/glm-5.3-flash                                                                 2.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.5s
├── execute_tool Bash call_5k7tlpvb                                                                 1.5s
├── chat ollama_cloud/glm-5.3-flash                                                                 8.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       8.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     8.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             8.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 8.1s
├── chat ollama_cloud/glm-5.3-flash                                                                 3.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.7s
├── execute_tool Memory call_hok8kikb                                                               1.3s
├── chat ollama_cloud/glm-5.3-flash                                                                 4.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.7s
├── execute_tool TodoWrite call_rl74ly2d                                                            67µs
├── chat ollama_cloud/glm-5.3-flash                                                                 2.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.0s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.0s
├── execute_tool Wait call_riz4gek4                                                                7m11s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.7s
├── execute_tool TodoWrite call_e5u54u1i                                                            66µs
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.6s
├── execute_tool Bash call_qc96w35z                                                                  4ms
╰── chat ollama_cloud/glm-5.3-flash                                                                 4.3s
    ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.3s
        ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.2s
            ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.2s
                ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.2s
Stats
Tool Calls

╭───────────┬───────┬───────┬──────────╮
│ Tool      │ Calls │ Fail% │ Avg      │
├───────────┼───────┼───────┼──────────┤
│ Bash      │ 12    │ 8%    │ 13876ms  │
│ TodoWrite │ 5     │ 0%    │ 64µs     │
│ Grep      │ 2     │ 0%    │ 29ms     │
│ Edit      │ 1     │ 0%    │ 1ms      │
│ Memory    │ 1     │ 0%    │ 1333ms   │
│ Wait      │ 1     │ 0%    │ 430880ms │
│ Read      │ 1     │ 0%    │ 276µs    │
╰───────────┴───────┴───────┴──────────╯

Token Usage

╭────────────────────────────┬─────────┬────────┬────────────┬─────────┬──────╮
│ Model                      │ Prompt  │ Cached │ Completion │ Total   │ Cost │
├────────────────────────────┼─────────┼────────┼────────────┼─────────┼──────┤
│ ollama_cloud/glm-5.3-flash │ 1137437 │ 887040 │ 12207      │ 1149644 │ -    │
╰────────────────────────────┴─────────┴────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ headless │ 1        │
╰───────────┴──────────┴──────────╯

Triggered by edenreich · Infer Action · OSS

@edenreich
edenreich merged commit 1a78570 into main Sep 25, 2026
@edenreich
edenreich deleted the fix/issue-254-20260925-2214 branch September 25, 2026 23:31
inference-gateway-releaser Bot added a commit that referenced this pull request Oct 3, 2026
## [0.27.0](v0.26.0...v0.27.0) (2026-10-03)

### ✨ Features

* **gateway:** add spec.a2a with Agent CR discovery ([#269](#269)) ([e707643](e707643))

### 🐛 Bug Fixes

* **gateway:** apply service type and annotations ([#260](#260)) ([1a78570](1a78570))

### 👷 CI

* **deps:** bump the gomod group with 4 updates ([#263](#263)) ([8c30df5](8c30df5))

### 📚 Documentation

* **agents:** add code readability guidelines ([#261](#261)) ([1b8157d](1b8157d))
* **agents:** add code readability guidelines ([#262](#262)) ([41c8e79](41c8e79))
* document gateway api crds and namespace label ([#258](#258)) ([a49a634](a49a634))
* fix install docs pinned version and stale claims ([#257](#257)) ([849e6f5](849e6f5))
* fix readme monitoring labels, configmap and status ([#256](#256)) ([31516bd](31516bd))
* fix removed and renamed CRD fields in docs ([#259](#259)) ([e81ea37](e81ea37))

### 🔧 Miscellaneous

* **deps:** bump claude-code 2.1.278 -> 2.1.280 ([#249](#249)) ([8888466](8888466))
* **deps:** bump claude-code 2.1.280 -> 2.1.283 ([#264](#264)) ([68d42bb](68d42bb))
* **deps:** bump claude-code 2.1.283 -> 2.1.285 ([#267](#267)) ([a940cb0](a940cb0))
* **deps:** bump infer CLI v0.205.3 -> v0.208.0 ([#250](#250)) ([3bcf0b1](3bcf0b1))
* **deps:** bump infer CLI v0.208.0 -> v0.218.0 ([#265](#265)) ([e08051d](e08051d))
* **deps:** bump infer CLI v0.218.0 -> v0.221.1 ([#266](#266)) ([a75538a](a75538a))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.27.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Gateway spec.service.type and spec.service.annotations are ignored

1 participant