Skip to content

Commit c675f82

Browse files
committed
CLOUDSTACK-4318:[Object_Store_Refactor] Failed to delete snapshot copied
to Staging storage during snapshot creation.
1 parent 8a104b9 commit c675f82

4 files changed

Lines changed: 124 additions & 100 deletions

File tree

engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answe
198198
templateStoreRef.setDownloadPercent(100);
199199
templateStoreRef.setDownloadState(Status.DOWNLOADED);
200200
templateStoreRef.setSize(newTemplate.getSize());
201-
templateStoreRef.setPhysicalSize(newTemplate.getPhysicalSize());
201+
if (newTemplate.getPhysicalSize() != null) {
202+
templateStoreRef.setPhysicalSize(newTemplate.getPhysicalSize());
203+
}
202204
templateStoreDao.update(templateStoreRef.getId(), templateStoreRef);
203205
if (this.getDataStore().getRole() == DataStoreRole.Image) {
204206
VMTemplateVO templateVO = this.imageDao.findById(this.getId());

server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
//
156156
@Local(value = { ConsoleProxyManager.class, ConsoleProxyService.class })
157157
public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxyManager,
158-
VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter {
158+
VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter {
159159
private static final Logger s_logger = Logger.getLogger(ConsoleProxyManagerImpl.class);
160160

161161
private static final int DEFAULT_CAPACITY_SCAN_INTERVAL = 30000; // 30 seconds
@@ -558,7 +558,7 @@ public ConsoleProxyVO startProxy(long proxyVmId) {
558558

559559
// For VMs that are in Stopping, Starting, Migrating state, let client to wait by returning null
560560
// as sooner or later, Starting/Migrating state will be transited to Running and Stopping will be transited
561-
// to
561+
// to
562562
// Stopped to allow
563563
// Starting of it
564564
s_logger.warn("Console proxy is not in correct state to be started: " + proxy.getState());
@@ -661,7 +661,7 @@ public ConsoleProxyVO startNew(long dataCenterId) throws ConcurrentOperationExce
661661
HypervisorType availableHypervisor = _resourceMgr.getAvailableHypervisor(dataCenterId);
662662
template = _templateDao.findSystemVMReadyTemplate(dataCenterId, availableHypervisor);
663663
if (template == null) {
664-
throw new CloudRuntimeException("Not able to find the System templates or not downloaded in zone " + dataCenterId);
664+
throw new CloudRuntimeException("Not able to find the System templates or not downloaded in zone " + dataCenterId);
665665
}
666666

667667
Map<String, Object> context = createProxyInstance(dataCenterId, template);
@@ -707,18 +707,18 @@ protected Map<String, Object> createProxyInstance(long dataCenterId, VMTemplateV
707707
}
708708
defaultNetwork = networks.get(0);
709709
} else {
710-
TrafficType defaultTrafficType = TrafficType.Public;
711-
if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) {
712-
defaultTrafficType = TrafficType.Guest;
713-
}
714-
List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType);
710+
TrafficType defaultTrafficType = TrafficType.Public;
711+
if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) {
712+
defaultTrafficType = TrafficType.Guest;
713+
}
714+
List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType);
715715

716716
// api should never allow this situation to happen
717-
if (defaultNetworks.size() != 1) {
717+
if (defaultNetworks.size() != 1) {
718718
throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type "
719-
+ defaultTrafficType + " when expect to find 1");
719+
+ defaultTrafficType + " when expect to find 1");
720720
}
721-
defaultNetwork = defaultNetworks.get(0);
721+
defaultNetwork = defaultNetworks.get(0);
722722
}
723723

724724
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork, NetworkOffering.SystemManagementNetwork);
@@ -951,7 +951,13 @@ public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCen
951951
ZoneHostInfo zoneHostInfo = zoneHostInfoMap.get(dataCenterId);
952952
if (zoneHostInfo != null && isZoneHostReady(zoneHostInfo)) {
953953
VMTemplateVO template = _templateDao.findSystemVMReadyTemplate(dataCenterId, HypervisorType.Any);
954-
TemplateDataStoreVO templateHostRef = _vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dataCenterId,
954+
if (template == null) {
955+
if (s_logger.isDebugEnabled()) {
956+
s_logger.debug("System vm template is not ready at data center " + dataCenterId + ", wait until it is ready to launch console proxy vm");
957+
}
958+
return false;
959+
}
960+
TemplateDataStoreVO templateHostRef = this._vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dataCenterId,
955961
Status.DOWNLOADED);
956962

957963
if (templateHostRef != null) {
@@ -1282,8 +1288,9 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
12821288
String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key());
12831289
if (cpvmSrvcOffIdStr != null) {
12841290
DiskOffering diskOffering = _diskOfferingDao.findByUuid(cpvmSrvcOffIdStr);
1285-
if (diskOffering == null)
1291+
if (diskOffering == null) {
12861292
diskOffering = _diskOfferingDao.findById(Long.parseLong(cpvmSrvcOffIdStr));
1293+
}
12871294
if (diskOffering != null) {
12881295
_serviceOffering = _offeringDao.findById(diskOffering.getId());
12891296
} else {
@@ -1517,7 +1524,7 @@ public String getScanHandlerName() {
15171524
@Override
15181525
public void onScanStart() {
15191526
// to reduce possible number of DB queries for capacity scan, we run following aggregated queries in preparation
1520-
// stage
1527+
// stage
15211528
_zoneHostInfoMap = getZoneHostInfo();
15221529

15231530
_zoneProxyCountMap = new HashMap<Long, ConsoleProxyLoadInfo>();

0 commit comments

Comments
 (0)