Repository navigation
🔧 chore: Allow harness URL override - #589
Conversation
Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
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)
| # 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}" |
There was a problem hiding this comment.
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.
| 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-}" ]] || |
There was a problem hiding this comment.
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.
| 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]}" |
There was a problem hiding this comment.
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.
| 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' |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
|
Thanks — addressed in
Tests |
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
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.
| 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)" |
There was a problem hiding this comment.
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.
| - `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, |
There was a problem hiding this comment.
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]>
Signed-off-by: Evaline Ju <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
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
Summary
Lets operators override
SH_PUBLIC_HARNESS_URLon port-forward-reached targets, so a local 8080 collision no longer blocks the deploy. Closes #584Checklist
git commit -s).make lintand the tests for the touched packages pass.docs/page, with the right maturity label (seedocs/CONTRIBUTING-DOCS.md).make check-linkspasses if any Markdown changed.docs/specs/README.mdordocs/adrs/README.md- N/A