1
0
Fork 0

Info log when server is removed. Store remove date in agency. (#9285)

This commit is contained in:
Lars Maier 2019-06-24 14:04:58 +02:00 committed by Max Neunhöffer
parent e61fb5a34e
commit 7d98b5bde4
1 changed files with 8 additions and 6 deletions

View File

@ -114,10 +114,12 @@ actions.defineHttp({
operations['/arango/Current/DBServers/' + serverId] = {'op': 'delete'}; operations['/arango/Current/DBServers/' + serverId] = {'op': 'delete'};
operations['/arango/Supervision/Health/' + serverId] = {'op': 'delete'}; operations['/arango/Supervision/Health/' + serverId] = {'op': 'delete'};
operations['/arango/Target/MapUniqueToShortID/' + serverId] = {'op': 'delete'}; operations['/arango/Target/MapUniqueToShortID/' + serverId] = {'op': 'delete'};
operations['/arango/Target/RemovedServers/' + serverId] = {'op': 'set', 'new': (new Date()).toISOString()};
try { try {
global.ArangoAgency.write([[operations, preconditions]]); global.ArangoAgency.write([[operations, preconditions]]);
actions.resultOk(req, res, actions.HTTP_OK, true); actions.resultOk(req, res, actions.HTTP_OK, true);
console.info("Removed server " + serverId + " from cluster");
return; return;
} catch (e) { } catch (e) {
if (e.code === 412) { if (e.code === 412) {
@ -154,7 +156,7 @@ actions.defineHttp({
callback: function (req, res) { callback: function (req, res) {
let role = global.ArangoServerState.role(); let role = global.ArangoServerState.role();
if (req.requestType !== actions.PUT || if (req.requestType !== actions.PUT ||
(role !== 'COORDINATOR' && role !== 'SINGLE')) { (role !== 'COORDINATOR' && role !== 'SINGLE')) {
actions.resultError(req, res, actions.HTTP_FORBIDDEN, 0, actions.resultError(req, res, actions.HTTP_FORBIDDEN, 0,
'only GET and PUT requests are allowed and only to coordinators or singles'); 'only GET and PUT requests are allowed and only to coordinators or singles');
@ -203,7 +205,7 @@ actions.defineHttp({
while (true) { while (true) {
var mode = global.ArangoAgency.read([["/arango/Supervision/State/Mode"]])[0]. var mode = global.ArangoAgency.read([["/arango/Supervision/State/Mode"]])[0].
arango.Supervision.State.Mode; arango.Supervision.State.Mode;
if (body === "on" && mode === "Maintenance") { if (body === "on" && mode === "Maintenance") {
res.body = JSON.stringify({ res.body = JSON.stringify({
error: false, error: false,
@ -217,7 +219,7 @@ actions.defineHttp({
} }
wait(0.1); wait(0.1);
if (new Date().getTime() > waitUntil) { if (new Date().getTime() > waitUntil) {
res.responseCode = actions.HTTP_GATEWAY_TIMEOUT; res.responseCode = actions.HTTP_GATEWAY_TIMEOUT;
res.body = JSON.stringify({ res.body = JSON.stringify({
@ -227,10 +229,10 @@ actions.defineHttp({
}); });
return; return;
} }
} }
return ; return ;
}}); }});
// ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////
@ -1078,7 +1080,7 @@ actions.defineHttp({
} }
// at least RW rights on db to move a shard // at least RW rights on db to move a shard
if (!req.isAdminUser && if (!req.isAdminUser &&
users.permission(req.user, body.database) !== 'rw') { users.permission(req.user, body.database) !== 'rw') {
actions.resultError(req, res, actions.HTTP_FORBIDDEN, 0, actions.resultError(req, res, actions.HTTP_FORBIDDEN, 0,
'insufficent permissions on database to move shard'); 'insufficent permissions on database to move shard');