Skip to content
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

server: add pause and resume to admin json rpc api #5190

Merged
merged 1 commit into from Feb 15, 2024

Conversation

incrypto32
Copy link
Contributor

Closes #5180

@incrypto32 incrypto32 force-pushed the krishna/add-pause-resume-to-rpc branch from ec25991 to 31419fc Compare February 6, 2024 10:45
@incrypto32 incrypto32 marked this pull request as ready for review February 6, 2024 10:51
@lutter
Copy link
Collaborator

lutter commented Feb 6, 2024

It would be good if the graphman pause/resume commands also used the implementation in the store instead of having their own parallel one.

@incrypto32
Copy link
Contributor Author

incrypto32 commented Feb 8, 2024

@lutter the implementation in the manager is just a wrapper to check if the subgraph is already paused or resumed before running the conn.pause_subgraph

The implementaion from the subgraph_store also simply wraps the same method conn.pause_subgraph

fn pause_subgraph(&self, deployment: &DeploymentLocator) -> Result<(), StoreError> {
let site = self.find_site(deployment.id.into())?;
let pconn = self.primary_conn()?;
pconn.transaction(|| -> Result<_, StoreError> {
let changes = pconn.pause_subgraph(site.as_ref())?;
pconn.send_store_event(&self.sender, &StoreEvent::new(changes))
})
}

Implementation in graphman

pub fn pause_or_resume(
primary: ConnectionPool,
sender: &NotificationSender,
search: &DeploymentSearch,
should_pause: bool,
) -> Result<(), Error> {
let locator = search.locate_unique(&primary)?;
let conn = primary.get()?;
let conn = catalog::Connection::new(conn);
let site = conn
.locate_site(locator.clone())?
.ok_or_else(|| anyhow!("failed to locate site for {locator}"))?;
let change = match conn.assignment_status(&site)? {
Some((_, is_paused)) => {
if should_pause {
if is_paused {
println!("deployment {locator} is already paused");
return Ok(());
}
println!("pausing {locator}");
conn.pause_subgraph(&site)?
} else {
println!("resuming {locator}");
conn.resume_subgraph(&site)?
}
}
None => {
println!("deployment {locator} not found");
return Ok(());
}
};
println!("Operation completed");
conn.send_store_event(sender, &StoreEvent::new(change))?;
Ok(())
}

@lutter
Copy link
Collaborator

lutter commented Feb 14, 2024

@lutter the implementation in the manager is just a wrapper to check if the subgraph is already paused or resumed before running the conn.pause_subgraph

You are right - I completely misread that code.

@incrypto32 incrypto32 merged commit 795c437 into master Feb 15, 2024
7 checks passed
@incrypto32 incrypto32 deleted the krishna/add-pause-resume-to-rpc branch February 15, 2024 05:48
@fordN fordN added the enhancement New feature or request label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pause method to JSON-RPC admin server
4 participants