Skip to content

deploy: set SH_MODEL_CATALOG_HOSTS through setup.sh into moca-settings - #575

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:setup-model-catalog-hosts
Oct 22, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:setup-model-catalog-hosts

Conversation

@pdettori

Copy link
Copy Markdown
Member

What

deploy/k8s/setup.sh now takes SH_MODEL_CATALOG_HOSTS as a sticky input, like the token lifetimes:

  • Written to moca-settings on every run (even when empty, so every stack hashes the same nine keys) and read by the control plane through an optional configMapKeyRef in base/control-plane.yaml; a change rolls the control plane through the existing SETTINGS_HASH stamp.
  • Sticky: unset on a re-run keeps the stored value; set to empty clears it (back to api.anthropic.com + the default inference endpoint only).
  • Validated in parse_args (given) and write_settings (stored): comma-separated bare hostnames only — a scheme, port or path is refused before anything touches the cluster, mirroring main.ts catalogHostsEnv, which the control plane would otherwise refuse to boot on after the apply.

Why

The k8s manifests never wired the catalog allow-list (compose and the VM env examples got it in 7085b51; k8s did not), so an operator had to kubectl set env the control plane Deployment by hand — and the next setup.sh run would silently drop the patch. Without the allow-list, per-session model listing degrades to model_catalog_unavailable (ids are still accepted unverified).

Usage

SH_MODEL_CATALOG_HOSTS=litellm.team-a.svc,gw.example.com \
  deploy/k8s/setup.sh --target ocp-single --image … --sandbox-image …

README §"Inputs are sticky" documents it alongside the other moca-settings inputs.

Testing

  • deploy/k8s/tests/setup.test.sh: new blocks mirroring the token-lifetime tests — sticky keep, empty clears, hash changes on a change (the roll), malformed values refused both given (before any kubectl apply) and stored; the eight-keys assertions updated to nine. All pass.
  • shellcheck -x -S warning (the pre-commit/CI severity) clean on both changed scripts.

🤖 Generated with Claude Code

The k8s manifests never wired the model catalog allow-list (compose and the
VM env examples have it, from 7085b51), so an operator had to patch the
control plane Deployment by hand -- and a re-run of setup.sh would drop the
patch. SH_MODEL_CATALOG_HOSTS is now a sticky input like the token
lifetimes: written to moca-settings (even when empty, so every stack hashes
the same nine keys), read by the control plane through an optional
configMapKeyRef, and rolled by the SETTINGS_HASH stamp.

Entries are validated in parse_args and write_settings -- bare hostnames
only, mirroring main.ts catalogHostsEnv, which the control plane would
otherwise refuse to boot on after the apply.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori requested a review from cwiklik as a code owner October 21, 2026 20:35
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 21, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

This PR wires SH_MODEL_CATALOG_HOSTS through deploy/k8s/setup.sh into moca-settings. The control plane reads it with an optional configMapKeyRef, and it follows the same sticky/clear/hash-roll pattern as the token TTLs. Values are validated before anything is applied. The logic, README and tests look right, and the new key is in the SETTINGS_HASH input, so a change rolls the control plane. One blocker: the lint check fails because Prettier reformats the new valueFrom line in control-plane.yaml. There is also a small validation gap (an embedded newline) that would still let a bad value crashloop the control plane.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Shell, YAML/K8s, Docs, Tests
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: failing (lint: prettier on control-plane.yaml:95). check was still running when this was drafted. Everything else passes, including deploy-scripts (setup.test.sh), shellcheck and k8s-kind-e2e.

Comment thread deploy/k8s/base/control-plane.yaml Outdated
# the entries, which the control plane would otherwise refuse to boot on.
- name: SH_MODEL_CATALOG_HOSTS
valueFrom:
{ configMapKeyRef: { name: moca-settings, key: SH_MODEL_CATALOG_HOSTS, optional: true } }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

must-fix — this line is why the lint check is red (pre-commit prettier hook, "Run hooks" step). It is 105 chars, over printWidth: 100, and Prettier 3.9.10 (the repo's pinned version) rewrites it as:

              valueFrom:
                {
                  configMapKeyRef:
                    { name: moca-settings, key: SH_MODEL_CATALOG_HOSTS, optional: true },
                }

SH_SANDBOX_DEFAULT_TIER above already uses that shape (line 72-75). Running pnpm exec prettier --write deploy/k8s/base/control-plane.yaml (or make fmt) fixes it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 2d3080f — the multi-line shape, and [email protected] --check now passes on the file.

Comment thread deploy/k8s/setup.sh
valid_catalog_hosts() {
local raw h
[[ -z "$1" ]] && return 0
IFS=',' read -r -a _vch_parts <<<"$1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion — a value with an embedded newline gets past this check but not past the control plane's. read -r reads only the first line, so SH_MODEL_CATALOG_HOSTS=$'gw.example.com\nhttps://x' validates as gw.example.com, the whole string is written to moca-settings, and catalogHostsEnv (which splits on , only and trims only the ends) then fails at boot, because URL.parse drops the \n and the hostname comparison fails. That is the crashloop-after-apply this check is meant to prevent. It applies to both callers (given and stored). Rejecting it up front closes the gap: [[ "$1" == *$'\n'* ]] && return 1. A test case for it would fit in the for bad in … loop.

Also a nit: _vch_parts isn't declared local, so it leaks into the global scope of a script that other code sources (SH_SOURCE_ONLY=1). Use local raw h; local -a _vch_parts.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 2d3080f — *$'\''\n''* is rejected up front in valid_catalog_hosts (before the read -r), for a given value and a stored one alike, with a test in both paths. _vch_parts is local -a now too.

Comment thread deploy/k8s/setup.sh Outdated
# valid_catalog_hosts VALUE: empty (the control plane's default, no extra hosts) or comma-separated
# bare hostnames. Mirrors main.ts catalogHostsEnv, which trims, lower-cases and skips empty entries
# but refuses a scheme, port, path or userinfo at BOOT; this keeps to [A-Za-z0-9.-] per entry,
# which covers every real hostname and none of what that check refuses.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit — the comment says this check covers "none of what that check refuses", and that's true. It is also stricter than catalogHostsEnv in two places: an underscore (a_b.svc) and a trailing-dot FQDN (gw.example.com.) both pass URL.parse in the control plane but are refused here. Neither is likely for a real gateway, and k8s Service names can't contain _. Still, one clause in the comment ("and is stricter: no _, no trailing dot") would stop a later reader from assuming the two checks are equivalent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 2d3080f — the comment now states the check is stricter than catalogHostsEnv (no _, no trailing dot, both of which URL.parse would take) and why stricter is the safe side.

- control-plane.yaml: the SH_MODEL_CATALOG_HOSTS valueFrom line was 105
  chars, over printWidth 100; the multi-line shape Prettier 3.9.10 writes.
- valid_catalog_hosts: read -r reads only the first line, so a value with
  an embedded newline validated as that line while catalogHostsEnv refuses
  the whole string at boot. Rejected up front now, given or stored, with a
  test in both paths.
- _vch_parts declared local -a (the script is sourced by SH_SOURCE_ONLY=1
  callers); the doc comment now says this check is stricter than
  catalogHostsEnv (no `_`, no trailing dot) rather than equivalent.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow-up at 2d3080f: all three items from the 5615ffd review are addressed — the control-plane.yaml valueFrom now has Prettier's multi-line shape (prettier 3.9.10 --check passes locally), valid_catalog_hosts rejects an embedded newline up front with tests for both the given and the stored value, _vch_parts is local -a, and the comment notes the check is stricter than catalogHostsEnv. LGTM.

@pdettori
pdettori merged commit d519432 into rossoctl:main Oct 22, 2026
15 checks passed
@pdettori
pdettori deleted the setup-model-catalog-hosts branch October 22, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants