mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	More protective cleanup when exporting snaphost to reduce chances of leaving intermediate files behind under soft error conditions
This commit is contained in:
		
							parent
							
								
									83bc7d1c81
								
							
						
					
					
						commit
						f0e048a968
					
				| @ -1187,6 +1187,9 @@ public class VirtualMachineMO extends BaseMO { | |||||||
| 		try { | 		try { | ||||||
| 			if(state == HttpNfcLeaseState.ready) { | 			if(state == HttpNfcLeaseState.ready) { | ||||||
| 				final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter(); | 				final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter(); | ||||||
|  | 
 | ||||||
|  |                 boolean success = false; | ||||||
|  |                 List<String> fileNames = new ArrayList<String>(); | ||||||
| 				try { | 				try { | ||||||
| 					HttpNfcLeaseInfo leaseInfo = leaseMo.getLeaseInfo(); | 					HttpNfcLeaseInfo leaseInfo = leaseMo.getLeaseInfo(); | ||||||
| 					final long totalBytes = leaseInfo.getTotalDiskCapacityInKB() * 1024; | 					final long totalBytes = leaseInfo.getTotalDiskCapacityInKB() * 1024; | ||||||
| @ -1194,8 +1197,6 @@ public class VirtualMachineMO extends BaseMO { | |||||||
| 					 | 					 | ||||||
| 					HttpNfcLeaseDeviceUrl[] deviceUrls = leaseInfo.getDeviceUrl(); | 					HttpNfcLeaseDeviceUrl[] deviceUrls = leaseInfo.getDeviceUrl(); | ||||||
| 					if(deviceUrls != null) { | 					if(deviceUrls != null) { | ||||||
| 						List<String> fileNames = new ArrayList<String>(); |  | ||||||
| 						 |  | ||||||
| 						OvfFile[] ovfFiles = new OvfFile[deviceUrls.length];   | 						OvfFile[] ovfFiles = new OvfFile[deviceUrls.length];   | ||||||
| 						for (int i = 0; i < deviceUrls.length; i++) {   | 						for (int i = 0; i < deviceUrls.length; i++) {   | ||||||
| 							String deviceId = deviceUrls[i].getKey();   | 							String deviceId = deviceUrls[i].getKey();   | ||||||
| @ -1252,11 +1253,7 @@ public class VirtualMachineMO extends BaseMO { | |||||||
| 					         | 					         | ||||||
| 					        String result = command.execute(); | 					        String result = command.execute(); | ||||||
| 					        if(result == null) { | 					        if(result == null) { | ||||||
| 					        	if(leaveOvaFileOnly) { | 					            success = true; | ||||||
| 							        for(String name: fileNames) { |  | ||||||
|                                         new File(name).delete(); |  | ||||||
|                                     } |  | ||||||
| 					        	} |  | ||||||
| 					        } | 					        } | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| @ -1264,6 +1261,16 @@ public class VirtualMachineMO extends BaseMO { | |||||||
| 					s_logger.error("Unexpected exception ", e); | 					s_logger.error("Unexpected exception ", e); | ||||||
| 				} finally { | 				} finally { | ||||||
| 					progressReporter.close(); | 					progressReporter.close(); | ||||||
|  | 
 | ||||||
|  | 					if(leaveOvaFileOnly) { | ||||||
|  |                         for(String name : fileNames) { | ||||||
|  |                             new File(name).delete(); | ||||||
|  |                         } | ||||||
|  | 					} | ||||||
|  | 					 | ||||||
|  | 					if(!success) { | ||||||
|  | 					    new File(exportDir + File.separator + exportName + ".ova").delete(); | ||||||
|  | 					}  | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} finally { | 		} finally { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user