[ https://issues.apache.org/jira/browse/CLOUDSTACK-8302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15065580#comment-15065580 ]
ASF GitHub Bot commented on CLOUDSTACK-8302: -------------------------------------------- Github user dmytro-shevchenko commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1230#discussion_r48097934 --- Diff: plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java --- @@ -1274,7 +1274,45 @@ public Answer createVolumeFromSnapshot(final CopyCommand cmd) { @Override public Answer deleteSnapshot(final DeleteCommand cmd) { - return new Answer(cmd); + try { + SnapshotObjectTO snapshotTO = (SnapshotObjectTO) cmd.getData(); + PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO) snapshotTO.getDataStore(); + VolumeObjectTO volume = snapshotTO.getVolume(); + String snapshotFullPath = snapshotTO.getPath(); + String snapshotName = snapshotFullPath.substring(snapshotFullPath.lastIndexOf("/") + 1); + KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid()); + KVMPhysicalDisk disk = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), volume.getPath()); + if (primaryPool.getType() == StoragePoolType.RBD) { + Rados r = new Rados(primaryPool.getAuthUserName()); + r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); + r.confSet("key", primaryPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); + r.connect(); + s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); + IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); + Rbd rbd = new Rbd(io); + RbdImage image = rbd.open(disk.getName()); + try { + s_logger.info("Attempting to remove RBD snapshot " + disk.getName() + "@" + snapshotName); + if (image.snapIsProtected(snapshotName)) { + s_logger.debug("Unprotecting snapshot " + snapshotFullPath); + image.snapUnprotect(snapshotName); + } + image.snapRemove(snapshotName); + s_logger.info("Snapshot " + snapshotFullPath + " successfully removed."); + } finally { + rbd.close(image); + r.ioCtxDestroy(io); + } + } else { + s_logger.warn("Operation not implemented!"); + throw new InternalErrorException("Operation not implemented!"); --- End diff -- Storage pool type added to messages. > Cleanup snapshot on KVM with RBD > -------------------------------- > > Key: CLOUDSTACK-8302 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8302 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the > default.) > Components: KVM, Snapshot, Storage Controller > Affects Versions: 4.4.0, 4.4.1, 4.4.2 > Environment: CloudStack 4.4.2 + KVM on CentOS 6.6 + Ceph/RBD 0.80.8 > Reporter: Star Guo > Assignee: Wido den Hollander > Priority: Critical > > I just build a lab with CloudStack 4.4.2 + CentOS 6.6 KVM + Ceph/RBD 0.80.8. > I deploy an instance on RBD and I create the ROOT volume snapshots. When > delete a snapshot the UI show OK, but the snapshot of the volume in the RBD > pool is still exist. > And I find the code in > com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java: > … > @Override > public Answer deleteSnapshot(DeleteCommand cmd) { > return new Answer(cmd); > } > … > deleteSnapshot() does not be implememented. And I also find the code: > ... > @Override > public Answer createTemplateFromSnapshot(CopyCommand cmd) { > return null; //To change body of implemented methods use File | > Settings | File Templates. > } > ... > So does createTenokateFromSnapshot(). I just look for it in MASTER branch but > not do that yet. Will CloudStack Dev Team plan to do that ? Thanks . -- This message was sent by Atlassian JIRA (v6.3.4#6332)