kuzzle 2.44.0-beta.1 → 2.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/controllers/adminController.js +2 -1
- package/lib/api/controllers/authController.d.ts +1 -0
- package/lib/api/controllers/authController.js +2 -1
- package/lib/api/controllers/securityController.js +22 -20
- package/lib/api/funnel.js +30 -10
- package/lib/cluster/command.js +3 -2
- package/lib/cluster/idCardHandler.d.ts +1 -0
- package/lib/cluster/idCardHandler.js +2 -1
- package/lib/cluster/node.js +18 -19
- package/lib/cluster/subscriber.js +5 -3
- package/lib/core/backend/backend.d.ts +3 -2
- package/lib/core/backend/backend.js +1 -1
- package/lib/core/cache/cacheEngine.js +3 -1
- package/lib/core/network/accessLogger.js +3 -2
- package/lib/core/network/entryPoint.js +7 -7
- package/lib/core/network/protocols/httpwsProtocol.js +7 -7
- package/lib/core/network/protocols/mqttProtocol.js +3 -2
- package/lib/core/network/router.js +4 -3
- package/lib/core/plugin/pluginsManager.js +13 -5
- package/lib/core/realtime/hotelClerk.d.ts +1 -0
- package/lib/core/realtime/hotelClerk.js +4 -3
- package/lib/core/realtime/notifier.js +2 -1
- package/lib/core/security/roleRepository.js +3 -2
- package/lib/core/security/securityLoader.js +5 -7
- package/lib/core/shared/store.d.ts +1 -0
- package/lib/core/shared/store.js +2 -1
- package/lib/core/statistics/statistics.js +3 -1
- package/lib/core/storage/storageEngine.js +6 -1
- package/lib/core/validation/validation.js +6 -5
- package/lib/kuzzle/dumpGenerator.js +17 -16
- package/lib/kuzzle/internalIndexHandler.js +3 -1
- package/lib/kuzzle/kuzzle.js +0 -1
- package/lib/service/cache/redis.js +4 -0
- package/lib/service/storage/7/elasticsearch.d.ts +1 -0
- package/lib/service/storage/7/elasticsearch.js +5 -4
- package/lib/service/storage/8/elasticsearch.d.ts +1 -0
- package/lib/service/storage/8/elasticsearch.js +5 -4
- package/lib/service/storage/Elasticsearch.d.ts +1 -0
- package/lib/service/storage/Elasticsearch.js +1 -1
- package/package.json +1 -1
|
@@ -45,6 +45,7 @@ class AdminController extends NativeController {
|
|
|
45
45
|
]);
|
|
46
46
|
|
|
47
47
|
this.shuttingDown = false;
|
|
48
|
+
this.logger = global.kuzzle.log.child("api:controllers:admin");
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
async refreshIndexCache() {
|
|
@@ -216,7 +217,7 @@ class AdminController extends NativeController {
|
|
|
216
217
|
if (waitForRefresh === "false") {
|
|
217
218
|
// Attaching an error handler to the provided promise to prevent
|
|
218
219
|
// uncaught rejections
|
|
219
|
-
promise.catch((err) =>
|
|
220
|
+
promise.catch((err) => this.logger.error(err));
|
|
220
221
|
|
|
221
222
|
return Bluebird.resolve(result);
|
|
222
223
|
}
|
|
@@ -87,6 +87,7 @@ class AuthController extends baseController_1.NativeController {
|
|
|
87
87
|
"updateSelf",
|
|
88
88
|
"validateMyCredentials",
|
|
89
89
|
]);
|
|
90
|
+
this.logger = global.kuzzle.log.child("api:controllers:auth");
|
|
90
91
|
this.anonymousId = null;
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
@@ -404,7 +405,7 @@ class AuthController extends baseController_1.NativeController {
|
|
|
404
405
|
retryOnConflict: request.getInteger("retryOnConflict", 10),
|
|
405
406
|
userId,
|
|
406
407
|
});
|
|
407
|
-
|
|
408
|
+
this.logger.info(`[SECURITY] ${securityController_1.default.userOrSdk(userId)} applied action "${request.input.action}" on user "${userId}."`);
|
|
408
409
|
return formatProcessing_1.default.serializeUser(user);
|
|
409
410
|
}
|
|
410
411
|
/**
|
|
@@ -109,6 +109,8 @@ class SecurityController extends NativeController {
|
|
|
109
109
|
global.kuzzle.pluginsManager.getStrategyMethod.bind(
|
|
110
110
|
global.kuzzle.pluginsManager,
|
|
111
111
|
);
|
|
112
|
+
|
|
113
|
+
this.logger = global.kuzzle.log.child("api:controllers:security");
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
/**
|
|
@@ -154,7 +156,7 @@ class SecurityController extends NativeController {
|
|
|
154
156
|
refresh,
|
|
155
157
|
});
|
|
156
158
|
|
|
157
|
-
|
|
159
|
+
this.logger.info(
|
|
158
160
|
`[SECURITY] ${SecurityController.userOrSdk(creatorId)} applied action "${
|
|
159
161
|
request.input.action
|
|
160
162
|
}" on user "${userId}."`,
|
|
@@ -394,7 +396,7 @@ class SecurityController extends NativeController {
|
|
|
394
396
|
},
|
|
395
397
|
);
|
|
396
398
|
|
|
397
|
-
|
|
399
|
+
this.logger.info(
|
|
398
400
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
399
401
|
request.input.action
|
|
400
402
|
}" on role "${role._id}."`,
|
|
@@ -419,7 +421,7 @@ class SecurityController extends NativeController {
|
|
|
419
421
|
userId,
|
|
420
422
|
});
|
|
421
423
|
|
|
422
|
-
|
|
424
|
+
this.logger.info(
|
|
423
425
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
424
426
|
request.input.action
|
|
425
427
|
}" on role "${role._id}."`,
|
|
@@ -440,7 +442,7 @@ class SecurityController extends NativeController {
|
|
|
440
442
|
refresh: request.getRefresh("wait_for"),
|
|
441
443
|
});
|
|
442
444
|
|
|
443
|
-
|
|
445
|
+
this.logger.info(
|
|
444
446
|
`[SECURITY] ${SecurityController.userOrSdk(
|
|
445
447
|
request.getKuid(),
|
|
446
448
|
)} applied action "${request.input.action} on role "${id}."`,
|
|
@@ -510,7 +512,7 @@ class SecurityController extends NativeController {
|
|
|
510
512
|
},
|
|
511
513
|
);
|
|
512
514
|
|
|
513
|
-
|
|
515
|
+
this.logger.info(
|
|
514
516
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
515
517
|
request.input.action
|
|
516
518
|
}" on profile "${profile._id}."`,
|
|
@@ -544,7 +546,7 @@ class SecurityController extends NativeController {
|
|
|
544
546
|
},
|
|
545
547
|
);
|
|
546
548
|
|
|
547
|
-
|
|
549
|
+
this.logger.info(
|
|
548
550
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
549
551
|
request.input.action
|
|
550
552
|
}" on profile "${profile._id}."`,
|
|
@@ -570,7 +572,7 @@ class SecurityController extends NativeController {
|
|
|
570
572
|
|
|
571
573
|
await this.ask("core:security:profile:delete", id, options);
|
|
572
574
|
|
|
573
|
-
|
|
575
|
+
this.logger.info(
|
|
574
576
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
575
577
|
request.input.action
|
|
576
578
|
}" on profile "${id}."`,
|
|
@@ -828,7 +830,7 @@ class SecurityController extends NativeController {
|
|
|
828
830
|
|
|
829
831
|
await this.ask("core:security:user:delete", id, options);
|
|
830
832
|
|
|
831
|
-
|
|
833
|
+
this.logger.info(
|
|
832
834
|
`[SECURITY] ${SecurityController.userOrSdk(
|
|
833
835
|
request.getKuid(),
|
|
834
836
|
)} applied action "${request.input.action}" on user "${id}."`,
|
|
@@ -945,7 +947,7 @@ class SecurityController extends NativeController {
|
|
|
945
947
|
{ refresh: request.getRefresh("wait_for"), userId },
|
|
946
948
|
);
|
|
947
949
|
|
|
948
|
-
|
|
950
|
+
this.logger.info(
|
|
949
951
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
950
952
|
request.input.action
|
|
951
953
|
}" on user "${id}."`,
|
|
@@ -972,7 +974,7 @@ class SecurityController extends NativeController {
|
|
|
972
974
|
userId,
|
|
973
975
|
});
|
|
974
976
|
|
|
975
|
-
|
|
977
|
+
this.logger.info(
|
|
976
978
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
977
979
|
request.input.action
|
|
978
980
|
}" on profile "${id}."`,
|
|
@@ -998,7 +1000,7 @@ class SecurityController extends NativeController {
|
|
|
998
1000
|
userId,
|
|
999
1001
|
});
|
|
1000
1002
|
|
|
1001
|
-
|
|
1003
|
+
this.logger.info(
|
|
1002
1004
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
1003
1005
|
request.input.action
|
|
1004
1006
|
}" on role "${id}."`,
|
|
@@ -1053,7 +1055,7 @@ class SecurityController extends NativeController {
|
|
|
1053
1055
|
}
|
|
1054
1056
|
}
|
|
1055
1057
|
|
|
1056
|
-
|
|
1058
|
+
this.logger.info(
|
|
1057
1059
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
1058
1060
|
request.input.action
|
|
1059
1061
|
}".`,
|
|
@@ -1146,7 +1148,7 @@ class SecurityController extends NativeController {
|
|
|
1146
1148
|
|
|
1147
1149
|
const createMethod = this.getStrategyMethod(strategy, "create");
|
|
1148
1150
|
|
|
1149
|
-
|
|
1151
|
+
this.logger.info(
|
|
1150
1152
|
`[SECURITY] ${SecurityController.userOrSdk(
|
|
1151
1153
|
request.getKuid(),
|
|
1152
1154
|
)} applied action "${request.input.action}" on user "${id}."`,
|
|
@@ -1174,7 +1176,7 @@ class SecurityController extends NativeController {
|
|
|
1174
1176
|
|
|
1175
1177
|
const updateMethod = this.getStrategyMethod(strategy, "update");
|
|
1176
1178
|
|
|
1177
|
-
|
|
1179
|
+
this.logger.info(
|
|
1178
1180
|
`[SECURITY] ${SecurityController.userOrSdk(
|
|
1179
1181
|
request.getKuid(),
|
|
1180
1182
|
)} applied action "${request.input.action}" on user "${id}."`,
|
|
@@ -1232,7 +1234,7 @@ class SecurityController extends NativeController {
|
|
|
1232
1234
|
|
|
1233
1235
|
await deleteMethod(request, id, strategy);
|
|
1234
1236
|
|
|
1235
|
-
|
|
1237
|
+
this.logger.info(
|
|
1236
1238
|
`[SECURITY] ${SecurityController.userOrSdk(
|
|
1237
1239
|
request.getKuid(),
|
|
1238
1240
|
)} applied action "${request.input.action}" on user "${id}."`,
|
|
@@ -1347,7 +1349,7 @@ class SecurityController extends NativeController {
|
|
|
1347
1349
|
}
|
|
1348
1350
|
|
|
1349
1351
|
if (successes.length > 1000) {
|
|
1350
|
-
|
|
1352
|
+
this.logger.info(
|
|
1351
1353
|
`[SECURITY] ${SecurityController.userOrSdk(
|
|
1352
1354
|
request.getKuid(),
|
|
1353
1355
|
)} deleted the following ${type}s: ${successes
|
|
@@ -1355,7 +1357,7 @@ class SecurityController extends NativeController {
|
|
|
1355
1357
|
.join(", ")}... (${successes.length - 1000} more users deleted)."`,
|
|
1356
1358
|
);
|
|
1357
1359
|
} else {
|
|
1358
|
-
|
|
1360
|
+
this.logger.info(
|
|
1359
1361
|
`[SECURITY] ${SecurityController.userOrSdk(
|
|
1360
1362
|
request.getKuid(),
|
|
1361
1363
|
)} deleted the following ${type}s: ${successes.join(", ")}."`,
|
|
@@ -1382,7 +1384,7 @@ class SecurityController extends NativeController {
|
|
|
1382
1384
|
},
|
|
1383
1385
|
);
|
|
1384
1386
|
|
|
1385
|
-
|
|
1387
|
+
this.logger.info(
|
|
1386
1388
|
`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${
|
|
1387
1389
|
request.input.action
|
|
1388
1390
|
}" on user "${id}."`,
|
|
@@ -1485,7 +1487,7 @@ class SecurityController extends NativeController {
|
|
|
1485
1487
|
}
|
|
1486
1488
|
|
|
1487
1489
|
if (creationFailure === null) {
|
|
1488
|
-
|
|
1490
|
+
this.logger.info(
|
|
1489
1491
|
`[SECURITY] ${SecurityController.userOrSdk(
|
|
1490
1492
|
request.getKuid(),
|
|
1491
1493
|
)} applied action "${request.input.action}" on user "${id}."`,
|
|
@@ -1509,7 +1511,7 @@ class SecurityController extends NativeController {
|
|
|
1509
1511
|
try {
|
|
1510
1512
|
this.ask("core:security:user:delete", id, { refresh: "false" });
|
|
1511
1513
|
} catch (e) {
|
|
1512
|
-
|
|
1514
|
+
this.logger.error(`User rollback error: ${e}`);
|
|
1513
1515
|
}
|
|
1514
1516
|
|
|
1515
1517
|
if (deletionErrors.length > 0) {
|
package/lib/api/funnel.js
CHANGED
|
@@ -90,6 +90,8 @@ class Funnel {
|
|
|
90
90
|
this.loadDocumentEventAliases();
|
|
91
91
|
|
|
92
92
|
this.sdkCompatibility = sdkCompatibility;
|
|
93
|
+
|
|
94
|
+
this.logger = global.kuzzle.log.child("api:funnel");
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
init() {
|
|
@@ -200,7 +202,7 @@ class Funnel {
|
|
|
200
202
|
global.kuzzle.config.limits.requestsBufferSize,
|
|
201
203
|
) / 100;
|
|
202
204
|
global.kuzzle.emit("core:overload", overloadPercentage);
|
|
203
|
-
|
|
205
|
+
this.logger.warn(
|
|
204
206
|
`[!WARNING!] Kuzzle overloaded: ${overloadPercentage}%. Delaying requests...`,
|
|
205
207
|
);
|
|
206
208
|
|
|
@@ -238,7 +240,7 @@ class Funnel {
|
|
|
238
240
|
) {
|
|
239
241
|
const error = processError.get("overloaded");
|
|
240
242
|
global.kuzzle.emit("log:error", error);
|
|
241
|
-
|
|
243
|
+
this.logger.error(error);
|
|
242
244
|
throw error;
|
|
243
245
|
}
|
|
244
246
|
|
|
@@ -486,7 +488,7 @@ class Funnel {
|
|
|
486
488
|
|
|
487
489
|
// JSON.stringify(new NativeError()) === '{}'
|
|
488
490
|
// i.e. Error, SyntaxError, TypeError, ReferenceError, etc.
|
|
489
|
-
|
|
491
|
+
this.logger.error(
|
|
490
492
|
err instanceof Error && !(err instanceof KuzzleError)
|
|
491
493
|
? `${err.message}\n${err.stack}`
|
|
492
494
|
: err,
|
|
@@ -753,11 +755,31 @@ class Funnel {
|
|
|
753
755
|
* @returns {Promise}
|
|
754
756
|
*/
|
|
755
757
|
async executePluginRequest(request) {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
758
|
+
if (request.input.triggerEvents) {
|
|
759
|
+
let error;
|
|
760
|
+
let res;
|
|
761
|
+
try {
|
|
762
|
+
const { result } = await this.processRequest(request);
|
|
763
|
+
debug(
|
|
764
|
+
"Request %s successfully executed. Result: %a",
|
|
765
|
+
request.id,
|
|
766
|
+
result,
|
|
767
|
+
);
|
|
768
|
+
res = result;
|
|
769
|
+
return { ...result };
|
|
770
|
+
} catch (e) {
|
|
771
|
+
error = e;
|
|
772
|
+
debug("Error processing request %s: %a", request.id, error);
|
|
773
|
+
} finally {
|
|
774
|
+
global.kuzzle.pipe("request:afterExecution", {
|
|
775
|
+
error: error,
|
|
776
|
+
request: request,
|
|
777
|
+
result: res,
|
|
778
|
+
success: error === undefined ? true : false,
|
|
779
|
+
});
|
|
760
780
|
}
|
|
781
|
+
}
|
|
782
|
+
try {
|
|
761
783
|
return await doAction(this.getController(request), request);
|
|
762
784
|
} catch (e) {
|
|
763
785
|
this.handleErrorDump(e);
|
|
@@ -1004,9 +1026,7 @@ class Funnel {
|
|
|
1004
1026
|
(this.lastOverloadTime === 0 || this.lastOverloadTime < now - 500)
|
|
1005
1027
|
) {
|
|
1006
1028
|
this.overloadWarned = false;
|
|
1007
|
-
|
|
1008
|
-
"End of overloaded state. Resuming normal activity.",
|
|
1009
|
-
);
|
|
1029
|
+
this.logger.info("End of overloaded state. Resuming normal activity.");
|
|
1010
1030
|
this.lastOverloadTime = now;
|
|
1011
1031
|
}
|
|
1012
1032
|
}
|
package/lib/cluster/command.js
CHANGED
|
@@ -51,6 +51,7 @@ class ClusterCommand {
|
|
|
51
51
|
this.protoroot = null;
|
|
52
52
|
|
|
53
53
|
this.state = stateEnum.INITIALIZING;
|
|
54
|
+
this.logger = global.kuzzle.log.child("cluster:command");
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
async init() {
|
|
@@ -188,7 +189,7 @@ class ClusterCommand {
|
|
|
188
189
|
} catch (e) {
|
|
189
190
|
// no response from the remote node in a timely fashion... retrying
|
|
190
191
|
// with another one
|
|
191
|
-
|
|
192
|
+
this.logger.warn(
|
|
192
193
|
`Unable to fetch a full state from node ${id} (no response received)`,
|
|
193
194
|
);
|
|
194
195
|
idx = (idx + 1) % nodes.length;
|
|
@@ -269,7 +270,7 @@ class ClusterCommand {
|
|
|
269
270
|
try {
|
|
270
271
|
[, response] = await req.receive();
|
|
271
272
|
} catch (e) {
|
|
272
|
-
|
|
273
|
+
this.logger.warn(
|
|
273
274
|
`Couldn't complete handshake with node ${id}: no response received`,
|
|
274
275
|
);
|
|
275
276
|
} finally {
|
|
@@ -87,6 +87,7 @@ class ClusterIdCardHandler {
|
|
|
87
87
|
* cluster
|
|
88
88
|
*/
|
|
89
89
|
this.disposed = false;
|
|
90
|
+
this.logger = global.kuzzle.log.child("cluster:id-card");
|
|
90
91
|
this.node = node;
|
|
91
92
|
this.ip = node.ip;
|
|
92
93
|
this.refreshDelay = node.heartbeatDelay;
|
|
@@ -171,7 +172,7 @@ class ClusterIdCardHandler {
|
|
|
171
172
|
await this.save();
|
|
172
173
|
}
|
|
173
174
|
catch (error) {
|
|
174
|
-
|
|
175
|
+
this.logger.error(`An error occurred while refreshing the ID card during WorkerThread startup: ${error}`);
|
|
175
176
|
}
|
|
176
177
|
}, this.refreshDelay * this.refreshMultiplier);
|
|
177
178
|
this.refreshWorker.on("message", ({ initialized }) => {
|
package/lib/cluster/node.js
CHANGED
|
@@ -157,6 +157,7 @@ const nodeActivityEnum = Object.freeze({
|
|
|
157
157
|
class ClusterNode {
|
|
158
158
|
constructor() {
|
|
159
159
|
this.config = global.kuzzle.config.cluster;
|
|
160
|
+
this.logger = global.kuzzle.log.child("cluster:node");
|
|
160
161
|
this.heartbeatDelay = this.config.heartbeat;
|
|
161
162
|
|
|
162
163
|
const family = this.config.ipv6 ? "IPv6" : "IPv4";
|
|
@@ -219,7 +220,7 @@ class ClusterNode {
|
|
|
219
220
|
this.registerAskEvents();
|
|
220
221
|
|
|
221
222
|
if (this.countActiveNodes() < this.config.minimumNodes) {
|
|
222
|
-
|
|
223
|
+
this.logger.info(
|
|
223
224
|
"[CLUSTER] Not enough nodes active. Waiting for other nodes to join the cluster...",
|
|
224
225
|
);
|
|
225
226
|
|
|
@@ -286,7 +287,7 @@ class ClusterNode {
|
|
|
286
287
|
await subscriber.sync(lastMessageId);
|
|
287
288
|
await this.idCardHandler.addNode(id);
|
|
288
289
|
|
|
289
|
-
|
|
290
|
+
this.logger.info(`[CLUSTER] Node "${id}" joined the cluster`);
|
|
290
291
|
this.trackActivity(id, ip, nodeActivityEnum.ADDED);
|
|
291
292
|
|
|
292
293
|
if (
|
|
@@ -294,7 +295,7 @@ class ClusterNode {
|
|
|
294
295
|
this.countActiveNodes() >= this.config.minimumNodes
|
|
295
296
|
) {
|
|
296
297
|
global.kuzzle.state = kuzzleStateEnum.RUNNING;
|
|
297
|
-
|
|
298
|
+
this.logger.warn(
|
|
298
299
|
`[CLUSTER] Minimum number of nodes reached (${this.countActiveNodes()}). This node is now accepting requests again.`,
|
|
299
300
|
);
|
|
300
301
|
}
|
|
@@ -310,10 +311,10 @@ class ClusterNode {
|
|
|
310
311
|
* @return {void}
|
|
311
312
|
*/
|
|
312
313
|
async evictSelf(reason, error = null) {
|
|
313
|
-
|
|
314
|
+
this.logger.error(`[CLUSTER] ${reason}`);
|
|
314
315
|
|
|
315
316
|
if (error) {
|
|
316
|
-
|
|
317
|
+
this.logger.error(error.stack);
|
|
317
318
|
}
|
|
318
319
|
|
|
319
320
|
this.publisher.sendNodeEvicted(this.nodeId, this.nodeId, reason);
|
|
@@ -330,15 +331,13 @@ class ClusterNode {
|
|
|
330
331
|
const subscriber = this.remoteNodes.get(nodeId);
|
|
331
332
|
|
|
332
333
|
if (!subscriber) {
|
|
333
|
-
|
|
334
|
+
this.logger.warn(
|
|
334
335
|
`[CLUSTER] Node "${nodeId}" with no subscriber evicted. Reason: ${reason}`,
|
|
335
336
|
);
|
|
336
337
|
return;
|
|
337
338
|
}
|
|
338
339
|
|
|
339
|
-
|
|
340
|
-
`[CLUSTER] Node "${nodeId}" evicted. Reason: ${reason}`,
|
|
341
|
-
);
|
|
340
|
+
this.logger.warn(`[CLUSTER] Node "${nodeId}" evicted. Reason: ${reason}`);
|
|
342
341
|
|
|
343
342
|
this.trackActivity(
|
|
344
343
|
nodeId,
|
|
@@ -358,7 +357,7 @@ class ClusterNode {
|
|
|
358
357
|
|
|
359
358
|
if (this.countActiveNodes() < this.config.minimumNodes) {
|
|
360
359
|
global.kuzzle.state = kuzzleStateEnum.NOT_ENOUGH_NODES;
|
|
361
|
-
|
|
360
|
+
this.logger.warn(
|
|
362
361
|
`[CLUSTER] Not enough nodes active (expected: ${
|
|
363
362
|
this.config.minimumNodes
|
|
364
363
|
}, active: ${this.countActiveNodes()}). Deactivating node until new ones are added.`,
|
|
@@ -471,17 +470,17 @@ class ClusterNode {
|
|
|
471
470
|
}
|
|
472
471
|
|
|
473
472
|
if (candidates.includes(this.nodeId)) {
|
|
474
|
-
|
|
473
|
+
this.logger.error(
|
|
475
474
|
"[CLUSTER] Network split detected. This node is outside the cluster: shutting down.",
|
|
476
475
|
);
|
|
477
476
|
global.kuzzle.shutdown();
|
|
478
477
|
return;
|
|
479
478
|
}
|
|
480
479
|
} catch (err) {
|
|
481
|
-
|
|
480
|
+
this.logger.error(
|
|
482
481
|
"[CLUSTER] Unexpected exception caught during a cluster consistency check. Shutting down...",
|
|
483
482
|
);
|
|
484
|
-
|
|
483
|
+
this.logger.error(err.stack);
|
|
485
484
|
global.kuzzle.shutdown();
|
|
486
485
|
}
|
|
487
486
|
}
|
|
@@ -495,7 +494,7 @@ class ClusterNode {
|
|
|
495
494
|
*/
|
|
496
495
|
async handshake() {
|
|
497
496
|
const handshakeTimeout = setTimeout(() => {
|
|
498
|
-
|
|
497
|
+
this.logger.error(
|
|
499
498
|
`[CLUSTER] Failed to join the cluster: timed out (joinTimeout: ${this.config.joinTimeout}ms)`,
|
|
500
499
|
);
|
|
501
500
|
global.kuzzle.shutdown();
|
|
@@ -538,7 +537,7 @@ class ClusterNode {
|
|
|
538
537
|
const duplicate = nodes.filter((node) => node.ip === this.ip);
|
|
539
538
|
|
|
540
539
|
if (duplicate.length > 0) {
|
|
541
|
-
|
|
540
|
+
this.logger.error(
|
|
542
541
|
`[CLUSTER] Another node share the same IP address as this one (${this.ip}): ${duplicate[0].id}. Shutting down.`,
|
|
543
542
|
);
|
|
544
543
|
global.kuzzle.shutdown();
|
|
@@ -562,7 +561,7 @@ class ClusterNode {
|
|
|
562
561
|
// down.
|
|
563
562
|
if (fullState === null) {
|
|
564
563
|
if (retried) {
|
|
565
|
-
|
|
564
|
+
this.logger.error(
|
|
566
565
|
"[CLUSTER] Could not connect to discovered cluster nodes (network split detected). Shutting down.",
|
|
567
566
|
);
|
|
568
567
|
global.kuzzle.shutdown();
|
|
@@ -578,7 +577,7 @@ class ClusterNode {
|
|
|
578
577
|
// Waits for a redis heartbeat round
|
|
579
578
|
retried = true;
|
|
580
579
|
const retryDelay = this.heartbeatDelay * 1.5;
|
|
581
|
-
|
|
580
|
+
this.logger.warn(
|
|
582
581
|
`[CLUSTER] Unable to connect to discovered cluster nodes. Retrying in ${retryDelay}ms...`,
|
|
583
582
|
);
|
|
584
583
|
await Bluebird.delay(retryDelay);
|
|
@@ -611,13 +610,13 @@ class ClusterNode {
|
|
|
611
610
|
subscriber.sync(
|
|
612
611
|
nodeStatus ? nodeStatus.lastMessageId : handshakeData.lastMessageId,
|
|
613
612
|
);
|
|
614
|
-
|
|
613
|
+
this.logger.info(
|
|
615
614
|
`[CLUSTER] Successfully completed the handshake with node ${nodeId}`,
|
|
616
615
|
);
|
|
617
616
|
}
|
|
618
617
|
}
|
|
619
618
|
|
|
620
|
-
|
|
619
|
+
this.logger.info("[CLUSTER] Successfully joined the cluster.");
|
|
621
620
|
this.trackActivity(this.nodeId, this.ip, nodeActivityEnum.ADDED);
|
|
622
621
|
} finally {
|
|
623
622
|
clearTimeout(handshakeTimeout);
|
|
@@ -103,6 +103,8 @@ class ClusterSubscriber {
|
|
|
103
103
|
Unsubscription: this.handleUnsubscription,
|
|
104
104
|
UserNotification: this.handleUserNotification,
|
|
105
105
|
});
|
|
106
|
+
|
|
107
|
+
this.logger = global.kuzzle.log.child("cluster:subscriber");
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
/**
|
|
@@ -253,7 +255,7 @@ class ClusterSubscriber {
|
|
|
253
255
|
*/
|
|
254
256
|
async handleNodeEviction(message) {
|
|
255
257
|
if (message.nodeId === this.localNode.nodeId) {
|
|
256
|
-
|
|
258
|
+
this.logger.error(
|
|
257
259
|
`[CLUSTER] Node evicted by ${message.evictor}. Reason: ${message.reason}`,
|
|
258
260
|
);
|
|
259
261
|
global.kuzzle.shutdown();
|
|
@@ -518,7 +520,7 @@ class ClusterSubscriber {
|
|
|
518
520
|
"Cluster-wide shutdown request received from node %s",
|
|
519
521
|
this.remoteNodeId,
|
|
520
522
|
);
|
|
521
|
-
|
|
523
|
+
this.logger.error(
|
|
522
524
|
`[CLUSTER] Cluster wide shutdown from ${this.remoteNodeId}`,
|
|
523
525
|
);
|
|
524
526
|
global.kuzzle.shutdown();
|
|
@@ -729,7 +731,7 @@ class ClusterSubscriber {
|
|
|
729
731
|
*/
|
|
730
732
|
async validateMessage(message) {
|
|
731
733
|
if (!has(message, "messageId")) {
|
|
732
|
-
|
|
734
|
+
this.logger.warn(
|
|
733
735
|
`Invalid message received from node ${this.remoteNodeId}. Evicting it.`,
|
|
734
736
|
);
|
|
735
737
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EmbeddedSDK } from "../shared/sdk/embeddedSdk";
|
|
2
2
|
import { EventDefinition, JSONObject } from "../../../index";
|
|
3
|
-
import { BackendCluster, BackendConfig, BackendController, BackendHook, BackendImport, BackendPipe, BackendPlugin, BackendStorage, BackendVault, BackendOpenApi,
|
|
3
|
+
import { BackendCluster, BackendConfig, BackendController, BackendHook, BackendImport, BackendPipe, BackendPlugin, BackendStorage, BackendVault, BackendOpenApi, BackendErrors, BackendSubscription } from "./index";
|
|
4
|
+
import { Logger } from "../../kuzzle/Logger";
|
|
4
5
|
export declare class Backend {
|
|
5
6
|
private _kuzzle;
|
|
6
7
|
private _name;
|
|
@@ -94,7 +95,7 @@ export declare class Backend {
|
|
|
94
95
|
* @method error
|
|
95
96
|
* @method verbose
|
|
96
97
|
*/
|
|
97
|
-
log:
|
|
98
|
+
log: Logger;
|
|
98
99
|
/**
|
|
99
100
|
* Storage manager
|
|
100
101
|
*/
|
|
@@ -146,7 +146,6 @@ class Backend {
|
|
|
146
146
|
this.plugin = new index_1.BackendPlugin(this);
|
|
147
147
|
this.storage = new index_1.BackendStorage(this);
|
|
148
148
|
this.import = new index_1.BackendImport(this);
|
|
149
|
-
this.log = new index_1.InternalLogger(this);
|
|
150
149
|
this.cluster = new index_1.BackendCluster();
|
|
151
150
|
this.openApi = new index_1.BackendOpenApi(this);
|
|
152
151
|
this.errors = new index_1.BackendErrors(this);
|
|
@@ -167,6 +166,7 @@ class Backend {
|
|
|
167
166
|
throw runtimeError.get("already_started", "start");
|
|
168
167
|
}
|
|
169
168
|
this._kuzzle = new kuzzle_1.default(this.config.content);
|
|
169
|
+
this.log = this._kuzzle.log.child(`app`);
|
|
170
170
|
for (const plugin of this.config.content.plugins.common.include) {
|
|
171
171
|
const { default: PluginClass } = await Promise.resolve(`${plugin}`).then(s => __importStar(require(s)));
|
|
172
172
|
this.plugin.use(new PluginClass(), {
|
|
@@ -31,6 +31,8 @@ class CacheEngine {
|
|
|
31
31
|
|
|
32
32
|
this.public = new Redis(config.memoryStorage, "public_adapter");
|
|
33
33
|
this.internal = new Redis(config.internalCache, "internal_adapter");
|
|
34
|
+
|
|
35
|
+
this.logger = global.kuzzle.log.child("core:cache:cacheEngine");
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
@@ -44,7 +46,7 @@ class CacheEngine {
|
|
|
44
46
|
this.registerInternalEvents();
|
|
45
47
|
this.registerPublicEvents();
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
this.logger.info("[✔] Cache initialized");
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
registerInternalEvents() {
|
|
@@ -43,6 +43,7 @@ class AccessLogger {
|
|
|
43
43
|
constructor() {
|
|
44
44
|
this.isActive = false;
|
|
45
45
|
this.worker = null;
|
|
46
|
+
this.logger = global.kuzzle.log.child("core:network:accessLogger");
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
async init() {
|
|
@@ -50,7 +51,7 @@ class AccessLogger {
|
|
|
50
51
|
|
|
51
52
|
for (const out of config.logs.transports) {
|
|
52
53
|
if (out.transport && !ALLOWED_TRANSPORTS.includes(out.transport)) {
|
|
53
|
-
|
|
54
|
+
this.logger.error(
|
|
54
55
|
`Failed to initialize logger transport "${out.transport}": unsupported transport. Skipped.`,
|
|
55
56
|
);
|
|
56
57
|
} else {
|
|
@@ -102,7 +103,7 @@ class AccessLogger {
|
|
|
102
103
|
size,
|
|
103
104
|
});
|
|
104
105
|
} catch (error) {
|
|
105
|
-
|
|
106
|
+
this.logger.error(
|
|
106
107
|
`Failed to write access log for request "${request.id}": ${error.message}`,
|
|
107
108
|
);
|
|
108
109
|
}
|
|
@@ -52,6 +52,8 @@ class EntryPoint {
|
|
|
52
52
|
this.accessLogger = new AccessLogger();
|
|
53
53
|
|
|
54
54
|
this.isShuttingDown = false;
|
|
55
|
+
|
|
56
|
+
this.logger = global.kuzzle.log.child("core:network:entrypoint");
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
dispatch(event, data) {
|
|
@@ -142,7 +144,7 @@ class EntryPoint {
|
|
|
142
144
|
try {
|
|
143
145
|
this.protocols.get(client.protocol).joinChannel(channel, connectionId);
|
|
144
146
|
} catch (e) {
|
|
145
|
-
|
|
147
|
+
this.logger.error(
|
|
146
148
|
`[join] protocol ${client && client.protocol} failed: ${e.message}`,
|
|
147
149
|
);
|
|
148
150
|
}
|
|
@@ -164,7 +166,7 @@ class EntryPoint {
|
|
|
164
166
|
try {
|
|
165
167
|
this.protocols.get(client.protocol).leaveChannel(channel, connectionId);
|
|
166
168
|
} catch (e) {
|
|
167
|
-
|
|
169
|
+
this.logger.error(
|
|
168
170
|
`[leave channel] protocol ${client && client.protocol} failed: ${
|
|
169
171
|
e.message
|
|
170
172
|
}`,
|
|
@@ -202,9 +204,7 @@ class EntryPoint {
|
|
|
202
204
|
return Bluebird.resolve()
|
|
203
205
|
.then(() => protocol.init(this, new Context()))
|
|
204
206
|
.catch((error) => {
|
|
205
|
-
|
|
206
|
-
`Error during "${manifest.name}" protocol init:`,
|
|
207
|
-
);
|
|
207
|
+
this.logger.error(`Error during "${manifest.name}" protocol init:`);
|
|
208
208
|
throw error;
|
|
209
209
|
})
|
|
210
210
|
.timeout(
|
|
@@ -318,7 +318,7 @@ class EntryPoint {
|
|
|
318
318
|
try {
|
|
319
319
|
protocol.broadcast(sanitized);
|
|
320
320
|
} catch (e) {
|
|
321
|
-
|
|
321
|
+
this.logger.error(
|
|
322
322
|
`[broadcast] protocol ${name} failed: ${e.message}\n${e.stack}`,
|
|
323
323
|
);
|
|
324
324
|
}
|
|
@@ -348,7 +348,7 @@ class EntryPoint {
|
|
|
348
348
|
try {
|
|
349
349
|
this.protocols.get(client.protocol).notify(removeStacktrace(data));
|
|
350
350
|
} catch (e) {
|
|
351
|
-
|
|
351
|
+
this.logger.error(
|
|
352
352
|
`[notify] protocol ${client.protocol} failed: ${e.message}`,
|
|
353
353
|
);
|
|
354
354
|
}
|