Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 <build@couchbase.com>
Tested-by: Pavel Blagodov <stochmail@gmail.com>
Reviewed-by: Matthew Dawber <matthew.dawber@couchbase.com>
Reviewed-by: Raluca Lupu <raluca.lupu@couchbase.com>
  • Loading branch information
pavel-blagodov committed Mar 3, 2022
1 parent f271e7f commit 17a34f4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions priv/public/ui/app/mn_admin/mn_statistics_description.js
Expand Up @@ -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": "=~",
Expand All @@ -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) => {
Expand Down Expand Up @@ -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];
},
Expand Down
20 changes: 20 additions & 0 deletions priv/public/ui/app/mn_admin/mn_user_roles_service.js
Expand Up @@ -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)
Expand Down Expand Up @@ -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});
Expand Down

0 comments on commit 17a34f4

Please sign in to comment.