File tree Expand file tree Collapse file tree 3 files changed +35
-10
lines changed
core/graphman/src/commands/deployment
node/src/manager/commands/deployment
server/graphman/src/resolvers/deployment_mutation Expand file tree Collapse file tree 3 files changed +35
-10
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,18 @@ impl Deployment {
2424 pub fn locator ( & self ) -> & DeploymentLocator {
2525 & self . locator
2626 }
27+
28+ pub fn assigned_node (
29+ & self ,
30+ primary_pool : ConnectionPool ,
31+ ) -> Result < Option < NodeId > , GraphmanError > {
32+ let primary_conn = primary_pool. get ( ) . map_err ( GraphmanError :: from) ?;
33+ let mut catalog_conn = catalog:: Connection :: new ( primary_conn) ;
34+ let node = catalog_conn
35+ . assigned_node ( & self . site )
36+ . map_err ( GraphmanError :: from) ?;
37+ Ok ( node)
38+ }
2739}
2840
2941#[ derive( Debug , Error ) ]
@@ -70,16 +82,13 @@ pub fn reassign_deployment(
7082 notification_sender : Arc < NotificationSender > ,
7183 deployment : & Deployment ,
7284 node : & NodeId ,
85+ curr_node : Option < NodeId > ,
7386) -> Result < ReassignResult , ReassignDeploymentError > {
7487 let primary_conn = primary_pool. get ( ) . map_err ( GraphmanError :: from) ?;
7588 let mut catalog_conn = catalog:: Connection :: new ( primary_conn) ;
76-
77- let changes: Vec < AssignmentChange > = match catalog_conn
78- . assigned_node ( & deployment. site )
79- . map_err ( GraphmanError :: from) ?
80- {
89+ let changes: Vec < AssignmentChange > = match & curr_node {
8190 Some ( curr) => {
82- if & curr == node {
91+ if & curr == & node {
8392 vec ! [ ]
8493 } else {
8594 catalog_conn
Original file line number Diff line number Diff line change @@ -16,11 +16,24 @@ pub fn run(
1616 node : & NodeId ,
1717) -> Result < ( ) > {
1818 let deployment = load_deployment ( primary_pool. clone ( ) , & deployment) ?;
19+ let curr_node = deployment. assigned_node ( primary_pool. clone ( ) ) ?;
20+ let reassign_msg = match & curr_node {
21+ Some ( curr_node) => format ! (
22+ "Reassigning deployment {} (was {})" ,
23+ deployment. locator( ) ,
24+ curr_node
25+ ) ,
26+ None => format ! ( "Reassigning deployment {}" , deployment. locator( ) ) ,
27+ } ;
28+ println ! ( "{}" , reassign_msg) ;
1929
20- println ! ( "Reassigning deployment {}" , deployment. locator( ) ) ;
21-
22- let reassign_result =
23- reassign_deployment ( primary_pool, notification_sender, & deployment, node) ?;
30+ let reassign_result = reassign_deployment (
31+ primary_pool,
32+ notification_sender,
33+ & deployment,
34+ node,
35+ curr_node,
36+ ) ?;
2437
2538 match reassign_result {
2639 ReassignResult :: EmptyResponse => {
Original file line number Diff line number Diff line change @@ -14,11 +14,14 @@ pub fn run(
1414 node : & NodeId ,
1515) -> Result < ReassignResult , anyhow:: Error > {
1616 let deployment = load_deployment ( ctx. primary_pool . clone ( ) , deployment) ?;
17+ let curr_node = deployment. assigned_node ( ctx. primary_pool . clone ( ) ) ?;
18+
1719 let reassign_result = reassign_deployment (
1820 ctx. primary_pool . clone ( ) ,
1921 ctx. notification_sender . clone ( ) ,
2022 & deployment,
2123 & node,
24+ curr_node,
2225 ) ?;
2326 Ok ( reassign_result)
2427}
You can’t perform that action at this time.
0 commit comments