Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
55 changes: 50 additions & 5 deletions .github/workflows/e2e-bm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ jobs:
echo "=== Sudo privileges ==="
sudo -v && echo "✓ Sudo available"

- name: Install dufs for HTTP package storage
run: |
echo "=== Installing dufs ==="
cargo install dufs
echo "✓ Installed dufs"

- name: Install Flame with flmadm and systemd
run: |
sudo ./target/release/flmadm install --all --src-dir . --skip-build --prefix $INSTALL_PREFIX --enable
Expand All @@ -78,6 +84,22 @@ jobs:
sudo chmod 0777 /opt/flame/packages
echo "✓ Created /opt/flame/packages with 0777 permissions"

- name: Start HTTP package storage server
run: |
echo "=== Starting dufs package storage server ==="
nohup dufs /opt/flame/packages -p 5050 -A > /tmp/dufs.log 2>&1 &
echo $! > /tmp/dufs.pid
sleep 2

if ps -p $(cat /tmp/dufs.pid) > /dev/null; then
echo "✓ Package storage server started (PID: $(cat /tmp/dufs.pid))"
curl -s http://127.0.0.1:5050/ > /dev/null && echo "✓ Package storage server is accessible"
else
echo "✗ Package storage server failed to start"
cat /tmp/dufs.log
exit 1
fi

- name: Install Python SDK for test client
run: |
echo "=== Installing flamepy for test client (not required for flmrun service) ==="
Expand Down Expand Up @@ -111,29 +133,47 @@ jobs:
- name: Install Python dependencies
run: |
# Install test dependencies
pip3 install grpcio grpcio-tools pytest black isort
pip3 install grpcio grpcio-tools pytest pytest-timeout black isort

- name: Verify Flame cluster is ready
run: |
echo "=== Check flmctl connectivity ==="
flmctl list -a || echo "Warning: Could not list applications"
echo ""
echo "=== Verify HTTP storage is accessible ==="
curl -s http://127.0.0.1:5050/ && echo "✓ HTTP storage is accessible" || echo "Warning: HTTP storage not accessible"

- name: Run test_runner
timeout-minutes: 10
run: |
# Add e2e src to PYTHONPATH (flamepy is already system-installed)
export PYTHONPATH="$(pwd)/e2e/src:$PYTHONPATH"
cd e2e
pytest -vv --durations=0 tests/test_runner.py
pytest -vv --durations=0 --timeout=120 tests/test_runner.py

- name: Show service logs on failure
if: failure()
if: failure() || cancelled()
run: |
echo "=== Package Storage Logs ==="
cat /tmp/dufs.log || echo "No dufs log file found"
echo ""
echo "=== Session Manager Logs (systemd) ==="
sudo journalctl -u flame-session-manager -n 100 || echo "No systemd logs found"
sudo journalctl -u flame-session-manager -n 200 || echo "No systemd logs found"
echo ""
echo "=== Session Manager Logs (file) ==="
sudo cat $INSTALL_PREFIX/logs/fsm.log || echo "No FSM log file found"
echo ""
echo "=== Executor Manager Logs (systemd) ==="
sudo journalctl -u flame-executor-manager -n 100 || echo "No systemd logs found"
sudo journalctl -u flame-executor-manager -n 200 || echo "No systemd logs found"
echo ""
echo "=== Executor Manager Logs (file) ==="
sudo cat $INSTALL_PREFIX/logs/fem.log || echo "No FEM log file found"
echo ""
echo "=== Active processes ==="
ps aux | grep -E "(flame|dufs|python)" || true
echo ""
echo "=== Network connections ==="
netstat -tlnp 2>/dev/null || ss -tlnp || true

- name: Stop Flame services
if: always()
Expand All @@ -145,4 +185,9 @@ jobs:
- name: Cleanup
if: always()
run: |
# Stop package storage server
if [ -f /tmp/dufs.pid ]; then
kill $(cat /tmp/dufs.pid) || true
rm -f /tmp/dufs.pid
fi
sudo ./target/release/flmadm uninstall --prefix $INSTALL_PREFIX --no-backup --force || true
2 changes: 1 addition & 1 deletion ci/flame-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ clusters:
cache:
endpoint: "grpc://127.0.0.1:9090"
package:
storage: "file:///opt/flame/packages"
storage: "http://127.0.0.1:5050"
excludes:
- "*.log"
- "*.pkl"
Expand Down
2 changes: 1 addition & 1 deletion ci/flame.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ clusters:
cache:
endpoint: "grpc://flame-executor-manager:9090"
package:
storage: "file:///opt/flame/packages"
storage: "http://flame-package-storage:5000"
excludes:
- "*.log"
- "*.pkl"
Expand Down
15 changes: 13 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ services:
- ./ci/flame-cluster.yaml:/root/.flame/flame-cluster.yaml
- ./examples:/opt/examples
- ./e2e:/opt/e2e
- flame-packages:/opt/flame/packages
- flame-work:/usr/local/flame/work
- flame-cache-storage:/var/lib/flame/cache
ports:
Expand All @@ -56,7 +55,19 @@ services:
- ./ci/flame.yaml:/root/.flame/flame.yaml
- ./examples:/opt/examples
- ./e2e:/opt/e2e
- flame-packages:/opt/flame/packages
depends_on:
- flame-package-storage

flame-package-storage:
image: sigoden/dufs:v0.43.0
logging:
options:
max-size: "100m"
command: ["/data", "-A"]
volumes:
- flame-packages:/data
ports:
- 5050:5000

volumes:
flame-packages:
Expand Down
28 changes: 28 additions & 0 deletions flmctl/src/close.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2025 The Flame Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

use std::error::Error;

use flame_rs as flame;
use flame_rs::apis::FlameContext;

pub async fn run(ctx: &FlameContext, session_id: &str) -> Result<(), Box<dyn Error>> {
let current_cluster = ctx.get_current_cluster()?;
let conn = flame::client::connect(&current_cluster.endpoint).await?;

conn.close_session(session_id).await?;

println!("Session <{}> was closed.", session_id);

Ok(())
}
5 changes: 2 additions & 3 deletions flmctl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use clap::{Parser, Subcommand};
use flame_rs::apis::FlameContext;

mod apis;
mod close;
mod create;
mod helper;
mod list;
Expand Down Expand Up @@ -129,9 +130,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
session,
executor,
}) => list::run(&ctx, *application, *session, *executor).await?,
Some(Commands::Close { .. }) => {
todo!()
}
Some(Commands::Close { session }) => close::run(&ctx, session).await?,
Some(Commands::Create { app, slots }) => create::run(&ctx, app, slots).await?,
Some(Commands::View {
application,
Expand Down
82 changes: 75 additions & 7 deletions hack/local-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -e

INSTALL_PREFIX="${INSTALL_PREFIX:-/tmp/flame-dev}"
FLAME_ENDPOINT="${FLAME_ENDPOINT:-http://127.0.0.1:8080}"
PACKAGE_STORAGE_PORT="${PACKAGE_STORAGE_PORT:-5050}"
PACKAGE_STORAGE_DIR="${PACKAGE_STORAGE_DIR:-$INSTALL_PREFIX/packages}"

# Colors for output
RED='\033[0;31m'
Expand All @@ -24,6 +26,22 @@ log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}

# Check if dufs is installed, if not provide installation instructions
check_dufs() {
if ! command -v dufs &> /dev/null; then
log_error "dufs is not installed. Please install it first:"
echo ""
echo " # Using cargo:"
echo " cargo install dufs"
echo ""
echo " # Or using brew (macOS):"
echo " brew install dufs"
echo ""
echo " # Or download from: https://github.com/sigoden/dufs/releases"
exit 1
fi
}

# Check if flmadm is built
if [ ! -f "target/release/flmadm" ]; then
log_info "Building flmadm..."
Expand All @@ -35,11 +53,30 @@ case "$1" in
install)
log_info "Installing Flame to $INSTALL_PREFIX..."
make install-dev INSTALL_PREFIX="$INSTALL_PREFIX"

# Create packages directory for HTTP storage
mkdir -p "$PACKAGE_STORAGE_DIR"
log_info "Created package storage directory: $PACKAGE_STORAGE_DIR"
;;

start)
log_info "Starting Flame services..."

# Check dufs is available
check_dufs

# Create packages directory if not exists
mkdir -p "$PACKAGE_STORAGE_DIR"

# Start package storage server (dufs)
log_info "Starting package storage server on port $PACKAGE_STORAGE_PORT..."
dufs "$PACKAGE_STORAGE_DIR" -p "$PACKAGE_STORAGE_PORT" -A \
> "$INSTALL_PREFIX/logs/storage.log" 2>&1 &
echo $! > /tmp/flame-storage.pid

# Wait for storage server
sleep 1

# Start session manager
log_info "Starting session manager..."
FLAME_HOME="$INSTALL_PREFIX" "$INSTALL_PREFIX/bin/flame-session-manager" \
Expand All @@ -61,6 +98,14 @@ case "$1" in
sleep 3

# Check if services are running
if [ -f /tmp/flame-storage.pid ] && ps -p $(cat /tmp/flame-storage.pid) > /dev/null; then
log_info "Package storage started (PID: $(cat /tmp/flame-storage.pid)) at http://127.0.0.1:$PACKAGE_STORAGE_PORT"
else
log_error "Package storage failed to start"
cat "$INSTALL_PREFIX/logs/storage.log"
exit 1
fi

if ps -p $(cat /tmp/flame-fsm.pid) > /dev/null; then
log_info "Session manager started (PID: $(cat /tmp/flame-fsm.pid))"
else
Expand All @@ -85,7 +130,7 @@ case "$1" in

if [ -f /tmp/flame-fem.pid ]; then
PID=$(cat /tmp/flame-fem.pid)
if ps -p $PID > /dev/null; then
if ps -p $PID > /dev/null 2>&1; then
kill $PID
log_info "Stopped executor manager (PID: $PID)"
fi
Expand All @@ -94,12 +139,21 @@ case "$1" in

if [ -f /tmp/flame-fsm.pid ]; then
PID=$(cat /tmp/flame-fsm.pid)
if ps -p $PID > /dev/null; then
if ps -p $PID > /dev/null 2>&1; then
kill $PID
log_info "Stopped session manager (PID: $PID)"
fi
rm -f /tmp/flame-fsm.pid
fi

if [ -f /tmp/flame-storage.pid ]; then
PID=$(cat /tmp/flame-storage.pid)
if ps -p $PID > /dev/null 2>&1; then
kill $PID
log_info "Stopped package storage (PID: $PID)"
fi
rm -f /tmp/flame-storage.pid
fi
;;

restart)
Expand All @@ -112,13 +166,19 @@ case "$1" in
status)
log_info "Checking Flame services status..."

if [ -f /tmp/flame-fsm.pid ] && ps -p $(cat /tmp/flame-fsm.pid) > /dev/null; then
if [ -f /tmp/flame-storage.pid ] && ps -p $(cat /tmp/flame-storage.pid) > /dev/null 2>&1; then
log_info "Package storage is running (PID: $(cat /tmp/flame-storage.pid))"
else
log_warn "Package storage is not running"
fi

if [ -f /tmp/flame-fsm.pid ] && ps -p $(cat /tmp/flame-fsm.pid) > /dev/null 2>&1; then
log_info "Session manager is running (PID: $(cat /tmp/flame-fsm.pid))"
else
log_warn "Session manager is not running"
fi

if [ -f /tmp/flame-fem.pid ] && ps -p $(cat /tmp/flame-fem.pid) > /dev/null; then
if [ -f /tmp/flame-fem.pid ] && ps -p $(cat /tmp/flame-fem.pid) > /dev/null 2>&1; then
log_info "Executor manager is running (PID: $(cat /tmp/flame-fem.pid))"
else
log_warn "Executor manager is not running"
Expand All @@ -128,6 +188,9 @@ case "$1" in
logs)
log_info "Showing service logs..."
echo ""
echo "=== Package Storage Logs ==="
tail -50 "$INSTALL_PREFIX/logs/storage.log" 2>/dev/null || log_warn "No storage logs found"
echo ""
echo "=== Session Manager Logs ==="
tail -50 "$INSTALL_PREFIX/logs/fsm.log" 2>/dev/null || log_warn "No FSM logs found"
echo ""
Expand Down Expand Up @@ -157,7 +220,7 @@ case "$1" in
echo ""
echo "Commands:"
echo " install - Install Flame locally"
echo " start - Start Flame services"
echo " start - Start Flame services (including package storage)"
echo " stop - Stop Flame services"
echo " restart - Restart Flame services"
echo " status - Check service status"
Expand All @@ -167,8 +230,13 @@ case "$1" in
echo " clean - Stop and uninstall Flame"
echo ""
echo "Environment variables:"
echo " INSTALL_PREFIX - Installation directory (default: /tmp/flame-dev)"
echo " FLAME_ENDPOINT - Flame endpoint URL (default: http://127.0.0.1:8080)"
echo " INSTALL_PREFIX - Installation directory (default: /tmp/flame-dev)"
echo " FLAME_ENDPOINT - Flame endpoint URL (default: http://127.0.0.1:8080)"
echo " PACKAGE_STORAGE_PORT - HTTP storage port (default: 5050)"
echo " PACKAGE_STORAGE_DIR - Package storage directory (default: \$INSTALL_PREFIX/packages)"
echo ""
echo "Prerequisites:"
echo " dufs - HTTP file server (install via: cargo install dufs)"
exit 1
;;
esac
6 changes: 3 additions & 3 deletions sdk/python/src/flamepy/core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self, service: FlameService):
self._service = service

@override
def OnSessionEnter(self, request, context):
def OnSessionEnter(self, request, context): # noqa: N802
"""Handle OnSessionEnter RPC call."""
_trace_fn = TraceFn("OnSessionEnter")

Expand Down Expand Up @@ -180,7 +180,7 @@ def OnSessionEnter(self, request, context):
return Result(return_code=-1, message=f"{str(e)}")

@override
def OnTaskInvoke(self, request, context):
def OnTaskInvoke(self, request, context): # noqa: N802
"""Handle OnTaskInvoke RPC call."""
_trace_fn = TraceFn("OnTaskInvoke")

Expand Down Expand Up @@ -209,7 +209,7 @@ def OnTaskInvoke(self, request, context):
return TaskResultProto(return_code=-1, output=None, message=f"{str(e)}")

@override
def OnSessionLeave(self, request, context):
def OnSessionLeave(self, request, context): # noqa: N802
"""Handle OnSessionLeave RPC call."""
_trace_fn = TraceFn("OnSessionLeave")

Expand Down
2 changes: 1 addition & 1 deletion sdk/rust/src/apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl From<rpc::ExecutorState> for ExecutorState {
}

pub fn init_logger() -> Result<(), FlameError> {
let filter = tracing_subscriber::EnvFilter::try_from_default_env()?
let filter = tracing_subscriber::EnvFilter::from_default_env()
.add_directive("h2=error".parse()?)
.add_directive("hyper_util=error".parse()?)
.add_directive("tower=error".parse()?);
Expand Down
Loading
Loading