Skip to content

🔧 chore: Allow harness URL override - #589

Merged
pdettori merged 8 commits into
rossoctl:mainfrom
evaline-ju:port-override
Oct 22, 2026
Merged

pdettori merged 8 commits into
rossoctl:mainfrom
evaline-ju:port-override

Conversation

@evaline-ju

Copy link
Copy Markdown
Contributor

Summary

Lets operators override SH_PUBLIC_HARNESS_URL on port-forward-reached targets, so a local 8080 collision no longer blocks the deploy. Closes #584

Checklist

  • Commits are signed off (git commit -s).
  • make lint and the tests for the touched packages pass.
  • Docs: changed behavior, flags or environment variables are reflected in the relevant README or
    docs/ page, with the right maturity label (see docs/CONTRIBUTING-DOCS.md).
  • Docs: make check-links passes if any Markdown changed.
  • A new spec or ADR is registered in docs/specs/README.md or docs/adrs/README.md - N/A

Signed-off-by: Evaline Ju <[email protected]>
@evaline-ju evaline-ju added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 22, 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

The PR lets setup.sh take SH_PUBLIC_HARNESS_URL on port-forward-reached targets (kind, ocp-single without Routes) and prints the matching supervisor port-forward port. Closes #584. The approach is right and CI is green. One must-fix: the override isn't sticky like every other setup.sh input, so the next plain re-run puts 8080 back and the #584 collision returns. Also suggested: the Route-refusal check misses a stored SH_ROUTE_DOMAIN, the URL/port parse is loose, and ocp-single and re-run tests are missing.

Outside the diff: deploy/k8s/README.md L114-115 still says "The control plane advertises the harness as http://127.0.0.1:8080, so the supervisor's forward must use local port 8080". A pointer to the new override there would help.

Author: evaline-ju (MEMBER — maintainer)
Areas reviewed: Shell, Docs, Tests, Security
Agent/IDE config (.claude/.vscode): none
Commits: 3 commits, all signed-off: yes (subjects have an emoji but no conventional prefix: advisory nit only)
CI status: passing (all 15 checks, incl. deploy-scripts and k8s-kind-e2e)

Comment thread deploy/k8s/setup.sh Outdated
# SH_PUBLIC_HARNESS_URL overrides the default on port-forward targets, so an operator with a local
# 8080 conflict can advertise a different localhost port (parse_args validates it).
if is_kind || ([[ "$TARGET" == ocp-single ]] && [[ -z "$ROUTE_DOMAIN" ]]); then
echo "${SH_PUBLIC_HARNESS_URL:-http://127.0.0.1:8080}"

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 — the override is not sticky, so a plain re-run silently reverts it. ${SH_PUBLIC_HARNESS_URL:-http://127.0.0.1:8080} only sees the environment. Re-running setup.sh --target kind without the variable (to pick up a new image, say) writes http://127.0.0.1:8080 back into moca-settings, rolls the control plane, and brings back the exact #584 collision. The new write_settings comment (L732) calls this "an input". The header (L29) says every input is sticky: unset keeps the stored value, set-but-empty clears it. Suggest resolving it like the other inputs in write_settings, e.g. if [[ -n "${SH_PUBLIC_HARNESS_URL+x}" ]]; then url="$SH_PUBLIC_HARNESS_URL"; else url="$(cm_value "$before" SH_PUBLIC_HARNESS_URL)"; fi, used only on the port-forward branch. Then make print_access use the same resolved value. Either that, or document explicitly that it must be passed on every run, and add it to the L29 list either way.

Comment thread deploy/k8s/setup.sh Outdated
if [[ -n "${SH_PUBLIC_HARNESS_URL-}" ]]; then
[[ "$SH_PUBLIC_HARNESS_URL" =~ ^https?://[^[:space:]]+$ ]] ||
die "SH_PUBLIC_HARNESS_URL='$SH_PUBLIC_HARNESS_URL' must be an http(s) URL"
is_kind || [[ "$TARGET" == ocp-single && -z "${SH_ROUTE_DOMAIN-}" ]] ||

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 — this Route check reads SH_ROUTE_DOMAIN from the environment, but on ocp-single the domain is sticky and only resolved in load_setup_inputs (L472). The --tls-cert/--tls-secret checks above are deferred for exactly this reason. Take an ocp-single stack that already has Routes, re-run with SH_PUBLIC_HARNESS_URL=… and no SH_ROUTE_DOMAIN: the check passes here, then public_harness_url takes the Route branch and quietly ignores the given URL. The README says it is "refused". Suggest moving the Route half of this check into load_setup_inputs, after ROUTE_DOMAIN is resolved and before moca-setup is applied.

Comment thread deploy/k8s/setup.sh
print_access() {
# The local port of the supervisor's port-forward: honor SH_PUBLIC_HARNESS_URL's port when given.
local sup_port=8080
[[ "$(public_harness_url)" =~ :([0-9]+)/?$ ]] && sup_port="${BASH_REMATCH[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 — :([0-9]+)/?$ falls back to 8080 for any URL with a path (http://127.0.0.1:18080/x) and for a URL with no explicit port. In both cases the printed port-forward no longer matches what discovery advertises. The supervisor is plain HTTP behind a byte-stream port-forward, so an https:// override can't work on these targets either. Suggest tightening the parse_args check (L182) to what the feature supports, e.g. ^http://[^/[:space:]]+:[0-9]{1,5}/?$. That way this extraction always matches.

Comment thread deploy/k8s/tests/setup.test.sh Outdated
reset_state
(export SH_PUBLIC_HARNESS_URL=not-a-url; expect_fail --target kind --skip-build)
expect_out 'must be an http(s) URL'
pass 'kind: a non-URL SH_PUBLIC_HARNESS_URL is refused up front'

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 — the tests cover kind only. Worth adding: (1) a re-run without the variable keeps the stored URL (this catches the stickiness issue on public_harness_url), (2) --target ocp-single without Routes accepts it and prints the custom port, (3) ocp-single with SH_ROUTE_DOMAIN refuses it, both given and stored.

Comment thread deploy/k8s/setup.sh Outdated
if [[ -n "$ROUTE_DOMAIN" ]]; then echo "https://moca.$ROUTE_DOMAIN"; else echo 'http://127.0.0.1:8080'; fi
# SH_PUBLIC_HARNESS_URL overrides the default on port-forward targets, so an operator with a local
# 8080 conflict can advertise a different localhost port (parse_args validates it).
if is_kind || ([[ "$TARGET" == ocp-single ]] && [[ -z "$ROUTE_DOMAIN" ]]); then

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 ( … ) forks a subshell, and the elif [[ "$TARGET" == ocp-single ]] below now duplicates the first test. if is_kind || [[ "$TARGET" == ocp-single && -z "$ROUTE_DOMAIN" ]]; then … elif [[ "$TARGET" == ocp-single ]] reads the same without the fork. The same expression already appears in parse_args L184.

@evaline-ju

Copy link
Copy Markdown
Contributor Author

Thanks — addressed in d8d0b56:

  • must-fix: sticky. SH_PUBLIC_HARNESS_URL now follows the same unset/set-empty convention as every other sticky input. public_harness_url reads moca-settings via cm_value when the env var is unset, so a plain re-run keeps the stored value and print_access prints the matching port-forward port. write_settings consumes the resolved URL via a local url= instead of calling public_harness_url inline. The sticky-settings docblock is updated to describe the new behavior.
  • suggestion: Route refusal. Moved out of parse_args into load_setup_inputs, right after ROUTE_DOMAIN is resolved (sticky-aware). parse_args keeps only the shape check and the target gate. A stored SH_ROUTE_DOMAIN now triggers the refusal just as a given one does.
  • suggestion: URL parse. Tightened to ^http://HOST:PORT/?$. https, missing-port, and path-bearing URLs are now refused up front — matching what the port-forward can actually serve. The error message names the required shape.
  • suggestion: tests. Four new test blocks: kind sticky (re-run keeps + set-empty clears), URL-shape rejection (4 variants: non-URL, https, missing port, path), ocp-single without Routes accepts the override, ocp-single with Routes refuses (given and stored).
  • nit: subshell fork. Dropped the ( … ) in public_harness_url; now a flat [[ … && … ]].
  • outside-diff: README cross-ref. deploy/k8s/README.md L114 now notes the SH_PUBLIC_HARNESS_URL override alongside the "forward must use local port 8080" line and points at §2's sticky settings for the override's semantics.

Tests bash deploy/k8s/tests/setup.test.sh pass end-to-end; CI is passing.

@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 to our review at a991f40: all five earlier items are addressed (stickiness, stored-domain refusal moved to load_setup_inputs, tight URL shape, ocp-single tests, subshell nit), and CI is green.

One regression from the new stickiness. On ocp-single with Routes on, moca-settings holds the Route URL (https://moca.<domain>). When the operator turns Routes off with SH_ROUTE_DOMAIN=, public_harness_url reuses that stored value. Discovery then advertises the dead Route host, and print_access falls back to port 8080. The existing test for that transition (setup.test.sh:939-944) only checks the printed port-forward line. Asserting that moca-settings' SH_PUBLIC_HARNESS_URL is http://127.0.0.1:8080 after that run would catch it.

Re-checked at 2c58c57 (comment-only commit): the stale parse_args refuses comment at setup.sh:747 is fixed, so that nit is dropped. The must-fix and README nit below still apply.

Comment thread deploy/k8s/setup.sh
echo "${SH_PUBLIC_HARNESS_URL:-http://127.0.0.1:8080}"
else
local stored
stored="$(cm_value "$(configmap_json moca-settings)" SH_PUBLIC_HARNESS_URL)"

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 — the stored value can be a Route URL. With Routes on, write_settings stores https://moca.<domain> in moca-settings. Re-run with SH_ROUTE_DOMAIN= (Routes off, documented in README §12) and no SH_PUBLIC_HARNESS_URL: this branch reads that stored value back. /v1/discovery then advertises a Route that no longer exists, and print_access prints 8080 because :([0-9]+)/?$ doesn't match, so mocactl can't reach the harness. Suggest only reusing a stored value that has the port-forward shape parse_args enforces, e.g. [[ "$stored" =~ ^http://[^/[:space:]]+:[0-9]{1,5}/?$ ]] || stored='', then fall back to the default. The test at setup.test.sh:939 covers this transition but only checks the printed port-forward. Asserting the stored URL there would catch it.

Comment thread deploy/k8s/README.md Outdated
- `SH_PUBLIC_HARNESS_URL` (kind and `--target ocp-single` without Routes) overrides the default
`http://127.0.0.1:8080` the control plane advertises via `GET /v1/discovery`; set it when 8080
conflicts with another local service. The port in the URL also becomes the printed `kubectl
port-forward svc/moca-supervisor` local port. Must be http(s); refused on Route-reached stacks,

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 — still says "Must be http(s)" and doesn't mention the override is sticky. Now it's http://HOST:PORT only, and also refused under a stored SH_ROUTE_DOMAIN. Suggest: "Must be http://HOST:PORT (no https, no path). Sticky like the others: SH_PUBLIC_HARNESS_URL= returns to 8080. Refused when Routes are on."

Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[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 to the review at b09dd65. The new commit (696f669, signed off) fixes the must-fix: the port-forward svc/moca-supervisor continuation in deploy/k8s/README.md now passes prettier 3.9.10 --check (verified locally with the repo config), and lint is green — all 15 checks pass.

Still open, non-blocking: the PUBLIC_HARNESS_URL memo in public_harness_url (setup.sh:718) never takes effect because both callers use $(...), so the "one kubectl get per run" comment is inaccurate. Fine as a follow-up.

LGTM.

Author: evaline-ju (MEMBER — maintainer)
Areas reviewed: Docs (incremental b09dd65..696f669)
Agent/IDE config (.claude/.vscode): none
Commits: 8 commits, all signed-off: yes
CI status: all 15 checks passing

@pdettori
pdettori merged commit 969de3b into rossoctl:main Oct 22, 2026
15 checks passed
@evaline-ju
evaline-ju deleted the port-override branch October 22, 2026 21:53
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.

deploy/k8s hardcodes SH_PUBLIC_HARNESS_URL to 127.0.0.1:8080; cannot override for local port conflicts

3 participants