Skip to content

Conversation

@RodrigoDLopez
Copy link
Contributor

@RodrigoDLopez RodrigoDLopez commented Aug 7, 2020

Description

On these days, when a VM snapshot is deleted, the cloudstack-usage still seeing that snapshot as active and continues billing this deleted snapshot. This PR proposes new methods to handle with vm_snapshot_create and vm_snapshot_delete events.
Also, add some unit tests to cover those new methods.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

How Has This Been Tested?

I don't know why the cloudstack-usage duplicate entries for vm_snapshot. I think this is a bug and I'll fix it in a future PR.
To run tests, I create a VM snapshot and used the cloudmonkey to list usageRecords type=25.

Created at 14:12

() 🐱 > list usagerecords startdate=2020-08-08 enddate=2020-08-08 type=25
{
  "count": 2,
  "usagerecord": [
    {
      "account": "admin",
      "description": "VMSnapshot usage Id: 1 (7b63f2f0-61fc-4034-8438-26e8989e3503)  for VM VM-ccb8b3d9-18aa-40c3-8e13-adde2de9b34b (ccb8b3d9-18aa-40c3-8e13-adde2de9b34b)",
      "enddate": "2020-08-08'T'14:13:31+00:00",
      "name": "i-2-5-VM_VS_20200808141157",
      "rawusage": "0.025106",
      "size": 214749184,
      "startdate": "2020-08-08'T'14:12:01+00:00",
      "usage": "0.025106 Hrs",
      "usagetype": 25,
      "virtualmachineid": "ccb8b3d9-18aa-40c3-8e13-adde2de9b34b",
    },
    {
      "account": "admin",
      "description": "VMSnapshot usage Id: 1 (7b63f2f0-61fc-4034-8438-26e8989e3503)  for VM VM-ccb8b3d9-18aa-40c3-8e13-adde2de9b34b (ccb8b3d9-18aa-40c3-8e13-adde2de9b34b)",
      "enddate": "2020-08-08'T'14:13:31+00:00",
      "name": "i-2-5-VM_VS_20200808141157",
      "rawusage": "0.025106",
      "size": 214749184,
      "startdate": "2020-08-08'T'14:12:01+00:00",
      "usage": "0.025106 Hrs",
      "usagetype": 25,
      "virtualmachineid": "ccb8b3d9-18aa-40c3-8e13-adde2de9b34b",
    }
  ]
}

Deleted at 14:18

() 🐱 > list usagerecords startdate=2020-08-08 enddate=2020-08-08 type=25
{
  "count": 4,
  "usagerecord": [
    {
      "account": "admin",
      "description": "VMSnapshot usage Id: 1 (7b63f2f0-61fc-4034-8438-26e8989e3503)  for VM VM-ccb8b3d9-18aa-40c3-8e13-adde2de9b34b (ccb8b3d9-18aa-40c3-8e13-adde2de9b34b)",
      "enddate": "2020-08-08'T'14:13:31+00:00",
      "name": "i-2-5-VM_VS_20200808141157",
      "rawusage": "0.025106",
      "size": 214749184,
      "startdate": "2020-08-08'T'14:12:01+00:00",
      "usage": "0.025106 Hrs",
      "usagetype": 25,
      "virtualmachineid": "ccb8b3d9-18aa-40c3-8e13-adde2de9b34b",
    },
    {
      "account": "admin",
      "description": "VMSnapshot usage Id: 1 (7b63f2f0-61fc-4034-8438-26e8989e3503)  for VM VM-ccb8b3d9-18aa-40c3-8e13-adde2de9b34b (ccb8b3d9-18aa-40c3-8e13-adde2de9b34b)",
      "enddate": "2020-08-08'T'14:13:31+00:00",
      "name": "i-2-5-VM_VS_20200808141157",
      "rawusage": "0.025106",
      "size": 214749184,
      "startdate": "2020-08-08'T'14:12:01+00:00",
      "usage": "0.025106 Hrs",
      "usagetype": 25,
      "virtualmachineid": "ccb8b3d9-18aa-40c3-8e13-adde2de9b34b",
    },
    {
      "account": "admin",
      "description": "VMSnapshot usage Id: 1 (7b63f2f0-61fc-4034-8438-26e8989e3503)  for VM VM-ccb8b3d9-18aa-40c3-8e13-adde2de9b34b (ccb8b3d9-18aa-40c3-8e13-adde2de9b34b)",
      "enddate": "2020-08-08'T'14:18:31+00:00",
      "name": "i-2-5-VM_VS_20200808141157",
      "rawusage": "0.083337",
      "size": 214749184,
      "startdate": "2020-08-08'T'14:13:31+00:00",
      "usage": "0.083337 Hrs",
      "usagetype": 25,
      "virtualmachineid": "ccb8b3d9-18aa-40c3-8e13-adde2de9b34b",
    },
    {
      "account": "admin",
      "description": "VMSnapshot usage Id: 1 (7b63f2f0-61fc-4034-8438-26e8989e3503)  for VM VM-ccb8b3d9-18aa-40c3-8e13-adde2de9b34b (ccb8b3d9-18aa-40c3-8e13-adde2de9b34b)",
      "enddate": "2020-08-08'T'14:18:31+00:00",
      "name": "i-2-5-VM_VS_20200808141157",
      "rawusage": "0.083337",
      "size": 214749184,
      "startdate": "2020-08-08'T'14:13:31+00:00",
      "usage": "0.083337 Hrs",
      "usagetype": 25,
      "virtualmachineid": "ccb8b3d9-18aa-40c3-8e13-adde2de9b34b",
    }
  ]
}

Create methods to handle with VM snapshot create and delete events
Add unit tests to cover new code
@RodrigoDLopez RodrigoDLopez changed the title Handle with VM snapshot events [WIP] Handle with VM snapshot events Aug 7, 2020
@GabrielBrascher GabrielBrascher added this to the 4.15.0.0 milestone Aug 7, 2020
@DaanHoogland DaanHoogland marked this pull request as draft August 9, 2020 18:39
@DaanHoogland DaanHoogland changed the title [WIP] Handle with VM snapshot events Handle with VM snapshot events Aug 9, 2020
@RodrigoDLopez RodrigoDLopez marked this pull request as ready for review August 10, 2020 21:02
@RodrigoDLopez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@RodrigoDLopez a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔debian. JID-1701

@RodrigoDLopez
Copy link
Contributor Author

@blueorangutan test

@rohityadavcloud
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔debian. JID-1740

@rohityadavcloud
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✖centos8 ✖debian. JID-1843

Copy link
Member

@rohityadavcloud rohityadavcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, did not test it; travis tests LGTM

@rohityadavcloud
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✖centos8 ✖debian. JID-1946

@DaanHoogland
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2043

@rohityadavcloud
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@rohityadavcloud
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2840)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 50708 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4251-t2840-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_supported_versions.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 82 look OK, 3 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_01_add_delete_kubernetes_supported_version Error 1807.27 test_kubernetes_supported_versions.py
test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL Failure 368.65 test_vpc_redundant.py
test_hostha_kvm_host_fencing Error 178.49 test_hostha_kvm.py

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good but the double records are kind of a problem, does this happen in the old/current implementation as well?

@DaanHoogland
Copy link
Contributor

DaanHoogland commented Sep 29, 2020

I don't know why the cloudstack-usage duplicate entries for vm_snapshot. I think this is a bug and I'll fix it in a future PR.

Did you create an issue yet? please do so before merging. maybe these double records should be mentioned in release notes as well (cc @PaulAngus )

@RodrigoDLopez
Copy link
Contributor Author

Hi @DaanHoogland
I saw this bug when I was fixing other issues in the 4.13.1.0 version. On this version, we can see duplicates records for vm_snapshot, I did not test this on master, but I saw the code. The duplicate records will occur on master as well.

As you requested, I will open an issue to report these duplicate records for vm_snapshot on cloud-usage

Copy link
Member

@GabrielBrascher GabrielBrascher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

@rohityadavcloud
Copy link
Member

@nvazquez can you review this? thanks.

Copy link
Contributor

@nvazquez nvazquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, just left a comment

@DaanHoogland
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2187

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2971)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 42028 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4251-t2971-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_clusters.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 83 look OK, 2 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers Failure 338.39 test_vpc_redundant.py
test_hostha_kvm_host_fencing Error 175.20 test_hostha_kvm.py

@DaanHoogland DaanHoogland merged commit d676ffa into apache:master Oct 16, 2020
@RodrigoDLopez RodrigoDLopez deleted the handle_with_vm_snapshot_event branch October 30, 2020 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants