-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CLOUDSTACK-9699: Add global setting for enable/disable Metrics feature #1884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewed-By: Radhika Grover & Koushik Das Added a new global setting called enable.metrics.ui (default false) which allows the metrics button to be enabled/disabled in the UI. Note that when false, the metrics button is not visible at all. This feature has been introduced because metrics feature is not optimized and will cause performance issues in large deployments. Conflicts: api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java server/src/com/cloud/server/ManagementServerImpl.java ui/scripts/cloudStack.js ui/scripts/instances.js ui/scripts/sharedFunctions.js ui/scripts/storage.js ui/scripts/system.js
…ies API and whether it includes enableMetrics parameter. Reviewed-By Koushik Das, Sanjeev N Added junit test case and marvin test case for testing updated listCapabilities API. The junit test case changes involved updating ResponseGenerator and ApiResponseHelper to correctly build the response. Conflicts: api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java server/src/com/cloud/api/ApiResponseHelper.java
Reviewed-By: Radhika Grover & Koushik Das Added a new global setting called enable.metrics.ui (default false) which allows the metrics button to be enabled/disabled in the UI. Note that when false, the metrics button is not visible at all. This feature has been introduced because metrics feature is not optimized and will cause performance issues in large deployments. Conflicts: api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java server/src/com/cloud/server/ManagementServerImpl.java ui/scripts/cloudStack.js ui/scripts/instances.js ui/scripts/sharedFunctions.js ui/scripts/storage.js ui/scripts/system.js
…stack into CLOUDSTACK-9699 Conflicts: api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java server/src/com/cloud/api/ApiResponseHelper.java test/integration/smoke/test_global_settings.py ui/scripts/cloudStack.js ui/scripts/sharedFunctions.js
jburwell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the code feedback, please squash the commits for this PR.
| Mockito.when(mgr.listCapabilities(listCapabilitiesCmd)).thenReturn(result); | ||
| } catch (Exception e) { | ||
| Assert.fail("Received exception when success expected " + e.getMessage()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not perform lines 58-67 in in setUp? Not only would this approach focus this method on the test operations, but remove the need for unnecessary class-level attributes.
Also, catching exceptions is not required because JUnit will automatically fail when exceptions are thrown. If there are checked exceptions, add them to the throws of the test method to keep test methods as succinct as possible.
| listCapabilitiesCmd._mgr = mgr; | ||
| listCapabilitiesCmd._responseGenerator = responseGenerator; | ||
|
|
||
| Map<String, Object> result = new HashMap<String, Object>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider using Collections.emptyMap() instead of allocating a new Map to improve clarity of intention.
| self.assertIsNotNone( | ||
| listCapabilities.enablemetricsui, | ||
| "Failed to fetch enable.metrics.ui" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests to verify that the value is set as expected.
| return ['add', 'viewMetrics', 'uploadVolume', 'uploadVolumefromLocal']; | ||
| else | ||
| return ['add', 'uploadVolume', 'uploadVolumefromLocal']; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the duplication in this function by refactoring as follows:
actionPreFilter: function(args){
actions = ['add', 'uploadVolume', 'uploadVolumefromLocal'];
if (g_enablemetricsui) {
actions.splice(1, 0, 'viewMetrics');
}
return actions;
},
| if (g_enablemetricsui) | ||
| return ['add', 'viewMetrics']; | ||
| else | ||
| return ['add']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the duplication in this function by refactoring as follows:
actions = ['add'];
if (g_enablemetricsui) {
actions.append('viewMetrics');
}
return actions;
| return ['add', 'viewMetrics']; | ||
| else | ||
| return ['add']; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 14096-14101 appear to be a duplication of lines 7857-7860. Can this code duplication be removed?
| return ['add', 'viewMetrics']; | ||
| else | ||
| return ['add']; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please code duplication comments above.
| return ['add', 'viewMetrics']; | ||
| else | ||
| return ['add']; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please code duplication comments above.
| if (listViewData.actions) { | ||
| // If a preFilter is set, then get the values. Else set this to null | ||
| var filteredActions = listViewData.actionPreFilter == undefined ? | ||
| null : listViewData.actionPreFilter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not set to an empty list rather than null to avoid a potential null error?
| // filter out those actions that shouldn't be shown | ||
| if (filteredActions != null | ||
| && (filteredActions.indexOf(actionName) < 0)) | ||
| return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per coding standards, please surround all if blocks with curly braces.
|
Thank you @jburwell. I will incorporate the comments in a couple of days and resubmit. |
|
@rashmidixit I'm working on writing separate metrics view apis (backend/apis), they will improve the performance significantly. An explicit global settings is not necessary, pl. hold on this PR. |
|
I'm working on improving the metrics view feature by implementing the logic as backend APIs, will post a PR this/next week. Thanks. |
|
@rhtyd Thanks for the update. |
|
This is not needed with PR #1944, though changes around capability refactoring can be separated. |
|
Closing this based on the new PR #1944. |
The Metrics view for each type of entity basically fires APIs and calculates required values on the client end. For e.g. to display memory usage etc at the zone level, it will fetch all zones. For each zone it will fetch pods->cluster->host->VMs
For a very large Cloudstack installation this will have a major impact on the performance.
Ideally, there should be an API which calculates all metrics in the backend and the UI should simply show the values. However, for the time, introduce a global setting called enable.metrics which will be set to false. This will cause the metrics button not to be shown on any of the pages.
If the Admin changes this to true, then the button will be visible and Metrics functionality will work as usual.
In this pull request, have also added JUnit test case for listCapabilities API.
Additionally added a test case in marvin called test_global_settings as part of the smoke tests which test the output of the listCapabilities API and checks if this setting is present or not.
Refer to CLOUDSTACK-9699 for more details.