Skip to content

feat(nginx): the split-host frontend site proxies /slm/api to a configurable SLM host (#19832) - #20464

Open
mrveiss wants to merge 49 commits into
mainfrom
issue-19832-nginx-slm-proxy
Open

mrveiss wants to merge 49 commits into
mainfrom
issue-19832-nginx-slm-proxy

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

The main frontend's SLM calls (slmClient.ts via getSLMUrl()) go to /slm/api on its own origin. On a split host the frontend nginx site has no such route, so the calls have nowhere to go. ADR-012 keeps the SLM a separate app at /slm/, and that is untouched: this is a proxy for the main app's SLM API calls only. The earlier closure cited ADR-012; the owner has overridden it, and the PR is realigned to current main and the install milestone (M1, phase M1.4).

What Changed

Kept (still needed, absent on main):

  • roles/frontend/templates/nginx-frontend.conf.j2: upstream autobot_slm_backend, /slm/api/ and /slm/api/ws/ locations, the edge denial of /slm/api/internal/, refusal of open health/metrics routes, verified HTTPS to a remote SLM.
  • roles/frontend/defaults/main.yml and tasks/code_only.yml: one explicit frontend_slm_remote placement, CA assertion when remote.
  • inventory/group_vars/all.yml: slm_nginx_tls_port, slm_client_max_body_size, slm_trusted_proxies (rendered into the SLM unit as SLM_TRUSTED_PROXIES); roles/common and the SLM vhost read the port variable (bug(deploy): the SLM vhost states its TLS port and upload cap as literals #22055).

Changed in this revival:

  • The frontend /slm/api locations now take slm_client_max_body_size directly. The frontend_slm_client_max_body_size alias is removed (owner decision, 2026-11-18).
  • repo_tests/proxy_upload_cap_one_home_19868_test.py learns that SLM locations take the SLM cap home, and pins that both locations do.
  • New test pins the SLM vhost's IPv4 and IPv6 TLS listens and the slm_frontend firewall port to slm_nginx_tls_port.
  • Merged current main; the only conflict was inventory/group_vars/all.yml (kept both the trusted-proxies block and main's proxy_upload_cap_file).

Review-fix round (head 375438e):

  • SLM firewall rule and deployment summary read slm_nginx_tls_port; the port-80 redirect carries a non-default TLS port; a test fails on a literal 443 in the slm_manager tasks or the SLM vhost.
  • The /slm/api/ and /slm/api/ws/ locations are ^~, so asset-extension regexes cannot shadow them. The open health and metrics routes (health, ready, live, recovery, metrics/prometheus, performance/metrics/prometheus) are refused by exact or ^~ locations. The main app calls only /slm/api/nodes, /auth/login and /discover/; the SLM UI is served by the SLM vhost and Prometheus scrapes the SLM backend directly, so none of the refused routes has a main-app caller.
  • slm_manager asserts a frontend entry (an IP address) is among the trusted proxies when a frontend exists.
  • Remote preflight checks the effective host (no loopback range, no IPv6 literal) and a regular CA file, and only runs where the site is rendered.
  • Open design item: fix(nginx): a remote SLM hostname that does not resolve stops the main frontend from starting #22093 (remote SLM name resolution at nginx start).

Dropped: the old reach-floor re-pins. The branch diff no longer carries any, and none were needed after the merge.

Verification

  • All *19832* tests, proxy_upload_cap_one_home_19868_test.py, the 20894 tests, the nginx and firewall tests, guard_reach_meta_test.py, reach_declarations_test.py and the reach-record tests: passing locally (project interpreter, plain jinja2 rather than Ansible's templar). Pre-push fast guards pass.
  • nginx -t passed on the rendered frontend template (self-signed test certificate, loopback upstream). The SLM vhost was not run through nginx -t.
  • Not done: a full play or a real split-host deployment.

Model Used

Claude Sonnet 5.5

Closes #19832
Closes #22055

Summary by CodeRabbit

  • New Features

    • Added configurable routing between the frontend and SLM, supporting local HTTP or remote HTTPS connections with certificate verification.
    • Added trusted-proxy configuration for frontend and backend connections.
    • Made the SLM HTTPS port and request size limit configurable.
  • Security

    • Restricted access to internal SLM APIs and health and metrics endpoints through the frontend.
  • Tests

    • Added coverage for routing, TLS settings, proxy trust, request limits and access restrictions.

@mrveiss

mrveiss commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

What changes when the SLM API is reachable on the main frontend's origin (#19832)

Read-only analysis of the code at this PR's head, plus the maintainer decisions applied afterwards. Paths are repo-relative. "Not determined" marks what reading could not settle.

Verdict

The SLM backend was already reachable at /slm/api on its own vhost; the new locations add the same surface on a second origin. Nothing found depended on the SLM being a separate origin for its authentication (bearer tokens, no cookies). The open routes, the missing login limit and the callback-host allowlist did depend on it in practice; each is resolved or listed below.

1. Rate limits

  • nginx: neither the SLM vhost nor the frontend site defines limit_req / limit_conn, so there was nothing to match in the proxy block.
  • App, before: only SSO and LDAP entry points were limited (autobot-slm-backend/api/sso_auth.py:53,61,69); POST /api/auth/login was not.
  • Applied: POST /api/auth/login is now limited per client IP and per username (autobot-slm-backend/api/login_rate_limit.py, called at the top of login in api/auth.py). It uses the shared RateLimiter that sso_auth.py uses, with the anonymous tier read from the SSOT config (no numbers in the module). A refusal is 429 with Retry-After and is audited as a failed auth.login, as a bad password is. Both buckets are charged on every attempt; a bucket for one username does not block another, nor another IP.
  • Not determined: whether the user service locks an account after repeated failures (not read).

2. Routes with no auth or weaker auth (mounted in autobot-slm-backend/main.py:578-583; gate _SM at main.py:630)

Route file:line Exposes On the main origin now
GET /api/health api/health.py:79 status, version, uptime, db/redis/frontend state, node counts reachable (the unified UI probes it: autobot-slm-frontend/src/composables/useSlmWebSocket.ts:205, src/views/settings/APISettings.vue:41)
GET /api/health/database api/health.py:150 detailed DB health refused (403)
GET /api/ready, /api/live api/health.py:132,144 liveness only refused (403)
GET /api/recovery api/health.py:158 static recovery page refused (403)
GET /api/performance/metrics/prometheus api/performance.py:50,881 DB-derived metrics text, ungated by design (main.py:598, #14339) reachable (the fleet-metrics view reads it with a bearer: autobot-slm-frontend/src/composables/useFleetMetrics.ts:364)
POST /api/auth/login api/auth.py:79 credential check reachable, now limited (section 1)
/api/auth/sso/* (providers, login, callback, exchange, ldap/login, saml/*) api/sso_auth.py:160-518 SSO entry points reachable, limited per sso_auth.py:53-75
/api/sso-providers* api/sso.py:71-332 provider admin authenticated: every route has require_permission(Permission.SECURITY_MANAGE) (:75,94,119,178,200,228,248,276,292,331); mutating ones also require_step_up. The "open" listing at main.py:593 is wider than the file.
/api/ws/* WebSocket api/websocket.py:363,404,435,483 own auth not read here; not determined

The path the maintainer named, /slm/api/metrics/prometheus, is not a route in the SLM; the real one is /performance/metrics/prometheus (above). It is refused as named (harmless) and the real route is left reachable because the UI needs it. Open gap for the maintainer: that route is ungated, so the main origin serves it to anyone. Gating it for browsers while keeping scrapers working needs a code change (a scrape token or separate path), not an nginx rule; not done here.

Agent-ingest routes accept X-Internal-API-Key instead of a user token (services/auth.py:305; mounted _SM_OR_AGENT at main.py:633,647,651,656,659). The key is a shared secret; reachability from another origin does not weaken it.

Not reachable through the new prefix: /scim/v2/* (mounted without /api, main.py:584), / and /metrics (main.py:703,714), and the nginx-only /autobot-api/, /openapi.json, /docs, /redoc. The new blocks inject no credentials of their own.

3. Cookies, CSRF and token storage

  • The SLM sets no cookies and authenticates by bearer header only (middleware/security_headers.py:14). A main-app session cookie is not consumed by the SLM; no SLM cookie exists.
  • State-changing requests without an Authorization header are refused outside an exempt list (middleware/security_headers.py:34-45).
  • Token storage (settled): the SLM UI stores slm_access_token and slm_user in sessionStorage with a localStorage fallback (autobot-slm-frontend/src/utils/authStorage.ts:13-14,19,37-42). The main UI stores autobot_auth in localStorage (autobot-frontend/src/stores/useUserStore.ts:263,302). The keys do not collide. On one shared origin they are still readable by any script on that origin; separating them needs a decision on whether the two UIs share an origin at all. No code in the main UI reads the SLM keys (search of autobot-frontend/src: no match).

4. CORS

allow_origins comes from SLM_CORS_ORIGINS or the SSOT host list plus the SLM and frontend nodes (config.py:97-127), allow_credentials=True (middleware/__init__.py:39-43). Through the proxy the browser sees the main origin as same-origin, so CORS is not exercised. The list does not widen.

5. Source-IP trust and forwarded headers

  • Client IP is taken from X-Forwarded-For only when the TCP peer is in settings.trusted_proxies (config.py:130-151,493-497; autobot_shared/proxy_utils.py).
  • The default list already includes the frontend node's address from the SSOT (config.py:146-147: NetworkConstants.FRONTEND_VM_IP), alongside loopback and the SLM node. Nothing was added. Remaining risks, not code defects: SLM_TRUSTED_PROXIES, when set, replaces the list (config.py:139-141; no ansible role sets it, search found none), and the SSOT frontend address must be the address nginx actually connects from. Not determined on any deployed host.
  • The new blocks set X-Forwarded-For $proxy_add_x_forwarded_for and X-Real-IP $remote_addr.
  • No allowlist by source IP was found in the SLM app code read.

6. Host header and SSO callbacks

The blocks send Host $host deliberately (the SLM vhost answers any server_name). SSO callback construction validates the host against localhost, 127.0.0.1 and the host of SLM_EXTERNAL_URL (api/sso_auth.py:76-90,103-130) and builds {scheme}://{host}/api/auth/sso/callback (:135). Left as is, by decision: allowing the main frontend's hostname would not make SSO work on the unified origin, because that URL's path /api/auth/sso/callback is the main app's /api, not the SLM's /slm/api, and the IdP's registered redirect URI would also have to change. That is a design change for the SSO flow, not an allowlist entry. Until then SSO started from the main hostname gets a 400.

7. Routes open only because of the SLM's own port

None found in the app. The ungated health and metrics surfaces (section 2) are open regardless of port.

8. Response headers (settled)

nginx inherits add_header from the server level into a location only when the location has none of its own. The /slm/api/ locations have none, so they inherit the server-level Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy (nginx-frontend.conf.j2 server level). The security headers the SLM app sets (middleware/security_headers.py:100-135: frame, nosniff, HSTS, CSP, referrer, permissions policy) pass through proxy_pass unchanged, because nginx does not strip upstream response headers. So they are not dropped. Not tested against a running nginx.

Applied in the proxy block (this PR)

  • client_max_body_size on both locations, from one value shared with the SLM vhost (slm_client_max_body_size, 10m).
  • Separate SLM node: HTTPS to the SLM's nginx on the SSOT port (slm_nginx_tls_port), keeping /slm/api/, with proxy_ssl_server_name on, proxy_ssl_verify on and the fleet CA (ca-cert.pem beside the node's own certificate, proxy_ssl_trusted_certificate). The play fails with a message when that CA file is missing; verification is never switched off. Same machine: plain HTTP to loopback uvicorn. No change to the uvicorn bind address or the firewall.
  • Refused with 403 on the main origin: /slm/api/health/… (sub-paths), ready, live, recovery, metrics/prometheus. Left reachable because the unified UI calls them: /slm/api/health and /slm/api/performance/metrics/prometheus.
  • POST /api/auth/login rate limit (section 1).

Still needs a decision

  1. Gating /api/performance/metrics/prometheus for browsers (section 2).
  2. SSO on the unified origin: callback path and IdP redirect URI (section 6).
  3. Whether the two UIs should share an origin's storage (section 3).
  4. The SLM node's certificate must carry the address the frontend connects to and chain to the fleet CA; not checked on any host.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d41725f and 7ad5aef.

Files selected for processing: 19

  • autobot-slm-backend/ansible/inventory/group_vars/all.yml
  • autobot-slm-backend/ansible/roles/common/defaults/main.yml
  • autobot-slm-backend/ansible/roles/frontend/defaults/main.yml
  • autobot-slm-backend/ansible/roles/frontend/tasks/code_only.yml
  • autobot-slm-backend/ansible/roles/frontend/templates/nginx-frontend.conf.j2
  • autobot-slm-backend/ansible/roles/slm_manager/tasks/main.yml
  • autobot-slm-backend/ansible/roles/slm_manager/tasks/service_units.yml
  • autobot-slm-backend/ansible/roles/slm_manager/tasks/trusted_proxies.yml
  • autobot-slm-backend/ansible/roles/slm_manager/templates/autobot-slm-backend.service.j2
  • autobot-slm-backend/ansible/roles/slm_manager/templates/autobot-slm.conf.j2
  • repo_tests/_reach_declared_scopes.py
  • repo_tests/_reach_roots_record.py
  • repo_tests/ansible_log_dir_templates_complete_and_ensured_20894_test.py
  • repo_tests/nginx_frontend_slm_api_limits_19832_test.py
  • repo_tests/nginx_frontend_slm_api_proxy_19832_test.py
  • repo_tests/nginx_frontend_slm_api_remote_and_refusals_19832_test.py
  • repo_tests/nginx_frontend_slm_explicit_placement_19832_test.py
  • repo_tests/proxy_upload_cap_one_home_19868_test.py
  • repo_tests/slm_manager_tls_port_redirect_and_proxies_19832_test.py
Walkthrough

The change adds configurable SLM proxy settings, local and remote frontend placement, and Nginx routes for SLM API and WebSocket requests. It also configures trusted proxies and adds tests for rendered proxy settings, TLS verification, route refusals, and shared request-body limits.

Changes: SLM Proxy Configuration

Layer / File(s) Summary
Shared SLM settings and trusted proxies
autobot-slm-backend/ansible/inventory/group_vars/all.yml, autobot-slm-backend/ansible/roles/common/defaults/main.yml, autobot-slm-backend/ansible/roles/slm_manager/tasks/main.yml, autobot-slm-backend/ansible/roles/slm_manager/templates/*, repo_tests/slm_manager_tls_port_redirect_and_proxies_19832_test.py, repo_tests/ansible_log_dir_templates_complete_and_ensured_20894_test.py, repo_tests/_reach_declared_scopes.py, repo_tests/_reach_roots_record.py
Inventory variables define the SLM TLS port, body-size limit, and trusted proxy addresses. The SLM manager resolves frontend addresses and uses the configured values in its firewall rule, vhost, service unit, and deployment summary. Tests cover these values and address resolution.
Frontend placement defaults and validation
autobot-slm-backend/ansible/roles/frontend/defaults/main.yml, autobot-slm-backend/ansible/roles/frontend/tasks/code_only.yml, repo_tests/nginx_frontend_slm_explicit_placement_19832_test.py
An explicit setting selects local loopback HTTP or remote HTTPS. Remote mode checks for the fleet CA and a non-loopback SLM host. Tests cover placement selection and task conditions.
Frontend API and WebSocket proxy routes
autobot-slm-backend/ansible/roles/frontend/templates/nginx-frontend.conf.j2, repo_tests/nginx_frontend_slm_api_limits_19832_test.py, repo_tests/nginx_frontend_slm_api_proxy_19832_test.py, repo_tests/nginx_frontend_slm_api_remote_and_refusals_19832_test.py, repo_tests/proxy_upload_cap_one_home_19868_test.py
The Nginx template adds an SLM upstream, API and WebSocket proxy locations, and refusal routes for internal, health, and metrics paths. Tests check rendered local and remote proxy settings, TLS verification, route matching, and request-body limits.

Severity of issue fixed: Medium

Merge Risk: Moderate · previous review d4172

Two deployment paths are still inconsistent with the new settings. A self-update can leave a DNS-named frontend untrusted, so its users share one login rate-limit bucket. The updater's readiness probe fails when the SLM TLS port is not 443. Both are small fixes and worth making before merge. The remote-SLM startup DNS dependency is opt-in and tracked separately.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the split-host frontend site and its new proxying of /slm/api to a configurable SLM host, which is the main change in the changeset. The changeset also covers TLS port variables, trust…
Linked Issues check Passed Both directly linked issues are open, so their coding requirements apply.

[#19832] Proxy and placement requirements: The frontend template (roles/frontend/templates/nginx-frontend.conf.j2, head) defi…
Out of Scope Changes check Passed The changes support the linked objectives. The nginx frontend template adds the SLM upstream, proxy and WebSocket locations, the refusal locations, and the body cap. The frontend defaults and tasks se…
Full details: Title check

Explanation

The title names the split-host frontend site and its new proxying of /slm/api to a configurable SLM host, which is the main change in the changeset. The changeset also covers TLS port variables, trusted proxies, firewall rules and tests, but the title does not need to list these. The title includes the issue number (#19832), which is acceptable and does not make it misleading. The title is 94 characters, slightly over a typical short title length, but it stays a single descriptive sentence.

Full details: Linked Issues check

Explanation

Both directly linked issues are open, so their coding requirements apply.

[#19832] Proxy and placement requirements: The frontend template (roles/frontend/templates/nginx-frontend.conf.j2, head) defines the upstream autobot_slm_backend and the locations ^~ /slm/api/ and ^~ /slm/api/ws/. Both use frontend_slm_backend_protocol and frontend_slm_upstream_prefix. The remote branch adds proxy_ssl_verify on, proxy_ssl_name, and proxy_ssl_trusted_certificate for the fleet CA. Placement comes from the explicit frontend_slm_remote setting (roles/frontend/defaults/main.yml, per the change summary), not from slm_colocated_frontend. The CA and host preflight assertions are in roles/frontend/tasks/code_only.yml and are gated by the effective remote flag. The /slm/api/internal/ location returns 404. Open health and metrics routes are returned 403 by exact or ^~ locations generated from frontend_slm_refused_routes. The body cap uses slm_client_max_body_size directly. SLM_TRUSTED_PROXIES is rendered in the service unit template. Tests pin the rendered behaviour (for example nginx_frontend_slm_api_remote_and_refusals_19832_test.py and nginx_frontend_slm_explicit_placement_19832_test.py).

[#22055] TLS and port requirements: autobot-slm.conf.j2 uses slm_nginx_tls_port on both IPv4 and IPv6 listens, and the port-80 redirect uses it. The firewall rule and deployment summary in slm_manager/tasks/main.yml, and firewall_service_ports.slm_frontend in roles/common/defaults/main.yml, read the same variable. The upload cap is slm_client_max_body_size (10m). New tests (slm_manager_tls_port_redirect_and_proxies_19832_test.py and nginx_frontend_slm_api_limits_19832_test.py) fail on literal ports or caps in the vhost and tasks.

Non-coding items were disregarded: the branch-deletion criterion of #22055, and manual or deployment verification.

Unresolved points that do not block a coding verdict: the SLM vhost was not run through nginx -t, no real split-host deployment was done, and nginx DNS resolution at start-up for a remote SLM is deferred to #22093. These concern verification or a design item outside the listed acceptance criteria. The assessment relies on the change summary and the rendered frontend template read at head. The SLM vhost, tasks and tests were not read directly.

Full details: Out of Scope Changes check

Explanation

The changes support the linked objectives. The nginx frontend template adds the SLM upstream, proxy and WebSocket locations, the refusal locations, and the body cap. The frontend defaults and tasks select placement and enforce CA verification. The inventory and common defaults hold the shared TLS port and body cap. The SLM vhost and firewall use slm_nginx_tls_port. The slm_manager tasks resolve frontend addresses for SLM_TRUSTED_PROXIES, and the service unit renders that value. The changes to the existing test files (proxy_upload_cap_one_home_19868_test.py and ansible_log_dir_templates_complete_and_ensured_20894_test.py) update guards for the new variables. The new tests pin the new behaviour. No change was found that is unrelated to #19832 or #22055. The previous assessment noted a possible login rate-limit change. The current PR description and change summary do not list one, so no such change is assessed here.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

…o issue-19832-nginx-slm-proxy

# Conflicts:
#	repo_tests/frontend_url_served_by_19326_test.py
…d assert (#19832)

The SLM firewall rule and summary read slm_nginx_tls_port; the port-80 redirect carries a non-default TLS port; the /slm/api locations are ^~ so asset-extension regexes cannot shadow them; the health and metrics routes, which the main app never calls, are refused by exact or ^~ locations; the slm_manager play asserts a frontend is among the trusted proxies.
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 22, 2026
@mrveiss

mrveiss commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner Author

Review findings, fixed in this PR (head 375438e; first part in 69b6261):

  1. Literal 443: the ufw HTTPS rule and the summary message read slm_nginx_tls_port (roles/slm_manager/tasks/main.yml); slm_manager_tls_port_redirect_and_proxies_19832_test.py fails on a literal 443 in the role tasks or the SLM vhost. 69b6261.
  2. Port-80 redirect: Jinja conditional in autobot-slm.conf.j2, :<port> only when it differs from the implicit HTTPS port (slm_https_implicit_port); tests render 443, 8443, 9443. 69b6261.
  3. Open routes on the main frontend: the main app calls only /slm/api/nodes, /auth/login, /discover/ (useHostInventory, useTLSCredentials, ssot-config). /health and /performance/metrics/prometheus are called only by the SLM's own UI, which the SLM vhost serves, and Prometheus scrapes the SLM backend directly (monitoring role prometheus.yml.j2). Both are now refused at the main edge with the other open routes; the tests that asserted them open now assert refusal. There is no main-app caller, so no extra issue for the health detail was filed. 69b6261.
  4. Shadowing: ^~ on /slm/api/ and /slm/api/ws/; refusals are = or ^~ locations (defaults list frontend_slm_refused_routes); render tests pick the effective location per path, including asset-suffix paths. 69b6261, 375438e.
  5. Trusted proxies: slm_manager assert that a frontend entry exists when a frontend is deployed, and that frontend entries are IP addresses; tests for pass and fail. 69b6261, 375438e.

All 19 CodeRabbit threads are answered and resolved; the remote-SLM DNS-at-startup item is tracked as #22093.

Follow-up fixes from the re-review (commit d080298, head e4633cd):
6. Frontend entries by DNS name or IPv6: the slm_manager play now resolves each entry on the SLM host with getent ahosts (IPv4 and IPv6; an IP resolves to itself), fails only when an entry does not resolve and names it, and the unit's SLM_TRUSTED_PROXIES carries the resolved addresses (slm_trusted_frontend_resolved). Tests: a hostname, an IPv6 address, an unresolvable entry, and the rendered list.
7. The tautological second assert condition is removed.
8. #22055 cap half: a test fails when an active client_max_body_size in the SLM vhost is not {{ slm_client_max_body_size }}, with a contrast pair (literal trips, variable and commented line do not).
9. The slm_https_implicit_port comment states it is a protocol constant, never derived from slm_nginx_tls_port.

Third review (commit 67e26e4):
10. The getent task has check_mode: false (read-only), so --check no longer fails every entry; a test pins the key.
11. The resolve, getent-ran assert, resolved-entries assert and set_fact tasks carry every tag of the unit task (slm, backend, systemd) plus config; a test pins that the unit's tags are covered, so --tags backend or systemd can no longer render raw hostnames.
12. Only rc 2 without a task-level msg is "entry does not resolve" (entry named). Any other rc, or a missing binary (rc 2 with msg), fails a separate assert naming the entry, rc and stderr or message and blaming the host or resolver.
13. Tests: module docstring says they simulate the task expressions and run no Ansible, getent or unit template; added the check_mode test, the tag-coverage test, the host-error cases, and a dual-stack multi-record case with realistic STREAM/DGRAM/RAW output.

Fourth review (commit 7855c3d):
14. The raw command lookup is replaced by ansible.builtin.getent (database: ahosts, key: item, fail_key: false). Verified against ansible-core 2.17: the command module sets msg: "non-zero return code" on every rc != 0 (modules/command.py:367), and a missing binary arrives as rc 2 with a msg too (module_utils/basic.py:2012, fail_json(rc=e.errno, ... msg=...)), so the two were indistinguishable. With the getent module a missing binary or a resolver fault (rc 1 or 3) fails the task with the host named by the module's own message (modules/getent.py: get_bin_path('getent', True), module.fail_json(msg=msg)), while not-found (rc 2) succeeds with {entry: None} (getent.py: results[dbtree][key] = None; module.exit_json), which the inventory assert names. The "getent itself ran" assert and its rc handling are removed; the absent-rc case no longer exists. A test pins that the task has no failed_when or ignore_errors.
15. Test fixtures now follow the real result shape (built by the module's own record logic, keys are the addresses, not-found is {entry: None} plus msg); cases for found, IPv6, dual-stack multi-record, not-found (named, never trusted), plus the host-fault pin. I also ran the module ad hoc to confirm both shapes, and ansible-playbook --syntax-check on the SLM manager playbook passes.

Fifth review and full-suite follow-up (commits 619cb8a and 89bbab1):
16. The comment above the getent lookup is corrected: a missing binary, bad arguments or an unsupported database are host faults and fail the task; a resolver outage most likely exits 2 like not-found and cannot be told apart here (#22096).
17. The two full-suite failures from the new guard file are fixed: the guard is listed in the glob-reads record (*.yml), and the literal-port scan and the body-cap check use the shared comment stripper (tools.lint._comment_syntax), with the contrast pairs kept (and one added for the port scan).

Shrink-only record (head d41725f):
18. The *.yml entry added for the new port guard is removed from GLOB_DECLARED_UNCOVERED. The guard now declares its tree as one path-qualified constant (autobot-slm-backend/ansible/roles/slm_manager/tasks/*.yml), which the python path filter already covers through autobot-slm-backend/ansible/**, so the guard needs no record entry and the record does not grow.

Unit renderers (head ab67097):
19. The trusted-proxy resolution now lives in roles/slm_manager/tasks/trusted_proxies.yml, imported by service_units.yml immediately before the unit render. service_units.yml is the only file that renders the backend unit, and both entry points go through it: main.yml (full provision) and Play 1 of update-all-nodes.yml (the builtin self-update path), so the DNS-name fallback can no longer render. A test pins that every renderer resolves first, with a contrast pair.
20. The TLS-listener check is a detector function with contrast fixtures, and the compound assert is split.

Test hardening (head c3e08d5):
21. The unit-renderer check normalises template and ansible.builtin.template (and the legacy src= string), walks block, rescue and always, and fails when a file names the unit in code but yields no renderer; a contrast case covers each form.
22. The TLS-listen fixtures include a trailing-comment line that only the shared comment stripper can pass (checked by bypassing the stripper, which fails it); the Jinja {# #} limit points to #22099.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Use the configured SLM TLS port in the readiness URL. · update-all-nodes.yml:712

autobot-slm-backend/ansible/playbooks/update-all-nodes.yml:712
Major · Functional Correctness · Quick win

Use the configured SLM TLS port in the readiness URL.

If slm_nginx_tls_port is 9443, the changed vhost no longer listens on 443. This URL still selects 443. The updater therefore exhausts its readiness retries even when SLM is healthy on 9443. The failure occurs after nginx has restarted. (raw.githubusercontent.com)

Include slm_nginx_tls_port in this URL. Check the sibling SLM URLs in this playbook for the same implicit-port assumption. An explicit configured port also preserves the default 443 case.

As per path instructions, “Flag a fix applied to one of several sibling entry points.”

Source: Path instructions

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 28ba7a5 and d41725f.

Files selected for processing: 16

  • autobot-slm-backend/ansible/inventory/group_vars/all.yml
  • autobot-slm-backend/ansible/roles/frontend/defaults/main.yml
  • autobot-slm-backend/ansible/roles/frontend/tasks/code_only.yml
  • autobot-slm-backend/ansible/roles/frontend/templates/nginx-frontend.conf.j2
  • autobot-slm-backend/ansible/roles/slm_manager/tasks/main.yml
  • autobot-slm-backend/ansible/roles/slm_manager/templates/autobot-slm-backend.service.j2
  • autobot-slm-backend/ansible/roles/slm_manager/templates/autobot-slm.conf.j2
  • repo_tests/_reach_declared_scopes.py
  • repo_tests/_reach_roots_record.py
  • repo_tests/ansible_log_dir_templates_complete_and_ensured_20894_test.py
  • repo_tests/nginx_frontend_slm_api_limits_19832_test.py
  • repo_tests/nginx_frontend_slm_api_proxy_19832_test.py
  • repo_tests/nginx_frontend_slm_api_remote_and_refusals_19832_test.py
  • repo_tests/nginx_frontend_slm_explicit_placement_19832_test.py
  • repo_tests/proxy_upload_cap_one_home_19868_test.py
  • repo_tests/slm_manager_tls_port_redirect_and_proxies_19832_test.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@mrveiss mrveiss added the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 22, 2026
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 22, 2026
@mrveiss mrveiss added the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) phase:M1.4 Wizard and SLM: choose a mode, apply it, default models work

Projects

None yet

1 participant