apache / apache/cloudstack

RBD/RADOS volume management should be handled by libvirt

Ouverte
#6,180 1 commentaire 1 réaction 1 personne assignée Réclamée par @wido Voir sur GitHub
complexity:epic component:agent component:ceph type:technical-debt
Langage dominant
Java
Étoiles
3.1k
Forks
1.4k
Merge moyen
6 j 19 h
PR mergées (30 j)
32

Description

##### 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.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.