Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8E572200C17 for ; Fri, 10 Feb 2017 15:22:32 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8CE22160B5C; Fri, 10 Feb 2017 14:22:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D32C0160B5B for ; Fri, 10 Feb 2017 15:22:31 +0100 (CET) Received: (qmail 96230 invoked by uid 500); 10 Feb 2017 14:22:26 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 96219 invoked by uid 99); 10 Feb 2017 14:22:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Feb 2017 14:22:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6D64ADFBE6; Fri, 10 Feb 2017 14:22:25 +0000 (UTC) From: nvazquez To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request #1913: CLOUDSTACK-9752: [Vmware] Optimization of vol... Content-Type: text/plain Message-Id: <20170210142225.6D64ADFBE6@git1-us-west.apache.org> Date: Fri, 10 Feb 2017 14:22:25 +0000 (UTC) archived-at: Fri, 10 Feb 2017 14:22:32 -0000 Github user nvazquez commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1913#discussion_r100543231 --- Diff: plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java --- @@ -1577,11 +1577,15 @@ public Answer createVolume(CreateObjectCommand cmd) { } synchronized (this) { - // s_logger.info("Delete file if exists in datastore to clear the way for creating the volume. file: " + volumeDatastorePath); - VmwareStorageLayoutHelper.deleteVolumeVmdkFiles(dsMo, volumeUuid.toString(), dcMo); - - vmMo.createDisk(volumeDatastorePath, (int)(volume.getSize() / (1024L * 1024L)), morDatastore, vmMo.getScsiDeviceControllerKey()); - vmMo.detachDisk(volumeDatastorePath, false); + try { + vmMo.createDisk(volumeDatastorePath, (int)(volume.getSize() / (1024L * 1024L)), morDatastore, vmMo.getScsiDeviceControllerKey()); + vmMo.detachDisk(volumeDatastorePath, false); + } + catch (Exception e) { + s_logger.error("Deleting file " + volumeDatastorePath + " due to error: " + e.getMessage()); + VmwareStorageLayoutHelper.deleteVolumeVmdkFiles(dsMo, volumeUuid.toString(), dcMo); --- End diff -- Hi @syed @karuturi @SudharmaJain, What do you think about this approach? We will delete vmdk file if either createDisk or detachDisk fails, this way we make sure file doesn't exist in case that CloudStack retries operation. By the way, in VolumeOrchestrator lines 556-588 there's the retry logic, to retry only if failure contains "request template reload": ```` for (int i = 0; i < 2; i++) { // retry one more time in case of template reload is required for Vmware case AsyncCallFuture future = null; boolean isNotCreatedFromTemplate = volume.getTemplateId() == null ? true : false; if (isNotCreatedFromTemplate) { future = volService.createVolumeAsync(volume, store); } else { TemplateInfo templ = tmplFactory.getTemplate(template.getId(), DataStoreRole.Image); future = volService.createVolumeFromTemplateAsync(volume, store.getId(), templ); } try { VolumeApiResult 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("create volume failed: " + result.getResult()); throw new CloudRuntimeException("create volume failed:" + result.getResult()); } } return result.getVolume(); } catch (InterruptedException e) { s_logger.error("create volume failed", e); throw new CloudRuntimeException("create volume failed", e); } catch (ExecutionException e) { s_logger.error("create volume failed", e); throw new CloudRuntimeException("create volume failed", e); } } throw new CloudRuntimeException("create volume failed even after template re-deploy"); } ```` To preserve this logic is that I've passed caught exception message on thrown exception in line 1587. Do you agree with this solution? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---