Skip to content

Add kernel restart functionality across frontend and backend#332

Open
Edwardvaneechoud wants to merge 1 commit intofeauture/kernel-implementationfrom
claude/kernel-restart-recovery-mfNXu
Open

Add kernel restart functionality across frontend and backend#332
Edwardvaneechoud wants to merge 1 commit intofeauture/kernel-implementationfrom
claude/kernel-restart-recovery-mfNXu

Conversation

@Edwardvaneechoud
Copy link
Owner

Summary

This PR adds the ability to restart kernel containers while preserving their configuration. Users can now restart kernels from both the Kernel Manager view and the Python Script node editor, with visual feedback during the restart process.

Key Changes

Backend (flowfile_core)

  • Added KernelState.RESTARTING enum value to track restart state
  • Implemented restart_kernel() method in kernel manager that:
    • Stops and removes the existing container
    • Re-allocates ports if needed (local mode)
    • Starts a fresh container with preserved configuration
    • Captures container logs on failure for diagnostics
  • Added _get_container_logs() helper to retrieve container logs for error reporting
  • Added POST /kernels/{kernel_id}/restart API endpoint with authorization checks

Frontend (flowfile_frontend)

  • Added KernelState type support for "restarting" state
  • Implemented KernelApi.restart() method for API communication
  • Added restartKernel() action in useKernelManager composable
  • Kernel Manager View:
    • Added restart button to KernelCard with warning styling
    • Disabled delete button during restart operations
    • Added restart status badge with spinning icon
    • Integrated restart handler in KernelManagerView
  • Python Script Node:
    • Added inline restart button next to kernel selector
    • Button shows spinning icon during restart and is disabled while restarting
    • Added "restarting" state message in kernel status display
    • Integrated restart handler that reloads kernels and artifacts after restart

Implementation Details

  • Restart preserves kernel configuration (packages, memory/CPU limits) but clears all in-memory artifacts
  • Visual feedback includes spinning icon during restart and disabled state to prevent concurrent operations
  • Error handling includes container logs in error messages for better diagnostics
  • Authorization checks ensure users can only restart their own kernels

Implements a "Restart Kernel" feature that allows users to recover from
runtime issues (memory leaks, hung processes, corrupted state) without
losing code or flow configuration.

Backend:
- Add RESTARTING state to KernelState enum
- Add restart_kernel() method to KernelManager that stops the container,
  creates a fresh one with the same config (packages, memory/CPU limits),
  and waits for health check
- Add _get_container_logs() helper for diagnostic output on restart failure
- Add POST /kernels/{kernel_id}/restart API endpoint

Frontend:
- Add "restarting" to KernelState type with spinner icon and yellow badge
- Add KernelApi.restart() method
- Add "Restart" button to KernelCard (visible when idle/executing/error)
- Add restart button to PythonScript node settings next to kernel dropdown
- Wire up restart handling in KernelManagerView and useKernelManager
- Status indicator updates in real-time (restarting -> idle)
- Error messages surface container logs on restart failure

https://claude.ai/code/session_01G7rwmj8nw9LnXdEVppxgnp
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.

2 participants