Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/nightly-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ on:
description: >-
Comma-separated job names to run (empty = all).
Valid: cloud-e2e, cloud-onboard-e2e, cloud-inference-e2e,
cron-preflight-inference-local-e2e,
agent-turn-latency-e2e, skill-agent-e2e, openclaw-skill-cli-e2e,
docs-validation-e2e, messaging-providers-e2e, openclaw-slack-pairing-e2e,
openclaw-tui-chat-correlation-e2e, issue-4434-tui-unreachable-inference-e2e,
Expand Down Expand Up @@ -239,6 +240,21 @@ jobs:
env_json: '{"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE":"1","NEMOCLAW_NON_INTERACTIVE":"1","NEMOCLAW_RECREATE_SANDBOX":"1","NEMOCLAW_SANDBOX_NAME":"e2e-cloud-inference"}'
nvidia_api_key: true
secrets: *nightly-e2e-default-secrets
cron-preflight-inference-local-e2e:
if: >-
github.repository == 'NVIDIA/NemoClaw' && (github.event_name != 'workflow_dispatch' ||
inputs.jobs == '' ||
contains(format(',{0},', inputs.jobs), ',cron-preflight-inference-local-e2e,'))
uses: ./.github/workflows/e2e-script.yaml
with:
ref: ${{ inputs.target_ref || github.ref }}
script: test/e2e/test-cron-preflight-inference-local-e2e.sh
timeout_minutes: 30
artifact_name: "install-log-cron-preflight-inference-local"
artifact_path: "/tmp/nemoclaw-e2e-cron-preflight-install.log"
env_json: '{"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE":"1","NEMOCLAW_NON_INTERACTIVE":"1","NEMOCLAW_RECREATE_SANDBOX":"1","NEMOCLAW_SANDBOX_NAME":"e2e-cron-preflight"}'
nvidia_api_key: true
secrets: *nightly-e2e-default-secrets
agent-turn-latency-e2e:
if: >-
github.repository == 'NVIDIA/NemoClaw' && (github.event_name != 'workflow_dispatch' ||
Expand Down
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,44 @@ RUN set -eu; \
patch_fail "Patch 4 cannot safely skip"; \
fi; \
fi; \
# --- Patch 5: cron model-provider preflight opts into trusted env-proxy mode --- \
# Reviewed against openclaw@2026.5.27 dist: the cron isolated-agent preflight \
# (`probeLocalProviderEndpoint`) calls `fetchWithSsrFGuard` with \
# `auditContext: "cron-model-provider-preflight"` and a narrow hostname-allowlist \
# SsrFPolicy, but does not pass a `mode`. Default STRICT mode pins DNS for the \
# managed inference hostname (`inference.local`), which is intentionally only \
# resolvable through the OpenShell L7 proxy — pinned `dns.lookup` therefore \
# fails with EAI_AGAIN and the scheduler permanently skips every cron run. \
# Inject `mode: "trusted_env_proxy"` so the call uses the env proxy dispatcher; \
# SSRF protection is retained through the existing hostname allowlist and the \
# proxy's own ACLs. Scoped to the exact audit-context string; other \
# `fetchWithSsrFGuard` callers are untouched. \
preflight_files="$(grep -RIlF --include='*.js' 'cron-model-provider-preflight' "$OC_DIST" || true)"; \
if [ -n "$preflight_files" ]; then \
patched_preflight=0; \
for f in $preflight_files; do \
if grep -Fq 'mode: "trusted_env_proxy", auditContext: "cron-model-provider-preflight"' "$f"; then \
echo "INFO: Patch 5 already present in $f"; \
else \
sed -i -E 's|auditContext: "cron-model-provider-preflight"|mode: "trusted_env_proxy", auditContext: "cron-model-provider-preflight"|g' "$f"; \
grep -Fq 'mode: "trusted_env_proxy", auditContext: "cron-model-provider-preflight"' "$f" \
|| patch_fail "Patch 5 verification failed for $f"; \
patched_preflight=1; \
fi; \
done; \
if [ "$patched_preflight" = "1" ]; then \
echo "INFO: Patch 5 applied to OpenClaw ${OC_VERSION} cron preflight trusted env-proxy"; \
fi; \
else \
preflight_refs="$(grep -RIlE --include='*.js' 'preflightCronModelProvider|probeLocalProviderEndpoint' "$OC_DIST" || true)"; \
if [ -z "$preflight_refs" ]; then \
echo "INFO: OpenClaw ${OC_VERSION} has no cron model-provider preflight; Patch 5 not needed"; \
else \
echo "ERROR: Patch 5 target missing but cron preflight references remain:" >&2; \
printf '%s\n' "$preflight_refs" | head -n 5 >&2; \
patch_fail "Patch 5 cannot safely skip"; \
fi; \
fi; \
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
# --- Patch 3: follow symlinks in plugin-install path checks (#2203) --- \
# OpenClaw's install-safe-path and install-package-dir reject symlinked \
# directories via lstat. Changing lstat → stat in these two modules lets \
Expand Down
186 changes: 186 additions & 0 deletions test/e2e/test-cron-preflight-inference-local-e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Cron preflight inference.local E2E.
#
# Onboards a fresh sandbox against the managed cloud provider (whose base URL
# resolves through `inference.local`), schedules an isolated agentTurn cron
# job, force-triggers it via `openclaw cron run --wait`, and asserts the
# provider preflight does not skip the run with `EAI_AGAIN` or the
# "local provider endpoint is not reachable" message.
#
# Prerequisites:
# - Docker running
# - NVIDIA_API_KEY set (real key, starts with nvapi-)
# - NEMOCLAW_NON_INTERACTIVE=1, NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1
#
# Environment:
# NEMOCLAW_SANDBOX_NAME — sandbox name (default: e2e-cron-preflight)
# NEMOCLAW_RECREATE_SANDBOX=1 — destroy + recreate if exists
# NEMOCLAW_CRON_PREFLIGHT_MODEL — cloud model (default: nvidia/nemotron-3-super-120b-a12b)
# NEMOCLAW_CRON_PREFLIGHT_WAIT — --wait-timeout for cron run (default: 90s)
# NEMOCLAW_CRON_PREFLIGHT_KEEP=1 — keep the sandbox after the test for inspection
#
# Usage:
# NEMOCLAW_NON_INTERACTIVE=1 NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 \
# NVIDIA_API_KEY=nvapi-... bash test/e2e/test-cron-preflight-inference-local-e2e.sh

set -uo pipefail

PASS=0
FAIL=0
SKIP=0
TOTAL=0

pass() {
PASS=$((PASS + 1))
TOTAL=$((TOTAL + 1))
printf '\033[32m PASS: %s\033[0m\n' "$1"
}
fail() {
FAIL=$((FAIL + 1))
TOTAL=$((TOTAL + 1))
printf '\033[31m FAIL: %s\033[0m\n' "$1"
}
skip() {
SKIP=$((SKIP + 1))
TOTAL=$((TOTAL + 1))
printf '\033[33m SKIP: %s\033[0m\n' "$1"
}
section() {
echo ""
printf '\033[1;36m=== %s ===\033[0m\n' "$1"
}
info() { printf '\033[1;34m [info]\033[0m %s\n' "$1"; }

# ── Repo root ──
_script_dir="$(cd "$(dirname "$0")" && pwd)"
_candidate="$(cd "${_script_dir}/../.." && pwd)"
if [ -d /workspace ] && [ -f /workspace/package.json ] && [ -d /workspace/test/e2e ]; then
REPO="/workspace"
elif [ -f "${_candidate}/package.json" ] && [ -d "${_candidate}/test/e2e" ]; then
REPO="${_candidate}"
else
echo "ERROR: Cannot find repo root."
exit 1
fi
cd "$REPO" || {
echo "ERROR: Cannot cd into repo root '$REPO'."
exit 1
}

SANDBOX="${NEMOCLAW_SANDBOX_NAME:-e2e-cron-preflight}"
MODEL="${NEMOCLAW_CRON_PREFLIGHT_MODEL:-nvidia/nemotron-3-super-120b-a12b}"
WAIT_TIMEOUT="${NEMOCLAW_CRON_PREFLIGHT_WAIT:-90s}"

# ── Prereqs ──
section "Prerequisites"
if ! command -v docker >/dev/null 2>&1; then
skip "docker not installed"
echo " Total: $TOTAL Pass: $PASS Fail: $FAIL Skip: $SKIP"
exit 0
fi
if ! command -v jq >/dev/null 2>&1; then
skip "jq not installed"
echo " Total: $TOTAL Pass: $PASS Fail: $FAIL Skip: $SKIP"
exit 0
fi
if [ -z "${NVIDIA_API_KEY:-}" ]; then
skip "NVIDIA_API_KEY not set"
echo " Total: $TOTAL Pass: $PASS Fail: $FAIL Skip: $SKIP"
exit 0
fi
if [ "${NVIDIA_API_KEY:0:6}" != "nvapi-" ]; then
skip "NVIDIA_API_KEY does not start with nvapi-"
echo " Total: $TOTAL Pass: $PASS Fail: $FAIL Skip: $SKIP"
exit 0
fi
pass "prerequisites satisfied"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

# shellcheck disable=SC2317 # invoked via trap
cleanup() {
if [ "${NEMOCLAW_CRON_PREFLIGHT_KEEP:-0}" = "1" ]; then
info "NEMOCLAW_CRON_PREFLIGHT_KEEP=1 set; leaving sandbox $SANDBOX in place"
return
fi
info "destroying sandbox $SANDBOX"
nemoclaw "$SANDBOX" destroy --yes >/dev/null 2>&1 || true
}
trap cleanup EXIT

# ── Onboard ──
section "Onboard sandbox '$SANDBOX'"
if [ "${NEMOCLAW_RECREATE_SANDBOX:-0}" = "1" ]; then
info "NEMOCLAW_RECREATE_SANDBOX=1 set; destroying existing sandbox first"
nemoclaw "$SANDBOX" destroy --yes >/dev/null 2>&1 || true
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

NEMOCLAW_SANDBOX_NAME="$SANDBOX" nemoclaw onboard \
--provider build \
--model "$MODEL" 2>&1 | sed 's/^/ /'
ONBOARD_RC=${PIPESTATUS[0]}
if [ "$ONBOARD_RC" -ne 0 ]; then
fail "onboard exited $ONBOARD_RC"
echo " Total: $TOTAL Pass: $PASS Fail: $FAIL Skip: $SKIP"
exit 1
fi
pass "onboard completed"

# ── Schedule cron job ──
section "Schedule isolated agentTurn cron job"
JOB_NAME="preflight-$(date +%s)"
ADD_OUT="$(nemoclaw "$SANDBOX" exec -- openclaw cron add \
--name "$JOB_NAME" \
--agent main \
--session isolated \
--every 12h \
--message "Reply with the single word: ok." \
--keep-after-run \
--json 2>&1)"
ADD_RC=$?
if [ "$ADD_RC" -ne 0 ]; then
fail "cron add exited $ADD_RC"
printf '%s\n' "$ADD_OUT" | sed 's/^/ /'
echo " Total: $TOTAL Pass: $PASS Fail: $FAIL Skip: $SKIP"
exit 1
fi

JOB_ID="$(printf '%s' "$ADD_OUT" | jq -r '.id // empty' 2>/dev/null || true)"
if [ -z "$JOB_ID" ]; then
fail "cron add returned no id"
printf '%s\n' "$ADD_OUT" | sed 's/^/ /'
echo " Total: $TOTAL Pass: $PASS Fail: $FAIL Skip: $SKIP"
exit 1
fi
pass "scheduled job $JOB_NAME ($JOB_ID)"

# ── Force-trigger + wait ──
section "Force-trigger and wait"
RUN_OUT="$(nemoclaw "$SANDBOX" exec -- openclaw cron run "$JOB_ID" \
--wait --wait-timeout "$WAIT_TIMEOUT" --json 2>&1)"
RUN_RC=$?
info "raw cron run output (rc=$RUN_RC):"
printf '%s\n' "$RUN_OUT" | sed 's/^/ /'

STATUS="$(printf '%s' "$RUN_OUT" | jq -r '.run.status // .status // empty' 2>/dev/null || true)"
REASON="$(printf '%s' "$RUN_OUT" | jq -r '.run.reason // .reason // ""' 2>/dev/null || true)"

# ── Assertions ──
section "Assertions"
if printf '%s' "$REASON" | grep -qi "EAI_AGAIN"; then
fail "preflight raised EAI_AGAIN; reason='$REASON'"
elif printf '%s' "$REASON" | grep -qi "local provider endpoint is not reachable"; then
fail "preflight reported endpoint unreachable; reason='$REASON'"
elif [ "$STATUS" = "skipped" ]; then
fail "cron run reported status=skipped; reason='$REASON'"
elif [ "$STATUS" = "ok" ]; then
pass "cron run status=ok"
else
fail "unexpected cron run status='$STATUS' rc=$RUN_RC reason='$REASON'"
fi

section "Summary"
echo " Total: $TOTAL Pass: $PASS Fail: $FAIL Skip: $SKIP"
[ "$FAIL" -eq 0 ] || exit 1
exit 0
Loading