feat(console): unregister inactive revisions
Expose a management DELETE endpoint that refuses to remove an active Deployment, delegates Actor and compiled Component cleanup to Runtime, and removes stored artifacts. Reconcile Toasty snapshots by deleting absent service and Deployment rows so removed revisions do not reappear after restart. Persist unregister lifecycle events and verify active-revision protection, artifact deletion, Runtime cleanup, and restart behavior.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
//! history, and service-scoped Host KV entries.
|
||||
|
||||
use std::{
|
||||
collections::BTreeSet,
|
||||
path::Path,
|
||||
sync::Arc,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
@@ -130,6 +131,15 @@ impl Persistence {
|
||||
let mut db = self.db.lock().await;
|
||||
let mut tx = db.transaction().await?;
|
||||
|
||||
let service_keys = services
|
||||
.iter()
|
||||
.map(|service| service.service_key.clone())
|
||||
.collect::<BTreeSet<_>>();
|
||||
for stored in StoredService::all().exec(&mut tx).await? {
|
||||
if !service_keys.contains(&stored.service_key) {
|
||||
StoredService::delete_by_service_key(&mut tx, &stored.service_key).await?;
|
||||
}
|
||||
}
|
||||
for service in services {
|
||||
StoredService::upsert_by_service_key(service.service_key)
|
||||
.manifest_toml(service.manifest_toml)
|
||||
@@ -159,6 +169,15 @@ impl Persistence {
|
||||
.await?;
|
||||
}
|
||||
|
||||
let deployment_ids = deployments
|
||||
.iter()
|
||||
.map(|deployment| deployment.service_id.clone())
|
||||
.collect::<BTreeSet<_>>();
|
||||
for stored in StoredDeployment::all().exec(&mut tx).await? {
|
||||
if !deployment_ids.contains(&stored.service_id) {
|
||||
StoredDeployment::delete_by_service_id(&mut tx, &stored.service_id).await?;
|
||||
}
|
||||
}
|
||||
for deployment in deployments {
|
||||
StoredDeployment::upsert_by_service_id(deployment.service_id)
|
||||
.active_revision(deployment.active_revision)
|
||||
|
||||
Reference in New Issue
Block a user