Skip to content

fix gateway_wait script for hermes#1931

Merged
EItanya merged 2 commits into
mainfrom
peterj/fixgatewaywait
May 27, 2026
Merged

fix gateway_wait script for hermes#1931
EItanya merged 2 commits into
mainfrom
peterj/fixgatewaywait

Conversation

@peterj
Copy link
Copy Markdown
Collaborator

@peterj peterj commented May 26, 2026

No description provided.

Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
Copilot AI review requested due to automatic review settings May 26, 2026 23:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.sh template and renders it via text/template in Go.
  • Updates Hermes bootstrap to execute the wait script using sh -s with 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>
@peterj peterj force-pushed the peterj/fixgatewaywait branch from f975fb4 to eece533 Compare May 27, 2026 00:19
@EItanya EItanya merged commit 88a4bc7 into main May 27, 2026
23 checks passed
@EItanya EItanya deleted the peterj/fixgatewaywait branch May 27, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants