Keep startup demo cleanup non-fatal
This commit is contained in:
@@ -7,7 +7,7 @@ use crank_core::{
|
||||
};
|
||||
use crank_mapping::{JsonPathRoot, infer_mapping_from_samples};
|
||||
use crank_mapping::{MappingRule, MappingSet};
|
||||
use crank_registry::{ListInvocationLogsQuery, OperationSummary, SampleKind};
|
||||
use crank_registry::{ListInvocationLogsQuery, OperationSummary, RegistryError, SampleKind};
|
||||
use crank_schema::Schema;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
@@ -99,11 +99,8 @@ impl AdminService {
|
||||
.name
|
||||
.starts_with("weather_current_open_meteo_smoke_")
|
||||
{
|
||||
self.delete_operation(
|
||||
workspace_id,
|
||||
&OperationId::new(operation.id.as_str().to_owned()),
|
||||
)
|
||||
.await?;
|
||||
self.delete_legacy_demo_operation_if_safe(workspace_id, &operation.id)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,17 +110,36 @@ impl AdminService {
|
||||
"weather_current_open_meteo",
|
||||
] {
|
||||
if let Some(operation) = self.find_operation_by_name(workspace_id, name).await? {
|
||||
self.delete_operation(
|
||||
workspace_id,
|
||||
&OperationId::new(operation.id.as_str().to_owned()),
|
||||
)
|
||||
.await?;
|
||||
self.delete_legacy_demo_operation_if_safe(workspace_id, &operation.id)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn delete_legacy_demo_operation_if_safe(
|
||||
&self,
|
||||
workspace_id: &WorkspaceId,
|
||||
operation_id: &OperationId,
|
||||
) -> Result<(), ApiError> {
|
||||
match self
|
||||
.registry
|
||||
.delete_operation(workspace_id, operation_id)
|
||||
.await
|
||||
{
|
||||
Ok(()) => Ok(()),
|
||||
Err(RegistryError::OperationHasPublishedAgentBindings { .. }) => {
|
||||
tracing::warn!(
|
||||
operation_id = %operation_id.as_str(),
|
||||
"legacy demo operation is still bound to a published agent; leaving it in place"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Err(error) => Err(ApiError::from(error)),
|
||||
}
|
||||
}
|
||||
|
||||
async fn ensure_demo_platform_api_key(
|
||||
&self,
|
||||
workspace_id: &WorkspaceId,
|
||||
|
||||
Reference in New Issue
Block a user