You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by "wenbingshen (via GitHub)" <gi...@apache.org> on 2023/05/25 14:24:50 UTC
[GitHub] [bookkeeper] wenbingshen opened a new pull request, #3972: Prevent bookie shutdown due to rest api when bookie prohibits readOnlyMode
wenbingshen opened a new pull request, #3972:
URL: https://github.com/apache/bookkeeper/pull/3972
### Motivation
When bookie disabled readOnlyMode, once the user initiates a readOnly conversion through the rest api, the bookie process will be shut down directly.
```java
public void doTransitionToReadOnlyMode() {
......
if (!conf.isReadOnlyModeEnabled()) {
LOG.warn("ReadOnly mode is not enabled. "
+ "Can be enabled by configuring "
+ "'readOnlyModeEnabled=true' in configuration."
+ " Shutting down bookie");
shutdownHandler.shutdown(ExitCode.BOOKIE_EXCEPTION);
return;
}
......
}
```
I have the following reasons for this PR:
1. If the user wants to shut down the bookie, there is no need to operate it through the rest api, and can directly use the shell shutdown script.
2. The user switches the readOnly state through the rest api, the first purpose is not to shut down the bookie process;
3. Exposing the bookie shutdown logic through the rest api has certain security risks.
You can copy the following code to org.apache.bookkeeper.server.http.TestHttpService#testBookieReadOnlyState to reproduce the shutdown of bookie:
```java
// disable readOnly mode
restartBookies(c -> {
c.setForceReadOnlyBookie(false);
c.setReadOnlyModeEnabled(false);
return c;
});
MetadataBookieDriver metadataDriver = BookieResources.createMetadataDriver(
baseConf, NullStatsLogger.INSTANCE);
BKHttpServiceProvider bkHttpServiceProvider2 = new BKHttpServiceProvider.Builder()
.setBookieServer(serverByIndex(numberOfBookies - 1))
.setServerConfiguration(baseConf)
.setLedgerManagerFactory(metadataDriver.getLedgerManagerFactory())
.build();
HttpEndpointService bookieReadOnlyService2 = bkHttpServiceProvider2
.provideHttpEndpointService(HttpServer.ApiType.BOOKIE_STATE_READONLY);
request = new HttpServiceRequest(JsonUtil.toJson(new ReadOnlyState(true)), HttpServer.Method.PUT, null);
response = bookieReadOnlyService2.handle(request);
Awaitility.await().untilAsserted(() -> {
assertFalse(serverByIndex(numberOfBookies - 1).isBookieRunning()); // here the bookie will be shutdown.
});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prevent bookie shutdown due to rest api when bookie prohibits readOnlyMode [bookkeeper]
Posted by "wenbingshen (via GitHub)" <gi...@apache.org>.
wenbingshen merged PR #3972:
URL: https://github.com/apache/bookkeeper/pull/3972
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org