From 70daee9b1047d0d231430fdcab8565cb7adf8fa1 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Thu, 30 Jan 2020 06:42:38 +0100 Subject: [PATCH 1/3] network: set restart_required to 0 after restarting network (#3803) After restarting the network with or without cleanup option, the restart_required field in networks table should be reset to 0. --- .../engine/orchestration/NetworkOrchestrator.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index fc9d96fb522..78f931543e3 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -2936,7 +2936,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra @Override public boolean restartNetwork(final Long networkId, final Account callerAccount, final User callerUser, final boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { - + boolean status = true; + boolean restartRequired = false; final NetworkVO network = _networksDao.findById(networkId); s_logger.debug("Restarting network " + networkId + "..."); @@ -2947,16 +2948,17 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (cleanup) { if (!rollingRestartRouters(network, offering, dest, context)) { - setRestartRequired(network, true); - return false; + status = false; + restartRequired = true; } - return true; + setRestartRequired(network, restartRequired); + return status; } s_logger.debug("Implementing the network " + network + " elements and resources as a part of network restart without cleanup"); try { implementNetworkElementsAndResources(dest, context, network, offering); - setRestartRequired(network, true); + setRestartRequired(network, false); return true; } catch (final Exception ex) { s_logger.warn("Failed to implement network " + network + " elements and resources as a part of network restart due to ", ex); From c22e99c63873efd95e4b79d9d4f15199c40bf7dc Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 5 Feb 2020 12:15:22 +0100 Subject: [PATCH 2/3] test: check more connectivity in test_privategw_acl.py (#3861) --- test/integration/smoke/test_privategw_acl.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/integration/smoke/test_privategw_acl.py b/test/integration/smoke/test_privategw_acl.py index 27328db3eb0..59a31d3baa1 100644 --- a/test/integration/smoke/test_privategw_acl.py +++ b/test/integration/smoke/test_privategw_acl.py @@ -373,12 +373,14 @@ class TestPrivateGwACL(cloudstackTestCase): nat_rule_2 = self.create_natrule(vpc_2, vm2, public_ip_2, network_2) self.check_pvt_gw_connectivity(vm1, public_ip_1, [vm2.nic[0].ipaddress, vm1.nic[0].ipaddress]) + self.check_pvt_gw_connectivity(vm2, public_ip_2, [vm2.nic[0].ipaddress, vm1.nic[0].ipaddress]) if restart_with_cleanup: self.reboot_vpc_with_cleanup(vpc_1, cleanup = restart_with_cleanup) self.reboot_vpc_with_cleanup(vpc_2, cleanup = restart_with_cleanup) self.check_pvt_gw_connectivity(vm1, public_ip_1, [vm2.nic[0].ipaddress, vm1.nic[0].ipaddress]) + self.check_pvt_gw_connectivity(vm2, public_ip_2, [vm2.nic[0].ipaddress, vm1.nic[0].ipaddress]) def performPrivateGWInterfaceTests(self, vpc_off): self.logger.debug("Creating VPCs with offering ID %s" % vpc_off.id) @@ -438,25 +440,32 @@ class TestPrivateGwACL(cloudstackTestCase): public_ip_1 = self.acquire_publicip(vpc_1, network_1) nat_rule_1 = self.create_natrule(vpc_1, vm1, public_ip_1, network_1) + public_ip_2 = self.acquire_publicip(vpc_2, network_2) + nat_rule_2 = self.create_natrule(vpc_2, vm2, public_ip_2, network_2) + self.check_private_gateway_interfaces() self.check_pvt_gw_connectivity(vm1, public_ip_1, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) + self.check_pvt_gw_connectivity(vm2, public_ip_2, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) self.reboot_vpc_with_cleanup(vpc_1, cleanup = True) self.check_routers_state() self.check_pvt_gw_connectivity(vm1, public_ip_1, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) + self.check_pvt_gw_connectivity(vm2, public_ip_2, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) self.stop_router_by_type("MASTER") self.check_routers_state() self.check_private_gateway_interfaces() self.check_pvt_gw_connectivity(vm1, public_ip_1, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) + self.check_pvt_gw_connectivity(vm2, public_ip_2, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) self.start_routers() self.check_routers_state() self.check_private_gateway_interfaces() self.check_pvt_gw_connectivity(vm1, public_ip_1, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) + self.check_pvt_gw_connectivity(vm2, public_ip_2, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) self.deletePvtGw(privateGw_1.id) self.check_private_gateway_interfaces(status_to_check = "DOWN") From bfdb9146932b68ec1c35d3e05c9efdde5a2e271f Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Thu, 6 Feb 2020 11:31:24 +0530 Subject: [PATCH 3/3] usage: publish zone id while uploading template and volume (#3867) After a local template is uploaded via browser, the generated usage event with type = "TEMPLATE.CREATE" is persisted with the data store ID instead of the zone ID on the zone_id column. The fix will refactor the upload monitor logic, as after the upload completes, it sets the datastore ID on the zone ID column for the created "TEMPLATE.CREATE" usage event. This refactor will query the DB for the data store and will set its associated zone ID in the usage field. The fix produces the same behaviour as when registering a template from URL. FIx is also for uploading VOLUME from local/via browser. --- .../com/cloud/storage/ImageStoreUploadMonitorImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/storage/ImageStoreUploadMonitorImpl.java b/server/src/main/java/com/cloud/storage/ImageStoreUploadMonitorImpl.java index 2b39518f8b8..a2f97e84127 100755 --- a/server/src/main/java/com/cloud/storage/ImageStoreUploadMonitorImpl.java +++ b/server/src/main/java/com/cloud/storage/ImageStoreUploadMonitorImpl.java @@ -55,6 +55,8 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; import com.cloud.agent.api.StartupCommand; import com.cloud.alert.AlertManager; +import com.cloud.api.query.dao.TemplateJoinDao; +import com.cloud.api.query.vo.TemplateJoinVO; import com.cloud.configuration.Resource; import com.cloud.event.EventTypes; import com.cloud.event.UsageEventUtils; @@ -111,6 +113,8 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto private TemplateDataFactory templateFactory; @Inject private TemplateService templateService; + @Inject + private TemplateJoinDao templateJoinDao; private long _nodeId; private ScheduledExecutorService _executor = null; @@ -322,7 +326,7 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto // publish usage events UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_UPLOAD, tmpVolume.getAccountId(), - tmpVolumeDataStore.getDataStoreId(), tmpVolume.getId(), tmpVolume.getName(), + tmpVolume.getDataCenterId(), tmpVolume.getId(), tmpVolume.getName(), null, null, tmpVolumeDataStore.getPhysicalSize(), tmpVolumeDataStore.getSize(), Volume.class.getName(), tmpVolume.getUuid()); @@ -425,7 +429,9 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto if (tmpTemplate.getFormat() == Storage.ImageFormat.ISO) { etype = EventTypes.EVENT_ISO_CREATE; } - UsageEventUtils.publishUsageEvent(etype, tmpTemplate.getAccountId(), tmpTemplateDataStore.getDataStoreId(), tmpTemplate.getId(), tmpTemplate.getName(), null, null, + TemplateJoinVO vo = templateJoinDao.findById(tmpTemplate.getId()); + assert (vo != null) : "Couldn't find the template view for given template ID"; + UsageEventUtils.publishUsageEvent(etype, tmpTemplate.getAccountId(), vo.getDataCenterId(), tmpTemplate.getId(), tmpTemplate.getName(), null, null, tmpTemplateDataStore.getPhysicalSize(), tmpTemplateDataStore.getSize(), VirtualMachineTemplate.class.getName(), tmpTemplate.getUuid()); if (s_logger.isDebugEnabled()) {