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:
parent
4b7604d278
commit
d9bf3d7d2e
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -830,7 +830,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
|
|||
`invalid source_volume_id: ${source_volume_id}`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// check for other snapshopts with the same name on other volumes and fail as appropriate
|
||||
// TODO: technically this should only be checking lun/snapshots relevant to this specific install of the driver
|
||||
// but alas an isolation/namespacing mechanism does not exist in synology
|
||||
|
|
@ -845,47 +845,35 @@ class ControllerSynologyDriver extends CsiBaseDriver {
|
|||
}
|
||||
|
||||
// check for already exists
|
||||
let snapshot = await httpClient.GetSnapshotByLunIDAndName(lun.lun_id, name);
|
||||
if (snapshot) {
|
||||
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,
|
||||
snapshot_id: `/lun/${lun.lun_id}/${snapshot.uuid}`, // add shanpshot_uuid //fixme
|
||||
source_volume_id: source_volume_id,
|
||||
//https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
|
||||
creation_time: {
|
||||
seconds: snapshot.time,
|
||||
nanos: 0,
|
||||
},
|
||||
ready_to_use: true,
|
||||
},
|
||||
};
|
||||
let snapshot;
|
||||
snapshot = await httpClient.GetSnapshotByLunIDAndName(lun.lun_id, name);
|
||||
if (!snapshot) {
|
||||
let data = Object.assign({}, driver.options.iscsi.lunSnapshotTemplate, {
|
||||
src_lun_uuid: lun.uuid,
|
||||
taken_by: "democratic-csi",
|
||||
description: name, //check
|
||||
});
|
||||
|
||||
await httpClient.CreateSnapshot(data);
|
||||
snapshot = await httpClient.GetSnapshotByLunIDAndName(lun.lun_id, name);
|
||||
|
||||
if (!snapshot) {
|
||||
throw new Error(`failed to create snapshot`);
|
||||
}
|
||||
}
|
||||
|
||||
let data = Object.assign({}, driver.options.iscsi.lunSnapshotTemplate, {
|
||||
src_lun_uuid: lun.uuid,
|
||||
taken_by: "democratic-csi",
|
||||
description: name, //check
|
||||
});
|
||||
|
||||
let response = await httpClient.CreateSnapshot(data);
|
||||
|
||||
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,
|
||||
snapshot_id: `/lun/${lun.lun_id}/${response.body.data.snapshot_uuid}`,
|
||||
size_bytes: snapshot.total_size,
|
||||
snapshot_id: `/lun/${lun.lun_id}/${snapshot.uuid}`, // add shanpshot_uuid //fixme
|
||||
source_volume_id: source_volume_id,
|
||||
//https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
|
||||
creation_time: {
|
||||
seconds: Math.round(new Date().getTime() / 1000),
|
||||
seconds: snapshot.time,
|
||||
nanos: 0,
|
||||
},
|
||||
ready_to_use: true,
|
||||
|
|
|
|||
|
|
@ -2162,6 +2162,8 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: let things settle to ensure proper size_bytes is reported
|
||||
// sysctl -d vfs.zfs.txg.timeout # vfs.zfs.txg.timeout: Max seconds worth of delta per txg
|
||||
let properties;
|
||||
properties = await zb.zfs.get(
|
||||
fullSnapshotName,
|
||||
|
|
|
|||
|
|
@ -3939,6 +3939,8 @@ class FreeNASApiDriver extends CsiBaseDriver {
|
|||
MANAGED_PROPERTY_NAME,
|
||||
];
|
||||
|
||||
// TODO: let things settle to ensure proper size_bytes is reported
|
||||
// sysctl -d vfs.zfs.txg.timeout # vfs.zfs.txg.timeout: Max seconds worth of delta per txg
|
||||
if (detachedSnapshot) {
|
||||
properties = await httpApiClient.DatasetGet(
|
||||
fullSnapshotName,
|
||||
|
|
|
|||
Loading…
Reference in New Issue