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

HDDS-10742. Add option to close all pipelines #6577

Merged
merged 7 commits into from
May 10, 2024

Conversation

Montura
Copy link
Contributor

@Montura Montura commented Apr 23, 2024

What changes were proposed in this pull request?

For now ozone CLI allows to get pipelines list or close pipeline by PipelineId.

Suggested a new option --all for ClosePipelineSubcommand to close all pipelines (or some filtered pipeline subset):

  1. get pipeline list from ScmClient
  2. filter CLOSED pipelines (to close only OPEN and ALLOCATED)
  3. filter pipelines by REPLICATION or REPLICATION_TYPE or REPLICATION_FACTOR (as in ListPipelinesSubcommand done)
  4. close the remain pipelines set

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-10742

How was this patch tested?

This subcommand triggers ClosePipelineSubcommand that is already tested.

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @Montura for the patch.

…PipelineSubcommand. Extract filter options to mixin class.
@Montura Montura changed the title HDDS-10742. Close all pipelines subcommand HDDS-10742. Close all pipelines with ClosePipelineSubcommand Apr 24, 2024
Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @Montura for updating the patch.

…oseAll option. Fix command execution: close one by id or all pipelines. Add javadoc and license
@Montura Montura force-pushed the close_all_pipelines_command branch from fd56fc3 to c549d33 Compare April 24, 2024 13:30
Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @Montura for continuing work on this. Seems to work well. I'll wait for @errose28 to take another look, too.

@adoroszlai adoroszlai changed the title HDDS-10742. Close all pipelines with ClosePipelineSubcommand HDDS-10742. Add option to close all pipelines Apr 24, 2024
Copy link
Contributor

@errose28 errose28 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just a few minor things:

  • A command like ozone admin pipeline close --replication=EC 1 will close pipeline 1 even if it is a Ratis pipeline.
    • It would be good to disallow the pipeline filter options when ID is specified, but I'm not sure how easy that is to do with pico CLI.
    • This is a minor details so if it's not easy to do it is ok as is.
  • It would be nice to print out how many pipeline close commands were sent when the command finishes. Maybe a message like Sending close command for 5 pipelines or something like that.

@Montura
Copy link
Contributor Author

Montura commented Apr 25, 2024

  • A command like ozone admin pipeline close --replication=EC 1 will close pipeline 1 even if it is a Ratis pipeline.

    • It would be good to disallow the pipeline filter options when ID is specified, but I'm not sure how easy that is to do with pico CLI.
  • Before my changes ozone admin pipeline close PIPELINE_ID was working only for specified PIPELINE_ID, so when user provides PIPELINE_ID he knows it's replicataion factor and replication type. There were no filters for this command.
  • Filters for replication type and factor appiled only for ozone admin pipeline list --filters command.
  • I thought that it would be nice to add the same filter options when run ozone admin pipeline close --all to be able to close only EC or only RATIS pipelines for example.

@Montura
Copy link
Contributor Author

Montura commented Apr 25, 2024

  • Before my changes ozone admin pipeline close PIPELINE_ID was working only for specified PIPELINE_ID, so when user provides PIPELINE_ID he knows it's replicataion factor and replication type. There were no filters for this command.

I realized, @errose28 means that you call ozone admin close pipeline 1 --replication=EC and filter is ignored...

Maybe a message like When close pipeline by ID filters are ignored. will solve this issue for a while?

  • CommandLine.ArgGroup doesn't support CommandLine.Mixin for know. I tried to add filters only for a new option --all. I'l look into int deeper

@Montura Montura requested a review from errose28 April 25, 2024 10:09
@Montura Montura force-pushed the close_all_pipelines_command branch from 404c82a to c9e59a7 Compare April 26, 2024 06:14
@Montura Montura requested a review from errose28 April 26, 2024 07:30
Copy link
Contributor

@errose28 errose28 left a comment

Choose a reason for hiding this comment

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

Thanks for the continued updates @Montura.

@@ -51,7 +51,7 @@ public class ClosePipelineSubcommand extends ScmSubcommand {
public void execute(ScmClient scmClient) throws IOException {
if (!Strings.isNullOrEmpty(closeOption.pipelineId)) {
if (filterOptions.getReplicationFilter().isPresent()) {
System.out.println("When close pipeline by ID filters are ignored.");
System.err.println("Replication filters can only be used with --all");
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if the last comment was not clear. We should also fail the command here instead of closing the pipeline anyways since the user did something invalid. We can probably throw IllegalArgumentException like FilterPipelineOptions#getReplicationFilter does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@errose28, let's sync :)

  1. We can log an error and don't close pipeline (if/else block): I have to fix current behaviour with else block.
if (filterOptions.getReplicationFilter().isPresent()) {
  System.err.println("Replication filters can only be used with --all");
} else {
  scmClient.closePipeline(...);
}
  1. We can log an error and throw and exception (if block), like org.apache.hadoop.hdds.scm.cli.cert.InfoSubcommand does: I have to fix current behaviour with throw an exception.
if (filterOptions.getReplicationFilter().isPresent()) {
  System.err.println("Replication filters can only be used with --all");
  throw new IllegalArgumentException("Replication filters can only be used with --all");
}
scmClient.closePipeline(...);
  1. We can just throw and exception (if block), like org.apache.hadoop.hdds.scm.cli.pipeline.ListPipelineSubcommand does : I have to fix current behaviour with throw an execption instead of log to System.err.
if (filterOptions.getReplicationFilter().isPresent()) {
  throw new IllegalArgumentException("Replication filters can only be used with --all");
}
scmClient.closePipeline(...);

What is the best one (or what do you expect) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@errose28, could you comment please the previous message

Copy link
Contributor

Choose a reason for hiding this comment

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

I just tried all three of these to double check and option 3 is what we want. There is logic farther up to print just the message to stderr and not the stack trace. Option 2 will print the message twice. Option 1 will exit 0 when it should exit nonzero.

Just looking at the example you provided I think cert.InfoSubcommand might print the message twice as well, but I did not try it out.

@Montura Montura requested a review from errose28 May 7, 2024 06:55
@errose28
Copy link
Contributor

errose28 commented May 8, 2024

Hi @Montura apologies for the delay. It's late night here currently but I will check this out tomorrow. Thanks for outlining the options.

@errose28
Copy link
Contributor

errose28 commented May 9, 2024

Just tried out the suggestions. Once this is done I think we are good to merge 👍

@Montura
Copy link
Contributor Author

Montura commented May 9, 2024

Done!

Copy link
Contributor

@errose28 errose28 left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @Montura. I just retriggered the unrelated recon test failure and once its green we can merge.

@adoroszlai adoroszlai merged commit 6487de7 into apache:master May 10, 2024
39 checks passed
@adoroszlai
Copy link
Contributor

Thanks @Montura for the patch, @errose28 for the review.

@Montura Montura deleted the close_all_pipelines_command branch May 10, 2024 21:46
jojochuang pushed a commit to jojochuang/ozone that referenced this pull request May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants