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 a REST API to get or update bookie readOnly state #2799

Merged
merged 4 commits into from
Mar 11, 2022

Conversation

fantapsody
Copy link
Contributor

@fantapsody fantapsody commented Sep 20, 2021

Motivation

This PR is a part of the work to improve the process of removing bookies from the cluster. Specifically, it implements the readOnly API described in the mail.

Changes

  • Add an REST API at /api/v1/bookie/state/readonly
    • The GET method returns the current readOnly status
    • The PUT method updates the readOnly status if needed.

TODOs

  • Update the document once the PR is accepted.
  • Update the BookieStateManager & BookieImpl to persist the information that the state change is triggered by the external API request and do not change the state based on the notification from the dirs monitoring service.

@fantapsody
Copy link
Contributor Author

@ivankelly PTAL

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

what happens if you restart the bookie ?

@fantapsody
Copy link
Contributor Author

what happens if you restart the bookie ?

@eolivelli It depends on the value of the config persistBookieStatusEnabled. If it is set to true, the state will be persisted to disk and be restored after restarted. However, the state might still be changed by the LedgerDirsMonitor, and I plan to persist the reason for the state change and use that information to decide whether the state could be changed by LedgerDirsMonitor. That may require the change of how to save & load the bookie status so I plan to leave it to further PRs.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

makes sense to me

the only thing to add here now is a bunch of test cases that cover this new code

well done

@fantapsody
Copy link
Contributor Author

It seems there is no test on HTTP services yet, so I plan to add one in the integration test module. I tried to run some existing tests like SimpleClusterTest in tests::integration::cluster to see how it works, but the test cluster failed to start and showed error logs like

Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for URL to be accessible (http://localhost:55041/commands/ruok should return HTTP 200)

I checked the log of the action that ran the integration tests, it seems those tests were not run actually: https://github.com/apache/bookkeeper/pull/2799/checks?check_run_id=3650019520

@eolivelli Could you confirm those integration tests are all still valid? Or do you have any suggestions on how to test these HTTP services? Thanks!

@eolivelli
Copy link
Contributor

eolivelli commented Sep 25, 2021

I cannot check now.
But IIRC we have unit tests for the HTTP API.
No need for a full integration test

In theory integration tests run for every pr validation

@eolivelli
Copy link
Contributor

@fantapsody
Copy link
Contributor Author

I cannot check now.
But IIRC we have unit tests for the HTTP API.
No need for a full integration test

In theory integration tests run for every pr validation

I just found those tests and will work on a new test case soon, thanks!

@fantapsody
Copy link
Contributor Author

@eolivelli I added a unit test for the new API, please take another look, thanks!

@addisonj
Copy link

@sijie Can you review this as well?

@pradeepbn
Copy link
Contributor

@fantapsody @sijie @eolivelli can we get this merged?

@letterwuyu
Copy link

thank you for you great work,lgtm, any updates ?

@lujiwen
Copy link

lujiwen commented Feb 10, 2022

@fantapsody thanks a lot for your great work, I am also looking for the solution to gracefully remove a bookie from cluster by marking it as read only mode, and do not handle write request any longer. But my question is how pulsar broker does realize that a read-only bookie is not a candidate of ensemble, and does not send write request to? Thanks in advance!

@fantapsody
Copy link
Contributor Author

@lujiwen The selection of bookies for the quorum is determined by the bookkeeper client which watches the changes of bookies and selects active bookies based on configurations and predefined policies. You may find a detailed description in https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/EnsemblePlacementPolicy.java. This PR is just a start, and there would be follow-ups as you may see in the TODOs in the issue description and the discussion in the mail list.

@eolivelli @sijie Could you take a look at the PR again?

@lujiwen
Copy link

lujiwen commented Feb 11, 2022

@fantapsody Thank you!

@dlg99 dlg99 closed this Mar 11, 2022
@dlg99 dlg99 reopened this Mar 11, 2022
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Lgtm

@dlg99 dlg99 added this to the 4.15.0 milestone Mar 11, 2022
@dlg99 dlg99 merged commit 9ee04b3 into apache:master Mar 11, 2022
dlg99 pushed a commit that referenced this pull request Mar 11, 2022
### Motivation

This PR is a part of the work to improve the process of removing bookies from the cluster. Specifically, it implements the `readOnly` API described in the [mail](http://mail-archives.apache.org/mod_mbox/bookkeeper-dev/202109.mbox/raw/%3CCAJdLeK03g8K0h6swn%3D9yVP1Ze2zHxe8TDobK6a-zpTdABkeQEA%40mail.gmail.com%3E).

### Changes

- Add an REST API at `/api/v1/bookie/state/readonly`
  - The `GET` method returns the current `readOnly` status
  - The `PUT` method updates the `readOnly` status if needed.

### TODOs

- Update the document once the PR is accepted.
- Update the `BookieStateManager` & `BookieImpl` to persist the information that the state change is triggered by the external API request and do not change the state based on the notification from the dirs monitoring service.

Reviewers: Yong Zhang <zhangyong1025.zy@gmail.com>, Enrico Olivelli <eolivelli@gmail.com>, Andrey Yegorov <None>

This closes #2799 from fantapsody/readonly-api

(cherry picked from commit 9ee04b3)
Signed-off-by: Andrey Yegorov <andrey.yegorov@datastax.com>
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
### Motivation

This PR is a part of the work to improve the process of removing bookies from the cluster. Specifically, it implements the `readOnly` API described in the [mail](http://mail-archives.apache.org/mod_mbox/bookkeeper-dev/202109.mbox/raw/%3CCAJdLeK03g8K0h6swn%3D9yVP1Ze2zHxe8TDobK6a-zpTdABkeQEA%40mail.gmail.com%3E).

### Changes

- Add an REST API at `/api/v1/bookie/state/readonly`
  - The `GET` method returns the current `readOnly` status
  - The `PUT` method updates the `readOnly` status if needed.

### TODOs

- Update the document once the PR is accepted.
- Update the `BookieStateManager` & `BookieImpl` to persist the information that the state change is triggered by the external API request and do not change the state based on the notification from the dirs monitoring service.

Reviewers: Yong Zhang <zhangyong1025.zy@gmail.com>, Enrico Olivelli <eolivelli@gmail.com>, Andrey Yegorov <None>

This closes apache#2799 from fantapsody/readonly-api
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.

8 participants