-
Notifications
You must be signed in to change notification settings - Fork 1.2k
server: fix NaN metrics for external resources #11302
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -207,8 +207,7 @@ private void setNewHostResponseBase(HostJoinVO host, EnumSet<HostDetails> detail | |||||
| hostResponse.setMemWithOverprovisioning(decimalFormat.format(memWithOverprovisioning)); | ||||||
| hostResponse.setMemoryAllocated(mem); | ||||||
| hostResponse.setMemoryAllocatedBytes(mem); | ||||||
| String memoryAllocatedPercentage = decimalFormat.format((float) mem / memWithOverprovisioning * 100.0f) +"%"; | ||||||
| hostResponse.setMemoryAllocatedPercentage(memoryAllocatedPercentage); | ||||||
| hostResponse.setMemoryAllocatedPercentage(calculateResourceAllocatedPercentage(mem, memWithOverprovisioning)); | ||||||
|
|
||||||
| String hostTags = host.getTag(); | ||||||
| hostResponse.setHostTags(hostTags); | ||||||
|
|
@@ -401,6 +400,9 @@ public List<HostJoinVO> findByClusterId(Long clusterId, Host.Type type) { | |||||
| } | ||||||
|
|
||||||
| private String calculateResourceAllocatedPercentage(float resource, float resourceWithOverProvision) { | ||||||
| if (resource == 0 || resourceWithOverProvision == 0) { | ||||||
| return "0.00%"; | ||||||
| } | ||||||
| DecimalFormat decimalFormat = new DecimalFormat("#.##"); | ||||||
| return decimalFormat.format(((float)resource / resourceWithOverProvision * 100.0f)) + "%"; | ||||||
|
||||||
| return decimalFormat.format(((float)resource / resourceWithOverProvision * 100.0f)) + "%"; | |
| return decimalFormat.format((resource / resourceWithOverProvision * 100.0f)) + "%"; |
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.
Can be a separate PR/change as not touched here
Uh oh!
There was an error while loading. Please reload this page.