From 1be337fbc50eb4ee2337f20372dc2963bf46a454 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Sat, 13 Feb 2021 00:23:30 +0900 Subject: [PATCH 1/3] make nodes with only group change not deployed by nodes deploy mode --- packages/node_modules/@node-red/runtime/lib/flows/index.js | 3 ++- packages/node_modules/@node-red/runtime/lib/flows/util.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/runtime/lib/flows/index.js b/packages/node_modules/@node-red/runtime/lib/flows/index.js index b31dc7755..16d81d4a2 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/index.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/index.js @@ -148,7 +148,8 @@ function setFlows(_config,_credentials,type,muteLog,forceStart,user) { // Parse the configuration newFlowConfig = flowUtil.parseConfig(clone(config)); // Generate a diff to identify what has changed - diff = flowUtil.diffConfigs(activeFlowConfig,newFlowConfig); + diff = flowUtil.diffConfigs(activeFlowConfig,newFlowConfig, + (type === "nodes")); // Now the flows have been compared, remove any credentials from newFlowConfig // so they don't cause false-positive diffs the next time a flow is deployed diff --git a/packages/node_modules/@node-red/runtime/lib/flows/util.js b/packages/node_modules/@node-red/runtime/lib/flows/util.js index 31c822313..f7478e820 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/util.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/util.js @@ -271,7 +271,7 @@ module.exports = { parseConfig: parseConfig, - diffConfigs: function(oldConfig, newConfig) { + diffConfigs: function(oldConfig, newConfig, ignoreGroup) { var id; var node; var nn; @@ -438,6 +438,9 @@ module.exports = { if (newConfig.allNodes.hasOwnProperty(id)) { node = newConfig.allNodes[id]; for (var prop in node) { + if (ignoreGroup && (prop === "g")) { + continue; + } if (node.hasOwnProperty(prop) && prop != "z" && prop != "id" && prop != "wires") { // This node has a property that references a changed/removed node // Assume it is a config node change and mark this node as From b66468c4ea26af9dbcdd49611b52757bdba39f34 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Sun, 14 Feb 2021 10:06:46 +0900 Subject: [PATCH 2/3] restart node only if node's group changes --- .../@node-red/runtime/lib/flows/index.js | 3 +-- .../@node-red/runtime/lib/flows/util.js | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/node_modules/@node-red/runtime/lib/flows/index.js b/packages/node_modules/@node-red/runtime/lib/flows/index.js index 16d81d4a2..b31dc7755 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/index.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/index.js @@ -148,8 +148,7 @@ function setFlows(_config,_credentials,type,muteLog,forceStart,user) { // Parse the configuration newFlowConfig = flowUtil.parseConfig(clone(config)); // Generate a diff to identify what has changed - diff = flowUtil.diffConfigs(activeFlowConfig,newFlowConfig, - (type === "nodes")); + diff = flowUtil.diffConfigs(activeFlowConfig,newFlowConfig); // Now the flows have been compared, remove any credentials from newFlowConfig // so they don't cause false-positive diffs the next time a flow is deployed diff --git a/packages/node_modules/@node-red/runtime/lib/flows/util.js b/packages/node_modules/@node-red/runtime/lib/flows/util.js index f7478e820..6e4ed35fc 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/util.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/util.js @@ -438,15 +438,25 @@ module.exports = { if (newConfig.allNodes.hasOwnProperty(id)) { node = newConfig.allNodes[id]; for (var prop in node) { - if (ignoreGroup && (prop === "g")) { - continue; - } if (node.hasOwnProperty(prop) && prop != "z" && prop != "id" && prop != "wires") { // This node has a property that references a changed/removed node // Assume it is a config node change and mark this node as // changed. - if (changed[node[prop]] || removed[node[prop]]) { + + var changeOrigin = changed[node[prop]]; + if (changeOrigin || removed[node[prop]]) { if (!changed[node.id]) { + if (changeOrigin && + (prop === "g") && + (changeOrigin.type === "group")) { + var oldNode = oldConfig.allNodes[node.id]; + // ignore change of group node + // if group of this node not changed + if (oldNode && + (node.g === oldNode.g)) { + continue; + } + } madeChange = true; changed[node.id] = node; // This node exists within subflow template From 12c7238c72499b46c93c529b939b41d6dc8ce8d4 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Mon, 15 Feb 2021 22:05:42 +0900 Subject: [PATCH 3/3] revert diffConfigs args --- packages/node_modules/@node-red/runtime/lib/flows/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/runtime/lib/flows/util.js b/packages/node_modules/@node-red/runtime/lib/flows/util.js index 6e4ed35fc..edb348ac4 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/util.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/util.js @@ -271,7 +271,7 @@ module.exports = { parseConfig: parseConfig, - diffConfigs: function(oldConfig, newConfig, ignoreGroup) { + diffConfigs: function(oldConfig, newConfig) { var id; var node; var nn;