apache / apache/cloudstack

RBD/RADOS volume management should be handled by libvirt

未关闭
#6,180 1 条评论 1 个 reaction 已指派 1 人 已被 @wido 认领 在 GitHub 查看
complexity:epic component:agent component:ceph type:technical-debt
主要语言
Java
星标
3.1k
派生
1.4k
平均合并
6 天 19 小时
30 天内合并 PR
32

描述

##### ISSUE TYPE
* Enhancement Request

##### COMPONENT NAME
~~~
CloudStack Agent
~~~

##### CLOUDSTACK VERSION
~~~
all
~~~

##### SUMMARY
The CloudStack Agent uses com.ceph.rados.* for many operations as when implementing the RBD storage pool support not all features were supported by Libvirt.

For example: https://github.com/apache/cloudstack/blob/1a304ccf68a75d835cf5e723b56b57155be6ebda/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java#L913

```
IoCTX io = r.ioCtxCreate(pool.getSourceDir());
Rbd rbd = new Rbd(io);
RbdImage image = rbd.open(uuid);
s_logger.debug("Fetching list of snapshots of RBD image " + pool.getSourceDir() + "/" + uuid);
List snaps = image.snapList();
try {
for (RbdSnapInfo snap : snaps) {
if (image.snapIsProtected(snap.name)) {
s_logger.debug("Unprotecting snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name);
image.snapUnprotect(snap.name);
} else {
s_logger.debug("Snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name + " is not protected.");
}
s_logger.debug("Removing snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name);
image.snapRemove(snap.name);
}
s_logger.info("Successfully unprotected and removed any remaining snapshots (" + snaps.size() + ") of "
+ pool.getSourceDir() + "/" + uuid + " Continuing to remove the RBD image");
} catch (RbdException e) {
s_logger.error("Failed to remove snapshot with exception: " + e.toString() +
", RBD error: " + ErrorCode.getErrorMessage(e.getReturnValue()));
throw new CloudRuntimeException(e.toString() + " - " + ErrorCode.getErrorMessage(e.getReturnValue()));
} finally {
s_logger.debug("Closing image and destroying context");
rbd.close(image);
r.ioCtxDestroy(io);
}
} catch (RadosException e) {
s_logger.error("Failed to remove snapshot with exception: " + e.toString() +
", RBD error: " + ErrorCode.getErrorMessage(e.getReturnValue()));
throw new CloudRuntimeException(e.toString() + " - " + ErrorCode.getErrorMessage(e.getReturnValue()));
} catch (RbdException e) {
s_logger.error("Failed to remove snapshot with exception: " + e.toString() +
", RBD error: " + ErrorCode.getErrorMessage(e.getReturnValue()));
throw new CloudRuntimeException(e.toString() + " - " + ErrorCode.getErrorMessage(e.getReturnValue()));
}
}
```

Here the CloudStack agent purges any RBD snapshots as they need to be removed prior to removing the RBD image.

Modern libvirt can do this for you (pseudo code):

```
StorageVol.delete(VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS)
```

This removes a lot of lines of code from CloudStack and leverages what libvirt can do for us.

This is just one example, but there are other places where the CloudStack agent uses the librados Java bindings directly while those things can be handled by libvirt.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。