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
Fix duplicate user entries for vpn usage #4085
Fix duplicate user entries for vpn usage #4085
Conversation
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.
LGTM based on code review.
@blueorangutan package |
@GabrielBrascher a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✖centos7 ✖debian. JID-1290 |
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✖centos7 ✖debian. JID-1293 |
Create a handle for VPN user event. Abstract methods to create and delete VPN user Events Prevents replicated entries for the same user with userId, domainId and zoneId create unit tests to cover new code
63acfe9
to
b6a97ad
Compare
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✔centos7 ✖debian. JID-1305 |
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✔centos7 ✖debian. JID-1350 |
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✔centos7 ✔debian. JID-1360 |
@blueorangutan test |
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✖centos7 ✖debian. JID-1381 |
Hello guys, this is an interesting one. |
@RodrigoDLopez I'm not sure why the packaging failed, I'll kick again |
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✖centos7 ✔debian. JID-1402 |
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✔centos7 ✔debian. JID-1403 |
@blueorangutan test |
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
Trillian test result (tid-1755)
|
Description
Refactor on
UsageManagerImpl.createVPNUserEvent
. Currently, the present method creates and removes a VPN user event. So this PR abstract this method into an handle, and creates methods to create and delete VPN user events.Additionally, the new created method prevents duplicated entries for same user, with same userId, domainId and zoneId
Types of changes
Screenshots (if appropriate):
How Has This Been Tested?
Manual test
To test VPN.USER.ADD event I duplicate a entry on
cloud_usage.usage_event
with:type = 'VPN.USER.ADD'
and processed = 0
Expected: Do not create a entry on
cloud_usage.usage_vpn_user
Result:
2020-04-29 21:35:02,011 DEBUG [cloud.usage.UsageManagerImpl] (Usage-Job-1:null) (logid:) We do not need to create the usage VPN user [4] assigned to account [4] because it already exists.
To test VPN.USER.REMOVE event I duplicate a entry on
cloud_usage.usage_event
with:type = 'VPN.USER.REMOVE'
and processed = 0
Expected: If we have more than one entry for this event, we will delete then all
Result:
2020-04-30 12:01:29,481 DEBUG [cloud.usage.UsageManagerImpl] (Usage-Job-1:null) (logid:) Deleting vpn user [23] assigned to account [4] domain [2] and zone [0] that was created at [Thu Apr 30 11:43:52 AMT 2020].
Result2:
2020-04-30 12:16:06,339 WARN [cloud.usage.UsageManagerImpl] (Usage-Job-1:null) (logid:) No usage entry for vpn user [23] assigned to account [4] domain [2] and zone [0] was found.