Uh oh!
There was an error while loading. Please reload this page.
[CLOUDSTACK-9338] ACS is not accounting resources of VMs with custom service offering properly - #2443
Conversation
…vice offering ACS is accounting the resources properly when deploying VMs with custom service offerings. However, there are other methods (such as updateResourceCount) that do not execute the resource accounting properly, and these methods update the resource count for an account in the database. Therefore, if a user deploys VMs with custom service offerings, and later this user calls the “updateResourceCount” method, it (the method) will only account for VMs with normal service offerings, and update this as the number of resources used by the account. This will result in a smaller number of resources to be accounted for the given account than the real used value. The problem becomes worse because if the user starts to delete these VMs, it is possible to reach negative values of resources allocated (breaking all of the resource limiting for accounts). This is a very serious attack vector for public cloud providers!
045df31 to
7f934c0CompareDaanHoogland
commented
Feb 1, 2018
@rafaelweingartner your code looks good at first sight. Are you writing automation tests for this? I think the PR merrits it |
rafaelweingartner
commented
Feb 1, 2018
I can write one if you think it is worth it. I have never created one though. |
bwsw
commented
Feb 2, 2018
@rafaelweingartner Nb. Please keep in mind to check that domain resources are accounted correctly too. Also, I strongly believe resources should be updated with increment/decrement merhods, but updateResourceCount is only should be used to do periodic update for top level domains when a/b/c/account is used and we would like to update for b and a... |
DaanHoogland
commented
Feb 2, 2018
As @bwsw (wow a company involved) says, accounting is important and needs a lot of tlc. If we don't make regression tests and write fix over fix, regressions are bound to happen, @rafaelweingartner . So if you have the mental and clock space for it , please do. |
@DaanHoogland, @bwsw I have been trying to understand how to do this test case using that "test library" that we have in ACS. It feels a lot of copy and paste on those test "file/scripts" is that the way it is supposed to be? Ins't there a straightforward way? I only need to execute a call to ACS, create a custom service offering, deploy a vm using this service offering, and then calling the resource count method and check its return. I was expecting something clever, where I could simply configure my cloudstack api calls knowing that there will be a cloudstack setup for me. I only need to create a custom service offering, deploy a vm with it, and then call the resource count method and check its result. |
DaanHoogland
commented
Feb 6, 2018
well, there is a lot of integration test code that could be done with a bunch of mocks and a good unit test of course. I have no idea if that applies in this case, but maybe it's worth a try. |
rafaelweingartner
commented
Feb 6, 2018
Well, here is a case that I have not solved with my self yet. The logic is in the SQL. I know it works this way because I tested manually. I could write down a unit test case to see if the SQL is the one I designed to be, but this does not look much elegant to me. I got marvin working, I am now developing the test case using it. |
ustcweizhou
commented
Feb 6, 2018
you can use UserVmJoinDao instead of SQL. |
rafaelweingartner
commented
Feb 6, 2018
@DaanHoogland, and @bwsw Finally I managed to understand how to create and use this thing to create the python test cases. It should be easier to learn and write these tests (there is also the possibility that I am not that smart).... I created a new test case called "test_01_updateResourceCount". |
f09004e to
601d095Compare
DaanHoogland
left a comment
There was a problem hiding this comment.
You are way smarter than me @rafaelweingartner , don't be begging for my sympathy.
borisstoyanov
commented
Feb 21, 2018
@blueorangutan package |
blueorangutan
commented
Feb 21, 2018
@borisstoyanov a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
blueorangutan
commented
Feb 21, 2018
Packaging result: ✔centos6 ✔centos7 ✖debian. JID-1729 |
borisstoyanov
commented
Feb 21, 2018
@blueorangutan test |
blueorangutan
commented
Feb 21, 2018
@borisstoyanov a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
borisstoyanov
commented
Feb 22, 2018
@blueorangutan test |
blueorangutan
commented
Feb 22, 2018
@borisstoyanov a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
blueorangutan
commented
Feb 22, 2018
Trillian test result (tid-2277)
|
rafaelweingartner
commented
Feb 22, 2018
@bwsw are you +1 here? |
yadvr
commented
May 4, 2018
@rafaelweingartner I scanned PRs merged on master but not 4.11 and came across this PR, since this is marked 'bug' do you think this would be useful for 4.11? If so, can you help create a backport PR for 4.11? |
rafaelweingartner
commented
May 4, 2018
I have not seen complains about this before. That is one of the reason why I target most of these things to master. It seems that we were the only ones having these needs. This one only happens if you use custom service offering. |
yadvr
commented
May 4, 2018
@rafaelweingartner yes, but any bug fixes are welcome on LTS branch. The issue such as this may affect users around usage/billing if cloudstack providers are offering custom offering to users. |
rafaelweingartner
commented
May 4, 2018
Sure. Would you like me do to the cherry-pick on 4.11 branch? |
yadvr
commented
May 4, 2018
@rafaelweingartner cherry-pick might fail, can you submit a PR to 4.11 branch or you can also push on my backport PR: #2621 |
Description
ACS accounts the resources when deploying VMs with custom service offerings. However, there are other methods (such as updateResourceCount) that do not execute the resource accounting properly, and these methods update the resource count for an account in the database. Therefore, if a user deploys VMs with custom service offerings, and later this user calls the “updateResourceCount” method, it (the method) will only account for VMs with normal service offerings, and update this as the number of resources used by the account. This will result in a smaller number of resources to be accounted for the given account than the real used value. The problem becomes worse because if the user starts to delete these VMs, it is possible to reach negative values of resources allocated (breaking all of the resource limiting for accounts). This is a very serious attack vector for public cloud providers!
Steps to reproduce: