From f7e78f0b8c6afeb00efec9e6acea81ccf2296489 Mon Sep 17 00:00:00 2001 From: yiqianxu Date: Wed, 2 Nov 2022 13:49:36 +0800 Subject: [PATCH] Add try-catch when parsing profiling json string; fix default namespace bug (#346) Signed-off-by: yiqianxu --- CHANGELOG.md | 1 + camera-front/node/routers/file.js | 18 ++++++++++++++---- .../topo-plugin/src/topology/services.ts | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 793ba9fc9..1d7e5eff4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Add request and response payload of `Redis` protocol message to `Span` data. ([#325](https://github.com/CloudDectective-Harmonycloud/kindling/pull/325)) ### Bug fixes +- Fix the topology node naming error in the default namespace.([#346](https://github.com/CloudDectective-Harmonycloud/kindling/pull/346)) - Fix the bug that if `ReadBytes` receives negative numbers as arguments, the program panics with the error of slice outofbound. ([#327](https://github.com/CloudDectective-Harmonycloud/kindling/pull/327)) ## v0.4.1 - 2022-09-21 diff --git a/camera-front/node/routers/file.js b/camera-front/node/routers/file.js index a6e7bc386..f7bfdbe23 100644 --- a/camera-front/node/routers/file.js +++ b/camera-front/node/routers/file.js @@ -114,12 +114,22 @@ router.get('/getTraceFile', function(req, res, next) { let cpuEventsList = []; let cpuEvents = []; - _.forEach(cpuEventStrs, (str) => cpuEventsList.push(JSON.parse(str))); + _.forEach(cpuEventStrs, (str) => { + try { + cpuEventsList.push(JSON.parse(str)) + } catch (error) { + console.error(str); + } + }); cpuEvents = _.map(cpuEventsList, 'labels'); _.forEach(cpuEvents, item => { - item.cpuEvents = JSON.parse(item.cpuEvents); - item.javaFutexEvents = JSON.parse(item.javaFutexEvents); - item.transactionIds = JSON.parse(item.transactionIds); + try { + item.cpuEvents = JSON.parse(item.cpuEvents); + item.javaFutexEvents = JSON.parse(item.javaFutexEvents); + item.transactionIds = JSON.parse(item.transactionIds); + } catch (error) { + console.error(error, item); + } }); let finalResult = { diff --git a/grafana-plugins/topo-plugin/src/topology/services.ts b/grafana-plugins/topo-plugin/src/topology/services.ts index 286c4d9eb..86b0b1815 100644 --- a/grafana-plugins/topo-plugin/src/topology/services.ts +++ b/grafana-plugins/topo-plugin/src/topology/services.ts @@ -30,7 +30,7 @@ export const showServiceOptions = [ // externalTypes:The namespace enumeration value of the current external call -const externalTypes: string[] = ['NOT_FOUND_EXTERNAL', 'NOT_FOUND_INTERNAL', 'EXTERNAL', 'external', 'default']; +const externalTypes: string[] = ['NOT_FOUND_EXTERNAL', 'NOT_FOUND_INTERNAL', 'EXTERNAL', 'external']; // workloadTypes const workloadTypes: string[] = ['workload', 'deployment', 'daemonset', 'statefulset', 'node'];