Skip to content

graphman: validate deployment before activating #5784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ impl Context {
store
}

fn pools(self) -> HashMap<Shard, ConnectionPool> {
fn pools(&self) -> HashMap<Shard, ConnectionPool> {
let (_, pools) = self.store_and_pools();
pools
}
Expand Down Expand Up @@ -1327,7 +1327,9 @@ async fn main() -> anyhow::Result<()> {
.await
}
Activate { deployment, shard } => {
commands::copy::activate(ctx.subgraph_store(), deployment, shard)
let pools = ctx.pools();
let store = ctx.subgraph_store();
commands::copy::activate(&pools, store, deployment, shard)
}
List => commands::copy::list(ctx.pools()),
Status { dst } => commands::copy::status(ctx.pools(), &dst),
Expand Down
26 changes: 23 additions & 3 deletions node/src/manager/commands/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ pub async fn create(
Ok(())
}

pub fn activate(store: Arc<SubgraphStore>, deployment: String, shard: String) -> Result<(), Error> {
pub fn activate(
pools: &HashMap<Shard, ConnectionPool>,
store: Arc<SubgraphStore>,
deployment: String,
shard: String,
) -> Result<(), Error> {
let shard = Shard::new(shard)?;
let deployment =
DeploymentHash::new(deployment).map_err(|s| anyhow!("illegal deployment hash `{}`", s))?;
Expand All @@ -167,8 +172,23 @@ pub fn activate(store: Arc<SubgraphStore>, deployment: String, shard: String) ->
shard
)
})?;
store.activate(&deployment)?;
println!("activated copy {}", deployment);

let (state, _, _) = match CopyState::find(pools, &shard, deployment.id.0)? {
Some((state, tables, on_sync)) => (state, tables, on_sync),
None => {
println!(
"copying is queued but has not started or no copy operation for {} exists",
deployment.id.0
);
return Ok(());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, don't we want the activate to actually do something?

}
};
if state.finished_at.is_some() {
store.activate(&deployment)?;
println!("activated copy {}", deployment);
} else {
println!("copying is not finished yet");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some more information to the error, like

the deployment sgdNNN is being copied from sgdNNN and can therefore not be activated yet

}
Ok(())
}

Expand Down