-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CLOUDSTACK-9665 List hosts api does not report correct cpu and memory… #2120
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,8 +154,10 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail | |
| Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity(); | ||
| Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity(); | ||
|
|
||
| hostResponse.setMemoryTotal(mem); | ||
| Float totalMemorywithOverprovisioning=new Float((host.getTotalMemory()*ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId()))); | ||
| hostResponse.setMemWithOverprovisioning(totalMemorywithOverprovisioning.toString()); | ||
| hostResponse.setMemoryAllocated(mem); | ||
| hostResponse.setMemoryTotal(host.getTotalMemory()); | ||
|
|
||
| String hostTags = host.getTag(); | ||
| hostResponse.setHostTags(host.getTag()); | ||
|
|
@@ -173,10 +175,10 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail | |
|
|
||
| hostResponse.setHypervisorVersion(host.getHypervisorVersion()); | ||
|
|
||
| String cpuAlloc = decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "%"; | ||
| Float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId())); | ||
| String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)) + "%"; | ||
| hostResponse.setCpuAllocated(cpuAlloc); | ||
| String cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor()).toString(); | ||
| hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning); | ||
| hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString()); | ||
| } | ||
|
|
||
| if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) { | ||
|
|
@@ -297,8 +299,10 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu | |
| Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity(); | ||
| Long cpu = host.getCpuReservedCapacity() + host.getCpuReservedCapacity(); | ||
|
|
||
| hostResponse.setMemoryAllocated(mem); | ||
| hostResponse.setMemoryTotal(host.getTotalMemory()); | ||
| hostResponse.setMemoryTotal(mem); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this also needs to be fixed. |
||
| Float memWithOverprovisioning =new Float((host.getTotalMemory()*ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId()))); | ||
| hostResponse.setMemWithOverprovisioning(memWithOverprovisioning.toString()); | ||
| hostResponse.setMemoryAllocated(decimalFormat.format((float)mem/ memWithOverprovisioning*100f).toString()+"%"); | ||
|
|
||
| String hostTags = host.getTag(); | ||
| hostResponse.setHostTags(host.getTag()); | ||
|
|
@@ -316,10 +320,10 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu | |
|
|
||
| hostResponse.setHypervisorVersion(host.getHypervisorVersion()); | ||
|
|
||
| String cpuAlloc = decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "%"; | ||
| Float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId())); | ||
| String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)).toString() + "%"; | ||
| hostResponse.setCpuAllocated(cpuAlloc); | ||
| String cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor()).toString(); | ||
| hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning); | ||
| hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString()); | ||
| } | ||
|
|
||
| if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hey guys,
Looks like there is a flaw with the logic. We have a cluster of XenServer hosts with 512 GB of RAM and the UI shows ~170 GB of RAM. This is not even including the overprovisioning factor. Can you please check the logic around here
here
getMemReservedCapacityis for most cases 0 which leads tomem = host.getMemUsedCapacity()and laterhostResponse.setMemoryTotal(mem)which is wrong. Can you please explain the logic here? @bvbharatk @karuturi ?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.
Jira ticket created: https://issues.apache.org/jira/browse/CLOUDSTACK-10001
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.
@syed I agree. I think this should just be
hostResponse.setMemoryTotal(host.getTotalMemory());