10000 fix cluster-statistics (#9397) · Mars2018/arangodb@54169cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 54169cd

Browse files
ObiWahnjsteemann
authored andcommitted
fix cluster-statistics (arangodb#9397)
1 parent 9668561 commit 54169cd

File tree

5 files changed

+46
-40
lines changed

5 files changed

+46
-40
lines changed

js/apps/system/_admin/aardvark/APP/statistics.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -499,25 +499,36 @@ router.get('/coordshort', function (req, res) {
499499
var coordinatorStats;
500500
if (Array.isArray(coordinators)) {
501501
coordinatorStats = coordinators.map(coordinator => {
502-
var endpoint = global.ArangoClusterInfo.getServerEndpoint(coordinator);
503-
if (endpoint.substring(0, 3) === 'ssl') {
504-
// if protocol ssl is returned, change it to https
505-
endpoint = 'https' + endpoint.substring(3);
502+
const op = ArangoClusterComm.asyncRequest(
503+
"GET",
504+
"server:" + coordinator,
505+
"_system",
506+
'/_admin/aardvark/statistics/short?count=' + coordinators.length,
507+
"",
508+
{},
509+
{ timeout: 10 }
510+
);
511+
512+
const r = ArangoClusterComm.wait(op);
513+
514+
if (r.status === "RECEIVED") {
515+
res.set("content-type", "application/json; charset=utf-8");
516+
return JSON.parse(r.body);
517+
}
518+
if (r.status === "TIMEOUT") {
519+
throw new httperr.BadRequest("operation timed out");
520+
}
521+
let body;
522+
try {
523+
body = JSON.parse(r.body);
524+
} catch (e) {
525+
// noop
506526
}
507-
if (endpoint !== '') {
508-
var response = download(endpoint.replace(/^tcp/, 'http') + '/_db/_system/_admin/aardvark/statistics/short?count=' + coordinators.length, '', {headers: {}});
509-
if (response.body === undefined) {
510-
console.warn('cannot contact coordinator ' + coordinator + ' on endpoint ' + endpoint);
511-
} else {
512-
try {
513-
return JSON.parse(response.body);
514-
} catch (e) {
515-
console.error("Couldn't read statistics response:", response.body);
516-
throw e;
517-
}
518-
}
519-
}
520-
return false;
527+
528+
throw Object.assign(
529+
new httperr.BadRequest("error from DBserver, possibly DBserver unknown"),
530+
{extra: {body}}
531+
);
521532
});
522533

523534
if (coordinatorStats) {

lib/V8/v8-utils.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,16 +2851,6 @@ static void JS_ProcessStatistics(v8::FunctionCallbackInfo<v8::Value> const& args
28512851
TRI_V8_TRY_CATCH_BEGIN(isolate)
28522852
v8::HandleScope scope(isolate);
28532853

2854-
V8SecurityFeature* v8security =
2855-
application_features::ApplicationServer::getFeature<V8SecurityFeature>(
2856-
"V8Security");
2857-
TRI_ASSERT(v8security != nullptr);
2858-
2859-
if (v8security->isInternalModuleHardened(isolate)) {
2860-
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_FORBIDDEN,
2861-
"not allowed to provide this information");
2862-
}
2863-
28642854
v8::Handle<v8::Object> result = v8::Object::New(isolate);
28652855

28662856
ProcessInfo info = TRI_ProcessInfoSelf();

tests/js/client/permissions/harden.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ function testSuite() {
4949
processStatistics();
5050
fail();
5151
} catch (err) {
52-
assertEqual(arangodb.ERROR_FORBIDDEN, err.errorNum);
52+
//disabled for oasis
53+
//assertEqual(arangodb.ERROR_FORBIDDEN, err.errorNum);
5354
}
5455
},
5556

tests/js/server/permissions/test-api-transaction-hardened.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function testSuite() {
5555
assertEqual(403, result.code);
5656
assertEqual(errors.ERROR_FORBIDDEN.code, result.errorNum);
5757
},
58-
58+
5959
testClientStatistics : function() {
6060
let data = {
6161
collections: {},
@@ -66,7 +66,7 @@ function testSuite() {
6666
assertFalse(result.error);
6767
assertEqual(200, result.code);
6868
},
69-
69+
7070
testHttpStatistics : function() {
7171
let data = {
7272
collections: {},
@@ -77,30 +77,33 @@ function testSuite() {
7777
assertFalse(result.error);
7878
assertEqual(200, result.code);
7979
},
80-
80+
8181
testProcessStatistics : function() {
8282
let data = {
8383
collections: {},
8484
action: String(function() { require('internal').processStatistics(); })
8585
};
8686

8787
let result = arango.POST("/_api/transaction", data);
88-
assertTrue(result.error);
89-
assertEqual(403, result.code);
90-
assertEqual(errors.ERROR_FORBIDDEN.code, result.errorNum);
88+
89+
assertFalse(result.error);
90+
// disabled for oasis
91+
//assertTrue(result.error);
92+
//assertEqual(403, result.code);
93+
//assertEqual(errors.ERROR_FORBIDDEN.code, result.errorNum);
9194
},
92-
95+
9396
testExecuteExternal : function() {
9497
let data = {
9598
collections: {},
96-
action: String(function() {
99+
action: String(function() {
97100
let command;
98101
if (require('internal').platform.substr(0, 3) !== 'win') {
99102
command = "/bin/true";
100103
} else {
101104
command = "notepad.exe";
102105
}
103-
require('internal').executeExternal(command);
106+
require('internal').executeExternal(command);
104107
})
105108
};
106109

@@ -109,7 +112,7 @@ function testSuite() {
109112
assertEqual(403, result.code);
110113
assertEqual(errors.ERROR_FORBIDDEN.code, result.errorNum);
111114
},
112-
115+
113116
};
114117
}
115118

tests/js/server/permissions/test-foxx-service-access-denied.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ function testSuite() {
111111
testProcessStatistics : function() {
112112
const url = endpoint + mount + "/process-statistics";
113113
const res = download(url);
114-
assertEqual(403, res.code);
114+
//disabled for oasis
115+
//assertEqual(403, res.code);
115116
},
116117

117118
testExecuteExternal : function() {

0 commit comments

Comments
 (0)
0