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 5 commits into
base: master
Choose a base branch
from

Conversation

shiyasmohd
Copy link
Contributor

No description provided.

Copy link
Contributor

@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 Show resolved Hide resolved
Comment on lines +78 to +81
None => catalog_conn
.assign_subgraph(&deployment.site, &node)
.map_err(GraphmanError::from)?,
};
Copy link
Contributor

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.

Comment on lines +4 to +7
pub struct Response {
pub success: bool,
pub message: String,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This type could be very confusing if we decide to use it. For example, how do we know what success: false means and how and why it is different from an error?

If we want to output some warnings to the user sometimes, I would suggest to create a clearer output type for this like CompletedWithWarnings which contains only a vector of warnings inside and use a union in the result like union ReassignResponse = EmptyResponse | CompletedWithWarnings. This way it's very clear how the command was executed and what happened during its execution.

&self,
ctx: &Context<'_>,
deployment: DeploymentSelector,
node: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not a big deal, but it might be nice to have a custom GraphQL type that handles NodeIds.

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
Contributor

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.

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