mirror of https://gitee.com/bigwinds/arangodb
check before foxx-heal (#10512)
* check before foxx-heal * be more graceful
This commit is contained in:
parent
b0cafb39ae
commit
3c5acf6717
|
@ -79,6 +79,7 @@ RestStatus RestStatusHandler::execute() {
|
||||||
auto& serverFeature = server.getFeature<ServerFeature>();
|
auto& serverFeature = server.getFeature<ServerFeature>();
|
||||||
result.add("mode", VPackValue(serverFeature.operationModeString())); // to be deprecated - 3.3 compat
|
result.add("mode", VPackValue(serverFeature.operationModeString())); // to be deprecated - 3.3 compat
|
||||||
result.add("operationMode", VPackValue(serverFeature.operationModeString()));
|
result.add("operationMode", VPackValue(serverFeature.operationModeString()));
|
||||||
|
result.add("foxxApi", VPackValue(!security.isFoxxApiDisabled()));
|
||||||
|
|
||||||
std::string host = ServerState::instance()->getHost();
|
std::string host = ServerState::instance()->getHost();
|
||||||
|
|
||||||
|
|
|
@ -816,13 +816,32 @@ arangodb::Result restoreView(arangodb::httpclient::SimpleHttpClient& httpClient,
|
||||||
arangodb::Result triggerFoxxHeal(arangodb::httpclient::SimpleHttpClient& httpClient) {
|
arangodb::Result triggerFoxxHeal(arangodb::httpclient::SimpleHttpClient& httpClient) {
|
||||||
using arangodb::Logger;
|
using arangodb::Logger;
|
||||||
using arangodb::httpclient::SimpleHttpResult;
|
using arangodb::httpclient::SimpleHttpResult;
|
||||||
const std::string FoxxHealUrl = "/_api/foxx/_local/heal";
|
|
||||||
|
|
||||||
std::string body = "";
|
std::string body = "";
|
||||||
|
|
||||||
|
// check if the foxx api is available.
|
||||||
|
const std::string statusUrl = "/_admin/status";
|
||||||
std::unique_ptr<SimpleHttpResult> response(
|
std::unique_ptr<SimpleHttpResult> response(
|
||||||
httpClient.request(arangodb::rest::RequestType::POST, FoxxHealUrl,
|
httpClient.request(arangodb::rest::RequestType::POST, statusUrl,
|
||||||
body.c_str(), body.length()));
|
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);
|
return ::checkHttpResponse(httpClient, response, "trigger self heal", body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@ function testSuite() {
|
||||||
assertTrue(result.hasOwnProperty("serverInfo"));
|
assertTrue(result.hasOwnProperty("serverInfo"));
|
||||||
assertTrue(result.hasOwnProperty("server"));
|
assertTrue(result.hasOwnProperty("server"));
|
||||||
assertTrue(result.hasOwnProperty("pid"));
|
assertTrue(result.hasOwnProperty("pid"));
|
||||||
|
assertTrue(result.hasOwnProperty("foxxApi"));
|
||||||
},
|
},
|
||||||
|
|
||||||
testCanAccessAdminStatusRo : function() {
|
testCanAccessAdminStatusRo : function() {
|
||||||
|
@ -111,6 +112,7 @@ function testSuite() {
|
||||||
assertFalse(result.hasOwnProperty("serverInfo"));
|
assertFalse(result.hasOwnProperty("serverInfo"));
|
||||||
assertFalse(result.hasOwnProperty("server"));
|
assertFalse(result.hasOwnProperty("server"));
|
||||||
assertFalse(result.hasOwnProperty("pid"));
|
assertFalse(result.hasOwnProperty("pid"));
|
||||||
|
assertFalse(result.hasOwnProperty("foxxApi"));
|
||||||
},
|
},
|
||||||
|
|
||||||
testCanAccessAdminLogRw : function() {
|
testCanAccessAdminLogRw : function() {
|
||||||
|
|
Loading…
Reference in New Issue