From 6131270b1df68461ee5a9f18afb4daf9eede883b Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 25 May 2020 11:44:07 +0530 Subject: [PATCH 1/8] Update Changelog for 2.10.7 --- Changelog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Changelog b/Changelog index 00d84edf..5068197e 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,13 @@ +2.10.7: 2020-05-25 + * Bugfix: Handle VM templates deleted in OpenNebula but VM instances still existing (MR!736) + Notes for deployment: + When deploying define a UPDATED_TEMPLATES string represented dictionary value in .env +``` + # Represents Template Ids that were + # deleted and the new template Id to look for the template + # definition + UPDATED_TEMPLATES="{1: 100}" +``` 2.10.6: 2020-03-25 * Bugfix: Handle Nonetype for discount's name (MR!735) 2.10.5: 2020-03-17 From 4bff49dab64ad364d08c0a9df13a6edd4a6e5101 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 10 Jun 2020 12:27:59 +0530 Subject: [PATCH 2/8] Refactor polling time to terminate VM --- dynamicweb/settings/base.py | 3 +++ hosting/views.py | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 76135165..03013ea5 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -768,6 +768,9 @@ UPDATED_TEMPLATES_DICT = {} if UPDATED_TEMPLATES_STR: UPDATED_TEMPLATES_DICT = eval(UPDATED_TEMPLATES_STR) +MAX_TIME_TO_WAIT_FOR_VM_TERMINATE = int_env( + 'MAX_TIME_TO_WAIT_FOR_VM_TERMINATE', 15) + if DEBUG: from .local import * # flake8: noqa else: diff --git a/hosting/views.py b/hosting/views.py index 1d16a750..ceecfd79 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1783,11 +1783,11 @@ class VirtualMachineView(LoginRequiredMixin, View): ) response['text'] = str(_('Error terminating VM')) + str(vm.id) else: - for t in range(15): + for t in range(settings.MAX_TIME_TO_WAIT_FOR_VM_TERMINATE): try: manager.get_vm(vm.id) except WrongIdError: - logger.error( + logger.debug( "VM {} not found. So, its terminated.".format(vm.id) ) response['status'] = True @@ -1798,7 +1798,7 @@ class VirtualMachineView(LoginRequiredMixin, View): vm_detail_obj.terminated_at = datetime.utcnow() vm_detail_obj.save() except BaseException as base_exception: - logger.error( + logger.debug( "manager.get_vm({vm_id}) returned exception: " "{details}.".format( details=str(base_exception), vm_id=vm.id @@ -1806,6 +1806,10 @@ class VirtualMachineView(LoginRequiredMixin, View): ) break else: + logger.debug( + 'Sleeping 2 seconds for terminate action on VM %s' % + vm.id + ) sleep(2) if not response['status']: response['text'] = str(_("VM terminate action timed out. " From af36a493662472a51595d6629fc4c22389203cf2 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 10 Jun 2020 13:36:30 +0530 Subject: [PATCH 3/8] Revert back errors --- hosting/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index ceecfd79..1bd7c1aa 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1787,7 +1787,7 @@ class VirtualMachineView(LoginRequiredMixin, View): try: manager.get_vm(vm.id) except WrongIdError: - logger.debug( + logger.error( "VM {} not found. So, its terminated.".format(vm.id) ) response['status'] = True @@ -1798,7 +1798,7 @@ class VirtualMachineView(LoginRequiredMixin, View): vm_detail_obj.terminated_at = datetime.utcnow() vm_detail_obj.save() except BaseException as base_exception: - logger.debug( + logger.error( "manager.get_vm({vm_id}) returned exception: " "{details}.".format( details=str(base_exception), vm_id=vm.id From 81eee87fb93c9bb51f4dc20154740b021977cce8 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 10 Jun 2020 13:45:46 +0530 Subject: [PATCH 4/8] Update Changelog for 2.10.8 --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 5068197e..1bb0ff37 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2.10.8: 2020-06-10 + * #8102: Refactor MAX_TIME_TO_WAIT_FOR_VM_TERMINATE to increase time to poll whether VM has been terminated or not (MR!737) 2.10.7: 2020-05-25 * Bugfix: Handle VM templates deleted in OpenNebula but VM instances still existing (MR!736) Notes for deployment: From 495e7d4022068e06f1ad969c16ca9b95c6dbfc42 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 11 Jun 2020 11:29:32 +0530 Subject: [PATCH 5/8] Fix wrong constant name settings.LDAP_MAX_UID_PATH -> settings.LDAP_MAX_UID_FILE_PATH --- utils/ldap_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/ldap_manager.py b/utils/ldap_manager.py index 8c555224..ee190732 100644 --- a/utils/ldap_manager.py +++ b/utils/ldap_manager.py @@ -266,7 +266,7 @@ class LdapManager: logger.error( "Error reading int value from {}. {}" "Returning default value {} instead".format( - settings.LDAP_MAX_UID_PATH, + settings.LDAP_MAX_UID_FILE_PATH, str(ve), settings.LDAP_DEFAULT_START_UID ) From eadbebb79659f50f4bed0f23853c72110b9e70da Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 11 Jun 2020 11:34:56 +0530 Subject: [PATCH 6/8] Update Changelog for 2.11 --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 1bb0ff37..b22ce6f5 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2.11: 2020-06-11 + * Bugfix: Correct the wrong constant name (caused payment to go thru and showing error and VMs not instantiated) (MR!738) 2.10.8: 2020-06-10 * #8102: Refactor MAX_TIME_TO_WAIT_FOR_VM_TERMINATE to increase time to poll whether VM has been terminated or not (MR!737) 2.10.7: 2020-05-25 From a52215bb56f280d7f83d348ac8dbe742db9e08c7 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 11 Jun 2020 11:42:23 +0530 Subject: [PATCH 7/8] Update Changelog --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index b22ce6f5..33bf7dc9 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,5 @@ 2.11: 2020-06-11 - * Bugfix: Correct the wrong constant name (caused payment to go thru and showing error and VMs not instantiated) (MR!738) + * Bugfix: Correct the wrong constant name (caused payment to go thru and showing error and VMs not instantiated) 2.10.8: 2020-06-10 * #8102: Refactor MAX_TIME_TO_WAIT_FOR_VM_TERMINATE to increase time to poll whether VM has been terminated or not (MR!737) 2.10.7: 2020-05-25 From bc69cc49e5773320a22ab94551fd14754ccdb179 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 11 Jun 2020 15:20:42 +0530 Subject: [PATCH 8/8] Move opennebula specific code to celery to make it asynchronous --- datacenterlight/views.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 17a0479f..ee97a447 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -1011,14 +1011,6 @@ class OrderConfirmationView(DetailView, FormView): user_hosting_key = UserHostingKey.objects.get(id=self.request.session['new_user_hosting_key_id']) user_hosting_key.user = new_user user_hosting_key.save() - - owner = new_user - manager = OpenNebulaManager( - email=owner.username, - password=owner.password - ) - keys_to_save = get_all_public_keys(new_user) - manager.save_key_in_opennebula_user('\n'.join(keys_to_save)) else: # We assume that if the user is here, his/her StripeCustomer # object already exists