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

Add graphman unassign/reassign commands to graphman graphql api #5678

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

shiyasmohd
Copy link
Contributor

No description provided.

@shiyasmohd shiyasmohd requested a review from isum October 18, 2024 15:24
@shiyasmohd shiyasmohd self-assigned this Oct 20, 2024
Copy link
Member

@isum isum left a comment

Choose a reason for hiding this comment

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

The code looks good, but there are a few things to consider before I can complete my review:

  • I would suggest rethinking the approach with warnings, so that we are not hiding potentially important details from users. It might be a good idea to break the commands into smaller pieces to allow more flexibility in the interfaces that assemble the commands (it is important not to allow assembling wrong commands);
  • When I introduced the GraphQL API, we agreed that all implemented commands should have tests, and there are no tests for the new GraphQL commands;
  • The primary use case for extracting the Graphman commands into a separate crate and breaking them into smaller pieces was to share the functionality between the CLI and the GraphQL API, but this PR does not share the extracted code with the CLI;

core/graphman/src/deployment.rs Outdated Show resolved Hide resolved
core/graphman/src/commands/deployment/unassign.rs Outdated Show resolved Hide resolved
core/graphman/src/commands/deployment/reassign.rs Outdated Show resolved Hide resolved
Comment on lines +78 to +81
None => catalog_conn
.assign_subgraph(&deployment.site, &node)
.map_err(GraphmanError::from)?,
};
Copy link
Member

Choose a reason for hiding this comment

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

Here we are hiding a potentially important detail about what actually happens.

I'm not sure what the best way to do this would be. One way would be to split the command into more pieces, so that when the API / CLI assembles the command, it decides how to proceed and what messages to generate. Another way would be to return some warnings in this function, but they are not very flexible and useful at this level.

server/graphman/src/entities/response.rs Outdated Show resolved Hide resolved
Comment on lines 103 to 113
let mirror = catalog::Mirror::primary_only(ctx.primary_pool);
let count = mirror.assignments(&node)?.len();
if count == 1 {
Ok(Response::new(true,format!("warning: this is the only deployment assigned to '{}'. Are you sure it is spelled correctly?",node.as_str())))
} else {
Ok(Response::new(
true,
format!("Ressigned {} to {}", deployment.as_str(), node.as_str()),
))
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this belongs here, because this functionality is also used in the CLI, and it's not very nice to have it duplicated.

server/graphman/src/resolvers/deployment_mutation.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants