[ https://issues.apache.org/jira/browse/CLOUDSTACK-6024?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daan Hoogland updated CLOUDSTACK-6024: -------------------------------------- Fix Version/s: 4.4.0 > template copy to primary storage uses a random source secstorage from any zone > ------------------------------------------------------------------------------ > > Key: CLOUDSTACK-6024 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-6024 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the > default.) > Affects Versions: 4.2.1, 4.1.2, 4.4.0 > Environment: Multiple zones where the secstorage of a zone is not > accessible to hosts from the other zone. > Reporter: Joris van Lieshout > Assignee: Daan Hoogland > Priority: Blocker > Fix For: 4.3.0, 4.4.0 > > > 2014-02-04 15:19:07,674 DEBUG [cloud.storage.VolumeManagerImpl] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) > Checking if we need to prepare 1 volumes for VM[User|xxxxxx-app01] > 2014-02-04 15:19:07,693 DEBUG [storage.image.TemplateDataFactoryImpl] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) > template 467 is already in store:117, type:Image > // store 117 is not accessible from the zone where this hypervisor lives > 2014-02-04 15:19:07,705 DEBUG [storage.datastore.PrimaryDataStoreImpl] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) Not > found (templateId:467poolId:208) in template_spool_ref, persisting it > 2014-02-04 15:19:07,718 DEBUG [storage.image.TemplateDataFactoryImpl] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) > template 467 is already in store:208, type:Primary > 2014-02-04 15:19:07,722 DEBUG [storage.volume.VolumeServiceImpl] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) Found > template 467-2-6c05b599-95ed-34c3-b8f0-fd9c30bac938 in storage pool 208 with > VMTemplateStoragePool id: 36433 > 2014-02-04 15:19:07,732 DEBUG [storage.volume.VolumeServiceImpl] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) > Acquire lock on VMTemplateStoragePool 36433 with timeout 3600 seconds > 2014-02-04 15:19:07,737 INFO [storage.volume.VolumeServiceImpl] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) lock > is acquired for VMTemplateStoragePool 36433 > 2014-02-04 15:19:07,748 DEBUG [storage.motion.AncientDataMotionStrategy] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) > copyAsync inspecting src type TEMPLATE copyAsync inspecting dest type TEMPLATE > 2014-02-04 15:19:07,775 DEBUG [agent.manager.ClusteredAgentAttache] > (Job-Executor-92:job-221857 = [ 6f2d5dbb-575e-49b9-89dd-d7567869849e ]) Seq > 93-1862347354: Forwarding Seq 93-1862347354: { Cmd , MgmtId: 345052370018, > via: 93, Ver: v1, Flags: 100111, > [{"org.apache.cloudstack.storage.command.CopyCommand":{"srcTO":{"org.apache.cloudstack.storage.to.TemplateObjectTO":{"path":"template/tmpl/2/467/c263eb76-3d72-3732-8cc6-42b0dad55c4d.vhd","origUrl":"http://xxxxx.xxxxx.com/image/centos64x64-daily-v1b104.vhd","uuid":"ca5e3f26-e9b6-41c8-a85b-df900be5673c","id":467,"format":"VHD","accountId":2,"checksum":"604a8327bd83850ed621ace2ea84402a","hvm":true,"displayText":"centos > template created by hans.pl from machine name > centos-daily-b104","imageDataStore":{"com.cloud.agent.api.to.NfsTO":{"_url":"nfs://xxxxxxxx.storage.xxxx.xxxxxx.xxx/volumes/pool0/xxxx-xxxx-1-1","_role":"Image"}},"name":"467-2-6c05b599-95ed-34c3-b8f0-fd9c30bac938","hypervisorType":"XenServer"}},"destTO":{"org.apache.cloudstack.storage.to.TemplateObjectTO":{"origUrl":"http://xxxxxx.xxxxxx.com/image/centos64x64-daily-v1b104.vhd","uuid":"ca5e3f26-e9b6-41c8-a85b-df900be5673c","id":467,"format":"VHD","accountId":2,"checksum":"604a8327bd83850ed621ace2ea84402a","hvm":true,"displayText":"centos > template created by hans.pl from machine name > centos-daily-b104","imageDataStore":{"org.apache.cloudstack.storage.to.PrimaryDataStoreTO":{"uuid":"b290385b-466d-3243-a939-3d242164e034","id":208,"poolType":"NetworkFilesystem","host":"xxxxxxxx.xxxx.xxxxx.net","path":"/volumes/pool0/xxxxxx-XEN-1","port":2049}},"name":"467-2-6c05b599-95ed-34c3-b8f0-fd9c30bac938","hypervisorType":"XenServer"}},"executeInSequence":true,"wait":10800}}] > } to 345052370017 > ===FILE: server/src/com/cloud/storage/VolumeManagerImpl.java > public void prepare(VirtualMachineProfile<? extends VirtualMachine> vm, > DeployDestination dest) throws StorageUnavailableException, > InsufficientStorageCapacityException, > ConcurrentOperationException { > if (dest == null) { > if (s_logger.isDebugEnabled()) { > s_logger.debug("DeployDestination cannot be null, cannot > prepare Volumes for the vm: " > + vm); > } > throw new CloudRuntimeException( > "Unable to prepare Volume for vm because > DeployDestination is null, vm:" > + vm); > } > List<VolumeVO> vols = > _volsDao.findUsableVolumesForInstance(vm.getId()); > if (s_logger.isDebugEnabled()) { > s_logger.debug("Checking if we need to prepare " + vols.size() > + " volumes for " + vm); > } > List<VolumeTask> tasks = getTasks(vols, dest.getStorageForDisks()); > Volume vol = null; > StoragePool pool = null; > for (VolumeTask task : tasks) { > if (task.type == VolumeTaskType.NOP) { > pool = > (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), > DataStoreRole.Primary); > vol = task.volume; > } else if (task.type == VolumeTaskType.MIGRATE) { > pool = > (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), > DataStoreRole.Primary); > vol = migrateVolume(task.volume, pool); > } else if (task.type == VolumeTaskType.RECREATE) { > Pair<VolumeVO, DataStore> result = > recreateVolume(task.volume, vm, dest); > pool = > (StoragePool)dataStoreMgr.getDataStore(result.second().getId(), > DataStoreRole.Primary); > vol = result.first(); > } > DataTO volumeTO = volFactory.getVolume(vol.getId()).getTO(); > DiskTO disk = new DiskTO(volumeTO, vol.getDeviceId(), null, > vol.getVolumeType()); > vm.addDisk(disk); > } > } > private Pair<VolumeVO, DataStore> recreateVolume(VolumeVO vol, > VirtualMachineProfile<? extends VirtualMachine> vm, > DeployDestination dest) throws StorageUnavailableException { > VolumeVO newVol; > boolean recreate = _recreateSystemVmEnabled; > DataStore destPool = null; > if (recreate > && (dest.getStorageForDisks() == null || dest > .getStorageForDisks().get(vol) == null)) { > destPool = dataStoreMgr.getDataStore(vol.getPoolId(), > DataStoreRole.Primary); > s_logger.debug("existing pool: " + destPool.getId()); > } else { > StoragePool pool = dest.getStorageForDisks().get(vol); > destPool = dataStoreMgr.getDataStore(pool.getId(), > DataStoreRole.Primary); > } > if (vol.getState() == Volume.State.Allocated > || vol.getState() == Volume.State.Creating) { > newVol = vol; > } else { > newVol = switchVolume(vol, vm); > // update the volume->PrimaryDataStoreVO map since volumeId has > // changed > if (dest.getStorageForDisks() != null > && dest.getStorageForDisks().containsKey(vol)) { > StoragePool poolWithOldVol = dest > .getStorageForDisks().get(vol); > dest.getStorageForDisks().put(newVol, poolWithOldVol); > dest.getStorageForDisks().remove(vol); > } > if (s_logger.isDebugEnabled()) { > s_logger.debug("Created new volume " + newVol > + " for old volume " + vol); > } > } > VolumeInfo volume = volFactory.getVolume(newVol.getId(), destPool); > Long templateId = newVol.getTemplateId(); > for (int i = 0; i < 2; i++) { > // retry one more time in case of template reload is required for > Vmware case > AsyncCallFuture<VolumeApiResult> future = null; > if (templateId == null) { > future = volService.createVolumeAsync(volume, destPool); > } else { > TemplateInfo templ = tmplFactory.getTemplate(templateId, > DataStoreRole.Image); > future = volService.createVolumeFromTemplateAsync(volume, > destPool.getId(), templ); > } > VolumeApiResult result = null; > try { > result = future.get(); > if (result.isFailed()) { > if (result.getResult().contains("request template > reload") && (i == 0)) { > s_logger.debug("Retry template re-deploy for vmware"); > continue; > } > else { > s_logger.debug("Unable to create " > + newVol + ":" + result.getResult()); > throw new StorageUnavailableException("Unable to > create " > + newVol + ":" + result.getResult(), > destPool.getId()); > } > } > newVol = _volsDao.findById(newVol.getId()); > break; //break out of template-redeploy retry loop > } catch (InterruptedException e) { > s_logger.error("Unable to create " + newVol, e); > throw new StorageUnavailableException("Unable to create " > + newVol + ":" + e.toString(), destPool.getId()); > } catch (ExecutionException e) { > s_logger.error("Unable to create " + newVol, e); > throw new StorageUnavailableException("Unable to create " > + newVol + ":" + e.toString(), destPool.getId()); > } > } > return new Pair<VolumeVO, DataStore>(newVol, destPool); > } > ===FILE: > engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java > public TemplateInfo getTemplate(long templateId, DataStoreRole storeRole) { > TemplateDataStoreVO tmplStore = > templateStoreDao.findByTemplate(templateId, storeRole); > DataStore store = null; > if (tmplStore != null) { > store = this.storeMgr.getDataStore(tmplStore.getDataStoreId(), > storeRole); > } > return this.getTemplate(templateId, store); > } > ===FILE: > engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java > public TemplateDataStoreVO findByTemplate(long templateId, DataStoreRole > role) { > SearchCriteria<TemplateDataStoreVO> sc = templateRoleSearch.create(); > sc.setParameters("template_id", templateId); > sc.setParameters("store_role", role); > sc.setParameters("destroyed", false); > return findOneIncludingRemovedBy(sc); > } > ===FILE: utils/src/com/cloud/utils/db/GenericDaoBase.java > protected T findOneIncludingRemovedBy(final SearchCriteria<T> sc) { > Filter filter = new Filter(1); > List<T> results = searchIncludingRemoved(sc, filter, null, false); > assert results.size() <= 1 : "Didn't the limiting worked?"; > return results.size() == 0 ? null : results.get(0); > } > ===FILE: utils/src/com/cloud/utils/db/Filter.java > public Filter(long limit) { > _orderBy = " ORDER BY RAND() LIMIT " + limit; > } -- This message was sent by Atlassian JIRA (v6.2#6252)