From 17a34f41bd18c01123dfe7f56200539b99a3c635 Mon Sep 17 00:00:00 2001 From: Pavel Blagodov Date: Tue, 17 Aug 2021 16:50:41 +0100 Subject: [PATCH] MB-47090: upgrade 7.0 stats names to 7.1 couch_docs_actual_disk_size, couch_docs_data_size, couch_views_actual_disk_size, couch_views_data_size are per bucket stats therefore they have to have appropriate prefix - "@kv-" in this case Change-Id: I83ab9428814365ba323b1e2c26928fd8deb582d3 Reviewed-on: https://review.couchbase.org/c/ns_server/+/159498 Well-Formed: Build Bot Tested-by: Pavel Blagodov Reviewed-by: Matthew Dawber Reviewed-by: Raluca Lupu --- .../app/mn_admin/mn_statistics_description.js | 17 ++++++++++++++++ .../ui/app/mn_admin/mn_user_roles_service.js | 20 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/priv/public/ui/app/mn_admin/mn_statistics_description.js b/priv/public/ui/app/mn_admin/mn_statistics_description.js index c707bb60df..4cacd2457d 100644 --- a/priv/public/ui/app/mn_admin/mn_statistics_description.js +++ b/priv/public/ui/app/mn_admin/mn_statistics_description.js @@ -8,6 +8,13 @@ be governed by the Apache License, Version 2.0, included in the file licenses/APL2.txt. */ + +//stats format anatomy +//example: @kv-.kv_vb_active_sync_write_committed_count +//@kv - stat section +//- - dash means that this is per bucket stat, so bucket label must be specified +//kv_vb_ac.... - stat name + var labelOperators = { "@kv-.kv_dcp_backoff_views+indexes.connection_type": "=~", "@kv-.kv_dcp_connection_count_views+indexes.connection_type": "=~", @@ -34,6 +41,13 @@ var mapping70 = get70Mapping(); var mapping65 = get65Mapping(); +var mapping70to71 = { + "@system.couch_docs_actual_disk_size": "@kv-.couch_docs_actual_disk_size", + "@system.couch_docs_data_size": "@kv-.couch_docs_data_size", + "@system.couch_views_actual_disk_size": "@kv-.couch_views_actual_disk_size", + "@system.couch_views_data_size": "@kv-.couch_views_data_size" +}; + var compat70Combined = propertiesToArray(compat65.stats) .concat(propertiesToArray(compat70.stats)) .reduce((acc, statPath) => { @@ -154,6 +168,9 @@ let service = { mapping65: function (name) { return mapping65[name] || name; }, + upgrade70to71: function (name) { + return mapping70to71[name] || name; + }, maybeGetLabelsModifier: function (service) { return stats70LabelsModifier[service]; }, diff --git a/priv/public/ui/app/mn_admin/mn_user_roles_service.js b/priv/public/ui/app/mn_admin/mn_user_roles_service.js index 4b26bc0e4f..00888d9d66 100644 --- a/priv/public/ui/app/mn_admin/mn_user_roles_service.js +++ b/priv/public/ui/app/mn_admin/mn_user_roles_service.js @@ -263,6 +263,17 @@ function mnUserRolesFactory($q, $http, mnPoolDefault, mnStoreService, mnStatisti }); } + function upgradeChartsNamesTo71(profile) { + profile.charts = profile.charts.map(chart => { + chart.stats = Object.keys(chart.stats) + .reduce((acc, stat70) => { + acc[mnStatsDesc.upgrade70to71(stat70)] = true; + return acc; + }, {}); + return chart; + }); + } + function upgradeChartsNamesTo70(profile) { profile.charts = profile.charts.map(chart => { chart.stats = Object.keys(chart.stats) @@ -317,6 +328,15 @@ function mnUserRolesFactory($q, $http, mnPoolDefault, mnStoreService, mnStatisti charts: profile.charts }).then(getUserProfile); } + if (poolDefault.compat.atLeast71 && (profile.version < poolDefault.versions["71"])) { + upgradeChartsNamesTo71(profile); + return putUserProfile({ + version: poolDefault.versions["71"], + scenarios: profile.scenarios, + groups: profile.groups, + charts: profile.charts + }).then(getUserProfile); + } mnStoreService.createStore("scenarios", {keyPath: "id", fill: profile.scenarios}); mnStoreService.createStore("groups", {keyPath: "id", fill: profile.groups}); mnStoreService.createStore("charts", {keyPath: "id", fill: profile.charts});