properly implement snapshot size_bytes for controller-*-client and synology drivers

Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
Travis Glenn Hansen
2021-11-28 22:52:49 -07:00
parent 4b7604d278
commit d9bf3d7d2e
4 changed files with 31 additions and 32 deletions
+8 -1
View File
@@ -228,6 +228,12 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
return this.getControllerSnapshotBasePath() + "/" + snapshot_id;
}
async getDirectoryUsage(path) {
let result = await this.exec("du", ["-s", "--block-size=1", path]);
let size = result.stdout.split("\t", 1)[0];
return size;
}
exec(command, args, options = {}) {
args = args || [];
@@ -664,13 +670,14 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
await driver.cloneDir(volume_path, snapshot_path);
}
let size_bytes = await driver.getDirectoryUsage(snapshot_path);
return {
snapshot: {
/**
* The purpose of this field is to give CO guidance on how much space
* is needed to create a volume from this snapshot.
*/
//size_bytes: 0,
size_bytes,
snapshot_id,
source_volume_id: source_volume_id,
//https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto