-
Notifications
You must be signed in to change notification settings - Fork 2.3k
test: add real runAgentInSandbox() E2E tests for telegram injection (Phases 7-11) #1219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
fba1ab0
3f376eb
0e11c49
25e3a4e
ab80478
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,8 +37,29 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | |
| export NEEDRESTART_MODE=a | ||
| export DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Wait for any existing apt locks (e.g. Brev's own provisioning on boot) | ||
| wait_for_apt() { | ||
| local max_wait=300 # 5 minutes | ||
| local waited=0 | ||
| while fuser /var/lib/dpkg/lock-frontend /var/lib/apt/lists/lock /var/cache/apt/archives/lock >/dev/null 2>&1; do | ||
| if [ $waited -ge $max_wait ]; then | ||
| fail "apt lock still held after ${max_wait}s — another process is stuck" | ||
| fi | ||
| info "Waiting for apt lock to be released... (${waited}s)" | ||
| sleep 10 | ||
| waited=$((waited + 10)) | ||
| done | ||
| # Wait for any apt processes to fully exit — locks can be released | ||
| # momentarily between apt operations in a multi-step provisioning sequence | ||
| while pgrep -x "apt-get\|apt\|dpkg" >/dev/null 2>&1; do | ||
| info "Waiting for apt/dpkg processes to finish..." | ||
| sleep 5 | ||
| done | ||
| } | ||
|
|
||
| # --- 0. Node.js (needed for services) --- | ||
| if ! command -v node >/dev/null 2>&1; then | ||
| wait_for_apt | ||
| info "Installing Node.js..." | ||
| NODESOURCE_URL="https://deb.nodesource.com/setup_22.x" | ||
| NODESOURCE_SHA256="575583bbac2fccc0b5edd0dbc03e222d9f9dc8d724da996d22754d6411104fd1" | ||
|
|
@@ -55,27 +76,44 @@ if ! command -v node >/dev/null 2>&1; then | |
| else | ||
| fail "No SHA-256 verification tool found (need sha256sum or shasum)" | ||
| fi | ||
| sudo -E bash "$tmpdir/setup_node.sh" >/dev/null 2>&1 | ||
| sudo -E bash "$tmpdir/setup_node.sh" | ||
| ) | ||
| sudo apt-get install -y -qq nodejs >/dev/null 2>&1 | ||
| # Retry apt-get install — Brev provisioning can grab the lock between operations | ||
| for attempt in 1 2 3 4 5; do | ||
| wait_for_apt | ||
| if sudo apt-get install -y -qq nodejs 2>&1; then | ||
| break | ||
| fi | ||
| info "apt-get install nodejs failed (attempt $attempt/5), retrying..." | ||
| sleep 10 | ||
| done | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| info "Node.js $(node --version) installed" | ||
| else | ||
| info "Node.js already installed: $(node --version)" | ||
| fi | ||
|
|
||
| # --- 1. Docker --- | ||
| if ! command -v docker >/dev/null 2>&1; then | ||
| wait_for_apt | ||
| info "Installing Docker..." | ||
| sudo apt-get update -qq >/dev/null 2>&1 | ||
| sudo apt-get install -y -qq docker.io >/dev/null 2>&1 | ||
| for attempt in 1 2 3 4 5; do | ||
| wait_for_apt | ||
| if sudo apt-get update -qq >/dev/null 2>&1 && sudo apt-get install -y -qq docker.io >/dev/null 2>&1; then | ||
| break | ||
| fi | ||
| info "Docker install failed (attempt $attempt/5), retrying..." | ||
| sleep 10 | ||
| done | ||
| sudo usermod -aG docker "$(whoami)" | ||
| info "Docker installed" | ||
| else | ||
| info "Docker already installed" | ||
| fi | ||
|
|
||
| # --- 2. NVIDIA Container Toolkit (if GPU present) --- | ||
| if command -v nvidia-smi >/dev/null 2>&1; then | ||
| # Check that nvidia-smi actually works, not just that the binary exists. | ||
| # Brev GPU images ship nvidia-smi even on CPU-only instances. | ||
| if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1; then | ||
|
Comment on lines
+113
to
+115
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use one GPU capability flag across all GPU-gated sections. This block correctly checks runnable Proposed fix+# Detect GPU availability once and reuse everywhere.
+HAS_GPU=false
+if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1; then
+ HAS_GPU=true
+fi
+
# --- 2. NVIDIA Container Toolkit (if GPU present) ---
-if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1; then
+if [ "$HAS_GPU" = true ]; then
...
fi
# --- 4. vLLM (local inference, if GPU present) ---
...
-elif command -v nvidia-smi >/dev/null 2>&1; then
+elif [ "$HAS_GPU" = true ]; then
...
fi🤖 Prompt for AI Agents |
||
| if ! dpkg -s nvidia-container-toolkit >/dev/null 2>&1; then | ||
| info "Installing NVIDIA Container Toolkit..." | ||
| curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \ | ||
|
|
@@ -91,6 +129,22 @@ if command -v nvidia-smi >/dev/null 2>&1; then | |
| else | ||
| info "NVIDIA Container Toolkit already installed" | ||
| fi | ||
| else | ||
| # CPU-only instance: ensure Docker uses runc (not nvidia) as default runtime. | ||
| # Brev GPU images pre-configure nvidia as the default Docker runtime even on | ||
| # CPU instances, causing "nvidia-container-cli: nvml error: driver not loaded" | ||
| # when starting containers. | ||
| if grep -q '"default-runtime".*nvidia' /etc/docker/daemon.json 2>/dev/null; then | ||
| info "Resetting Docker default runtime to runc (no GPU detected)..." | ||
| sudo python3 -c " | ||
| import json | ||
| with open('/etc/docker/daemon.json') as f: cfg = json.load(f) | ||
| cfg.pop('default-runtime', None) | ||
| with open('/etc/docker/daemon.json', 'w') as f: json.dump(cfg, f, indent=2) | ||
| " | ||
| sudo systemctl restart docker | ||
| info "Docker runtime reset to runc" | ||
| fi | ||
| fi | ||
|
|
||
| # --- 3. openshell CLI (binary release, not pip) --- | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.