Hardswap Invariants in tests + Quota fixes

This commit is contained in:
Alexey
2026-09-20 00:28:52 +03:00
parent 89dacbd17e
commit d706b3f3ba
66 changed files with 1821 additions and 505 deletions
+27 -1
View File
@@ -17,7 +17,7 @@ use hyper::service::service_fn;
use hyper::{Method, Request, Response, StatusCode};
use subtle::ConstantTimeEq;
use tokio::net::TcpListener;
use tokio::sync::{Mutex, RwLock, Semaphore, watch};
use tokio::sync::{Mutex, RwLock, Semaphore, oneshot, watch};
use tokio::time::timeout;
use tracing::{debug, info, warn};
@@ -134,6 +134,7 @@ pub(super) struct ApiShared {
pub(super) active_runtime: Arc<ArcSwap<RuntimeGeneration>>,
pub(super) web_trace: Arc<WebTraceStore>,
pub(super) web_runtime_rx: watch::Receiver<WebRuntimePublication>,
pub(super) control_plane: ProcessControlPlane,
}
impl ApiShared {
@@ -169,8 +170,32 @@ impl ApiShared {
active_runtime: self.active_runtime.clone(),
web_trace: self.web_trace.clone(),
web_runtime_rx: self.web_runtime_rx.clone(),
control_plane: self.control_plane.clone(),
}
}
/// Keeps an accepted mutation alive until persistence and mandatory publication finish.
async fn run_mutation_completion<T, F>(&self, future: F) -> Result<T, ApiFailure>
where
T: Send + 'static,
F: std::future::Future<Output = Result<T, ApiFailure>> + Send + 'static,
{
let (result_tx, result_rx) = oneshot::channel();
self.control_plane
.spawn_completion(async move {
let _ = result_tx.send(future.await);
})
.map_err(|_| {
ApiFailure::new(
StatusCode::SERVICE_UNAVAILABLE,
"control_plane_shutting_down",
"Control plane is shutting down",
)
})?;
result_rx.await.map_err(|_| {
ApiFailure::internal("accepted config mutation did not report completion")
})?
}
}
fn auth_header_matches(actual: &str, expected: &str) -> bool {
@@ -364,6 +389,7 @@ pub(crate) async fn serve(
active_runtime,
web_trace,
web_runtime_rx,
control_plane: control_plane.clone(),
});
spawn_runtime_watchers(