fix gateway_wait script for hermes#1931
Merged
Merged
Conversation
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Hermes “gateway wait” logic by moving the wait snippet into an embedded shell template and changing execution to feed the script via stdin (instead of sh -c), improving how the script is transported/executed inside the sandbox.
Changes:
- Adds an embedded
gateway_wait.shtemplate and renders it viatext/templatein Go. - Updates Hermes bootstrap to execute the wait script using
sh -swith stdin content. - Keeps existing diagnostics output on timeout (ss output + gateway log tail).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| go/core/pkg/sandboxbackend/openshell/hermes/gateway_wait.sh | New embedded shell script template that polls ss for the Hermes gateway listener and prints diagnostics on timeout. |
| go/core/pkg/sandboxbackend/openshell/hermes/gateway_wait.go | Switches script generation from fmt.Sprintf to an embedded text/template. |
| go/core/pkg/sandboxbackend/openshell/hermes.go | Runs the wait script via stdin (sh -s) instead of passing it via sh -c. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo '--- ss -tln ---' >&2 | ||
| ss -tln 2>&1 | head -20 >&2 || true | ||
| echo '--- tail /tmp/gateway.log ---' >&2 | ||
| tail -n 40 /tmp/gateway.log 2>&1 >&2 || echo '(no /tmp/gateway.log)' >&2 |
Comment on lines
+16
to
+20
| func GatewayListenWaitScript(port int) string { | ||
| return fmt.Sprintf(`listen='127.0.0.1:%d' | ||
| if ! command -v ss >/dev/null 2>&1; then | ||
| echo 'hermes gateway wait: ss not found in PATH' >&2 | ||
| exit 2 | ||
| fi | ||
| for i in $(seq 1 30); do | ||
| if ss -tln 2>/dev/null | grep -qF "$listen"; then | ||
| exit 0 | ||
| fi | ||
| sleep 1 | ||
| done | ||
| echo "hermes gateway wait: timed out after 30s waiting for $listen" >&2 | ||
| echo '--- ss -tln ---' >&2 | ||
| ss -tln 2>&1 | head -20 >&2 || true | ||
| echo '--- tail /tmp/gateway.log ---' >&2 | ||
| tail -n 40 /tmp/gateway.log 2>&1 >&2 || echo '(no /tmp/gateway.log)' >&2 | ||
| exit 1 | ||
| `, port) | ||
| var out bytes.Buffer | ||
| if err := gatewayListenWaitTemplate.Execute(&out, struct{ Port int }{Port: port}); err != nil { | ||
| panic(err) | ||
| } |
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
f975fb4 to
eece533
Compare
EItanya
approved these changes
May 27, 2026
EItanya
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.