Update archipelago: API, auth, container, parmanode, performance, security

- API handler, RPC, and server updates
- Auth and coding rules
- Container data manager, dev orchestrator, health monitor, podman client
- Parmanode script runner
- Performance resource manager
- Security container policies and secrets manager
- Add build scripts and documentation
This commit is contained in:
Dorian
2026-01-27 22:27:17 +00:00
parent 0d073fa89e
commit 1c024c5d64
5332 changed files with 8978 additions and 24160 deletions
+11 -16
View File
@@ -1,15 +1,12 @@
use crate::api::rpc::RpcHandler;
use crate::config::Config;
use anyhow::Result;
use http_body_util::{BodyExt, Full};
use hyper::body::Bytes;
use hyper::{Method, Request, Response, StatusCode};
use hyper_util::rt::TokioIo;
use std::sync::Arc;
use tracing::debug;
pub struct ApiHandler {
config: Config,
_config: Config,
rpc_handler: Arc<RpcHandler>,
// Add other handlers here (websocket, static files, etc.)
}
@@ -19,28 +16,26 @@ impl ApiHandler {
let rpc_handler = Arc::new(RpcHandler::new(config.clone()).await?);
Ok(Self {
config,
_config: config,
rpc_handler,
})
}
pub async fn handle_request(
&self,
req: Request<http_body_util::Incoming>,
) -> Result<Response<Full<Bytes>>> {
req: Request<hyper::Body>,
) -> Result<Response<hyper::Body>> {
// Extract path and method before consuming req
let path = req.uri().path().to_string();
let method = req.method().clone();
// Convert body to bytes using http_body_util::BodyExt
// Convert body to bytes
let (parts, body) = req.into_parts();
use http_body_util::BodyExt;
let collected: http_body_util::Collected<Bytes> = body.collect().await
.map_err(|_e| anyhow::anyhow!("Failed to read body"))?;
let body_bytes = collected.to_bytes();
let body_bytes = hyper::body::to_bytes(body).await
.map_err(|e| anyhow::anyhow!("Failed to read body: {}", e))?;
// Reconstruct request with Full<Bytes> body for RPC handler
let req_with_bytes = Request::from_parts(parts, Full::new(body_bytes));
// Reconstruct request with body as Bytes for RPC handler
let req_with_bytes = Request::from_parts(parts, hyper::Body::from(body_bytes));
debug!("{} {}", method, path);
@@ -52,13 +47,13 @@ impl ApiHandler {
(Method::GET, "/health") => {
Ok(Response::builder()
.status(StatusCode::OK)
.body(Full::new(Bytes::from("OK")))
.body(hyper::Body::from("OK"))
.unwrap())
}
_ => {
Ok(Response::builder()
.status(StatusCode::NOT_FOUND)
.body(Full::new(Bytes::from("Not Found")))
.body(hyper::Body::from("Not Found"))
.unwrap())
}
}
-1
View File
@@ -2,4 +2,3 @@ mod handler;
mod rpc;
pub use handler::ApiHandler;
pub use rpc::RpcHandler;
+8 -14
View File
@@ -1,12 +1,9 @@
use crate::config::Config;
use crate::container::DevContainerOrchestrator;
use anyhow::{Context, Result};
use http_body_util::{BodyExt, Full};
use hyper::body::Bytes;
use hyper::{Request, Response, StatusCode};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use tokio::sync::RwLock;
use tracing::{debug, error};
#[derive(Debug, Deserialize)]
@@ -29,7 +26,7 @@ struct RpcError {
}
pub struct RpcHandler {
config: Config,
_config: Config,
orchestrator: Option<Arc<DevContainerOrchestrator>>,
}
@@ -44,22 +41,19 @@ impl RpcHandler {
};
Ok(Self {
config,
_config: config,
orchestrator,
})
}
pub async fn handle(
&self,
req: Request<Full<Bytes>>,
) -> Result<Response<Full<Bytes>>> {
// Read request body - Full<Bytes> is already collected
req: Request<hyper::Body>,
) -> Result<Response<hyper::Body>> {
// Read request body
let (_, body) = req.into_parts();
// Full<Bytes> implements Body, collect it to get the bytes
use http_body_util::BodyExt;
let collected = body.collect().await
.context("Failed to collect body")?;
let body_bytes = collected.to_bytes();
let body_bytes = hyper::body::to_bytes(body).await
.context("Failed to read body")?;
let rpc_req: RpcRequest = serde_json::from_slice(&body_bytes)
.context("Invalid RPC request")?;
@@ -108,7 +102,7 @@ impl RpcHandler {
Ok(Response::builder()
.status(StatusCode::OK)
.header("Content-Type", "application/json")
.body(Full::new(Bytes::from(body)))
.body(hyper::Body::from(body))
.unwrap())
}