Skip to content

Commit fb7c34c

Browse files
committed
node,server: improve error handling when restarting paused subgraphs
1 parent cd39656 commit fb7c34c

File tree

2 files changed

+37
-14
lines changed
  • node/src/manager/commands/deployment
  • server/graphman/src/resolvers/deployment_mutation

2 files changed

+37
-14
lines changed

node/src/manager/commands/deployment/pause.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@ use std::sync::Arc;
33
use anyhow::Result;
44
use graph_store_postgres::connection_pool::ConnectionPool;
55
use graph_store_postgres::NotificationSender;
6-
use graphman::commands::deployment::pause::load_active_deployment;
7-
use graphman::commands::deployment::pause::pause_active_deployment;
6+
use graphman::commands::deployment::pause::{
7+
load_active_deployment, pause_active_deployment, PauseDeploymentError,
8+
};
89
use graphman::deployment::DeploymentSelector;
910

1011
pub fn run(
1112
primary_pool: ConnectionPool,
1213
notification_sender: Arc<NotificationSender>,
1314
deployment: DeploymentSelector,
1415
) -> Result<()> {
15-
let active_deployment = load_active_deployment(primary_pool.clone(), &deployment)?;
16+
let active_deployment = load_active_deployment(primary_pool.clone(), &deployment);
1617

17-
println!("Pausing deployment {} ...", active_deployment.locator());
18-
19-
pause_active_deployment(primary_pool, notification_sender, active_deployment)?;
18+
match active_deployment {
19+
Ok(active_deployment) => {
20+
println!("Pausing deployment {} ...", active_deployment.locator());
21+
pause_active_deployment(primary_pool, notification_sender, active_deployment)?;
22+
}
23+
Err(PauseDeploymentError::AlreadyPaused(locator)) => {
24+
println!("Deployment {} is already paused", locator);
25+
return Ok(());
26+
}
27+
Err(PauseDeploymentError::Common(e)) => {
28+
println!("Failed to load active deployment: {}", e);
29+
return Err(e.into());
30+
}
31+
}
2032

2133
Ok(())
2234
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
use async_graphql::Result;
2-
use graphman::commands::deployment::pause::load_active_deployment;
3-
use graphman::commands::deployment::pause::pause_active_deployment;
2+
use graphman::commands::deployment::pause::{
3+
load_active_deployment, pause_active_deployment, PauseDeploymentError,
4+
};
45
use graphman::deployment::DeploymentSelector;
56

67
use crate::resolvers::context::GraphmanContext;
78

89
pub fn run(ctx: &GraphmanContext, deployment: &DeploymentSelector) -> Result<()> {
9-
let active_deployment = load_active_deployment(ctx.primary_pool.clone(), deployment)?;
10+
let active_deployment = load_active_deployment(ctx.primary_pool.clone(), deployment);
1011

11-
pause_active_deployment(
12-
ctx.primary_pool.clone(),
13-
ctx.notification_sender.clone(),
14-
active_deployment,
15-
)?;
12+
match active_deployment {
13+
Ok(active_deployment) => {
14+
pause_active_deployment(
15+
ctx.primary_pool.clone(),
16+
ctx.notification_sender.clone(),
17+
active_deployment,
18+
)?;
19+
}
20+
Err(PauseDeploymentError::AlreadyPaused(_)) => {
21+
return Ok(());
22+
}
23+
Err(PauseDeploymentError::Common(e)) => {
24+
return Err(e.into());
25+
}
26+
}
1627

1728
Ok(())
1829
}

0 commit comments

Comments
 (0)