From b956438d8d5880ffa22fa1b4478d09e83ee1efad Mon Sep 17 00:00:00 2001 From: psihius Date: Thu, 25 Jul 2019 22:08:33 +0200 Subject: [PATCH 1/3] INVALID REQUEST is not a valid json key for a variable, end up being "undefined" --- master.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master.js b/master.js index f92e3dd8..9ab63d7e 100644 --- a/master.js +++ b/master.js @@ -389,7 +389,7 @@ app.post("/api/getSlaveMeta", function (req, res) { } } else { res.status(400); - res.send('{"INVALID REQUEST":1}'); + res.send('{"INVALID_REQUEST":1}'); } }); // mod management From 3338c439dd1c7c0d785d5eff3a73ffdaaa69dacf Mon Sep 17 00:00:00 2001 From: psihius Date: Thu, 25 Jul 2019 22:20:34 +0200 Subject: [PATCH 2/3] Empty meta fix for querying new slave check --- master.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/master.js b/master.js index 9ab63d7e..6ed5e4a7 100644 --- a/master.js +++ b/master.js @@ -379,17 +379,20 @@ POST Get metadata from a single slave. For whenever you find the data returned b app.post("/api/getSlaveMeta", function (req, res) { endpointHitCounter.labels(req.route.path).inc(); console.log("body", req.body); - if(req.body && req.body.instanceID){ - if (slaves[req.body.instanceID]) { + if(req.body && req.body.instanceID){ + if (slaves[req.body.instanceID]) { console.log("returning meta for ", req.body.instanceID); + if(!slaves[req.body.instanceID].meta) { + slaves[req.body.instanceID].meta = {}; + } res.send(JSON.stringify(slaves[req.body.instanceID].meta)) } else { res.status(404) res.send('{"status": 404, "info": "Slave not registered"}') } } else { - res.status(400); - res.send('{"INVALID_REQUEST":1}'); + res.status(400); + res.send('{"INVALID_REQUEST":1}'); } }); // mod management From 2714b09e5d0cb6e1d41671b59e539ce9a4498ca8 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 26 Jul 2019 18:51:16 +0200 Subject: [PATCH 3/3] Fix wrong argument order Fix compression not applying because the order of the callback and options arguments were swapped in the call to Needle.get for the request_cluster_data function. --- sharedPlugins/researchSync/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sharedPlugins/researchSync/index.js b/sharedPlugins/researchSync/index.js index 33b267ec..395e885a 100644 --- a/sharedPlugins/researchSync/index.js +++ b/sharedPlugins/researchSync/index.js @@ -128,7 +128,7 @@ class ResearchSync { request_cluster_data() { const slaves_data_url = `${this.config.masterIP}:${this.config.masterPort}/api/slaves` - needle.get(slaves_data_url, this.sync_researches.bind(this), {compressed:true}) + needle.get(slaves_data_url, {compressed:true}, this.sync_researches.bind(this)) } sync_researches(err, resp, slaves_data) {