mirror of https://gitee.com/bigwinds/arangodb
check before foxx-heal
This commit is contained in:
parent
32bb28028a
commit
74fde7f330
|
@ -83,6 +83,7 @@ RestStatus RestStatusHandler::execute() {
|
|||
VPackValue(server->operationModeString())); // to be deprecated - 3.3 compat
|
||||
result.add("operationMode", VPackValue(server->operationModeString()));
|
||||
}
|
||||
result.add("foxxApi", VPackValue(!security->isFoxxApiDisabled()));
|
||||
|
||||
std::string host = ServerState::instance()->getHost();
|
||||
|
||||
|
|
|
@ -769,13 +769,32 @@ arangodb::Result restoreView(arangodb::httpclient::SimpleHttpClient& httpClient,
|
|||
arangodb::Result triggerFoxxHeal(arangodb::httpclient::SimpleHttpClient& httpClient) {
|
||||
using arangodb::Logger;
|
||||
using arangodb::httpclient::SimpleHttpResult;
|
||||
const std::string FoxxHealUrl = "/_api/foxx/_local/heal";
|
||||
|
||||
std::string body = "";
|
||||
|
||||
// check if the foxx api is available.
|
||||
const std::string statusUrl = "/_admin/status";
|
||||
std::unique_ptr<SimpleHttpResult> response(
|
||||
httpClient.request(arangodb::rest::RequestType::POST, FoxxHealUrl,
|
||||
httpClient.request(arangodb::rest::RequestType::POST, statusUrl,
|
||||
body.c_str(), body.length()));
|
||||
|
||||
auto res = ::checkHttpResponse(httpClient, response, "check status", body);
|
||||
if (res.ok() && response) {
|
||||
try {
|
||||
if(!response->getBodyVelocyPack()->slice().get("foxxApi").getBool()) {
|
||||
LOG_TOPIC("9e9b9", INFO, Logger::RESTORE)
|
||||
<< "skipping foxx self-healing because Foxx API is disabled";
|
||||
return { };
|
||||
}
|
||||
} catch (...) {
|
||||
//API Not available because of older version or whatever
|
||||
}
|
||||
}
|
||||
|
||||
const std::string FoxxHealUrl = "/_api/foxx/_local/heal";
|
||||
response.reset(
|
||||
httpClient.request(arangodb::rest::RequestType::POST, FoxxHealUrl,
|
||||
body.c_str(), body.length())
|
||||
);
|
||||
return ::checkHttpResponse(httpClient, response, "trigger self heal", body);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ function testSuite() {
|
|||
assertTrue(result.hasOwnProperty("serverInfo"));
|
||||
assertTrue(result.hasOwnProperty("server"));
|
||||
assertTrue(result.hasOwnProperty("pid"));
|
||||
assertTrue(result.hasOwnProperty("foxxApi"));
|
||||
},
|
||||
|
||||
testCanAccessAdminStatusRo : function() {
|
||||
|
@ -111,6 +112,7 @@ function testSuite() {
|
|||
assertFalse(result.hasOwnProperty("serverInfo"));
|
||||
assertFalse(result.hasOwnProperty("server"));
|
||||
assertFalse(result.hasOwnProperty("pid"));
|
||||
assertFalse(result.hasOwnProperty("foxxApi"));
|
||||
},
|
||||
|
||||
testCanAccessAdminLogRw : function() {
|
||||
|
|
Loading…
Reference in New Issue