Skip to content

display current node when reassigning subgraph #5910

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

Merged
merged 1 commit into from
Apr 17, 2025
Merged
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
21 changes: 15 additions & 6 deletions core/graphman/src/commands/deployment/reassign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ impl Deployment {
pub fn locator(&self) -> &DeploymentLocator {
&self.locator
}

pub fn assigned_node(
&self,
primary_pool: ConnectionPool,
) -> Result<Option<NodeId>, GraphmanError> {
let primary_conn = primary_pool.get().map_err(GraphmanError::from)?;
let mut catalog_conn = catalog::Connection::new(primary_conn);
let node = catalog_conn
.assigned_node(&self.site)
.map_err(GraphmanError::from)?;
Ok(node)
}
}

#[derive(Debug, Error)]
Expand Down Expand Up @@ -70,16 +82,13 @@ pub fn reassign_deployment(
notification_sender: Arc<NotificationSender>,
deployment: &Deployment,
node: &NodeId,
curr_node: Option<NodeId>,
) -> Result<ReassignResult, ReassignDeploymentError> {
let primary_conn = primary_pool.get().map_err(GraphmanError::from)?;
let mut catalog_conn = catalog::Connection::new(primary_conn);

let changes: Vec<AssignmentChange> = match catalog_conn
.assigned_node(&deployment.site)
.map_err(GraphmanError::from)?
{
let changes: Vec<AssignmentChange> = match &curr_node {
Some(curr) => {
if &curr == node {
if &curr == &node {
vec![]
} else {
catalog_conn
Expand Down
21 changes: 17 additions & 4 deletions node/src/manager/commands/deployment/reassign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ pub fn run(
node: &NodeId,
) -> Result<()> {
let deployment = load_deployment(primary_pool.clone(), &deployment)?;
let curr_node = deployment.assigned_node(primary_pool.clone())?;
let reassign_msg = match &curr_node {
Some(curr_node) => format!(
"Reassigning deployment {} (was {})",
deployment.locator(),
curr_node
),
None => format!("Reassigning deployment {}", deployment.locator()),
};
println!("{}", reassign_msg);

println!("Reassigning deployment {}", deployment.locator());

let reassign_result =
reassign_deployment(primary_pool, notification_sender, &deployment, node)?;
let reassign_result = reassign_deployment(
primary_pool,
notification_sender,
&deployment,
node,
curr_node,
)?;

match reassign_result {
ReassignResult::EmptyResponse => {
Expand Down
3 changes: 3 additions & 0 deletions server/graphman/src/resolvers/deployment_mutation/reassign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ pub fn run(
node: &NodeId,
) -> Result<ReassignResult, anyhow::Error> {
let deployment = load_deployment(ctx.primary_pool.clone(), deployment)?;
let curr_node = deployment.assigned_node(ctx.primary_pool.clone())?;

let reassign_result = reassign_deployment(
ctx.primary_pool.clone(),
ctx.notification_sender.clone(),
&deployment,
&node,
curr_node,
)?;
Ok(reassign_result)
}
Loading