diff --git a/src/driver/controller-zfs-generic/index.js b/src/driver/controller-zfs-generic/index.js index 146ca20..1f1f89f 100644 --- a/src/driver/controller-zfs-generic/index.js +++ b/src/driver/controller-zfs-generic/index.js @@ -98,7 +98,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver { * * @param {*} datasetName */ - async createShare(call, datasetName, callContext) { + async createShare(callContext, call, datasetName) { const driver = this; const zb = await this.getZetabyte(); const execClient = this.getExecClient(); @@ -118,7 +118,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver { key ] ) { - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [key]: this.options.nfs.shareStrategySetDatasetProperties .properties[key], @@ -131,7 +131,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver { break; } - properties = await zb.zfs.get(datasetName, ["mountpoint"]); + properties = await zb.zfs.get(callContext, datasetName, ["mountpoint"]); properties = properties[datasetName]; callContext.logger.debug("zfs props data: %j", properties); @@ -152,7 +152,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver { key ] ) { - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [key]: this.options.smb.shareStrategySetDatasetProperties .properties[key], @@ -166,7 +166,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver { break; } - properties = await zb.zfs.get(datasetName, ["mountpoint"]); + properties = await zb.zfs.get(callContext, datasetName, ["mountpoint"]); properties = properties[datasetName]; callContext.logger.debug("zfs props data: %j", properties); @@ -306,7 +306,7 @@ create /backstores/block/${assetName} callContext.logger.info("iqn: " + iqn); // store this off to make delete process more bullet proof - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [ISCSI_ASSETS_NAME_PROPERTY_NAME]: assetName, }); @@ -531,7 +531,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath} callContext.logger.info("nqn: " + nqn); // store this off to make delete process more bullet proof - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [NVMEOF_ASSETS_NAME_PROPERTY_NAME]: assetName, }); @@ -555,7 +555,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath} } } - async deleteShare(call, datasetName, callContext) { + async deleteShare(callContext, call, datasetName) { const zb = await this.getZetabyte(); const execClient = this.getExecClient(); @@ -573,7 +573,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath} ] ) { try { - await zb.zfs.inherit(datasetName, key); + await zb.zfs.inherit(callContext, datasetName, key); } catch (err) { if (err.toString().includes("dataset does not exist")) { // do nothing @@ -603,7 +603,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath} ] ) { try { - await zb.zfs.inherit(datasetName, key); + await zb.zfs.inherit(callContext, datasetName, key); } catch (err) { if (err.toString().includes("dataset does not exist")) { // do nothing @@ -629,7 +629,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath} // Delete iscsi assets try { - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ ISCSI_ASSETS_NAME_PROPERTY_NAME, ]); } catch (err) { @@ -701,7 +701,7 @@ delete ${assetName} // Delete nvmeof assets try { - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ NVMEOF_ASSETS_NAME_PROPERTY_NAME, ]); } catch (err) { @@ -830,7 +830,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath} return {}; } - async expandVolume(call, datasetName, callContext) { + async expandVolume(callContext, call, datasetName) { switch (this.options.driver) { case "zfs-generic-nfs": break; diff --git a/src/driver/controller-zfs-local/index.js b/src/driver/controller-zfs-local/index.js index 3253d63..5bdecc3 100644 --- a/src/driver/controller-zfs-local/index.js +++ b/src/driver/controller-zfs-local/index.js @@ -160,7 +160,7 @@ class ControllerZfsLocalDriver extends ControllerZfsBaseDriver { * * @param {*} datasetName */ - async createShare(call, datasetName, callContext) { + async createShare(callContext, call, datasetName) { let volume_context = {}; switch (this.options.driver) { @@ -193,7 +193,7 @@ class ControllerZfsLocalDriver extends ControllerZfsBaseDriver { * @param {*} datasetName * @returns */ - async deleteShare(call, datasetName, callContext) { + async deleteShare(callContext, call, datasetName) { return {}; } @@ -203,7 +203,7 @@ class ControllerZfsLocalDriver extends ControllerZfsBaseDriver { * @param {*} call * @param {*} datasetName */ - async expandVolume(call, datasetName, callContext) {} + async expandVolume(callContext, call, datasetName) {} /** * List of topologies associated with the *volume* diff --git a/src/driver/controller-zfs/index.js b/src/driver/controller-zfs/index.js index 04c8f21..31bfc76 100644 --- a/src/driver/controller-zfs/index.js +++ b/src/driver/controller-zfs/index.js @@ -41,9 +41,9 @@ const MAX_ZVOL_NAME_LENGTH_CACHE_KEY = "controller-zfs:max_zvol_name_length"; * - getFSTypes() // optional * - getAccessModes(capability) // optional * - async getAccessibleTopology() // optional - * - async createShare(call, datasetName, callContext) // return appropriate volume_context for Node operations - * - async deleteShare(call, datasetName, callContext) // no return expected - * - async expandVolume(call, datasetName, callContext) // no return expected, used for restarting services etc if needed + * - async createShare(callContext, call, datasetName) // return appropriate volume_context for Node operations + * - async deleteShare(callContext, call, datasetName) // no return expected + * - async expandVolume(callContext, call, datasetName) // no return expected, used for restarting services etc if needed */ class ControllerZfsBaseDriver extends CsiBaseDriver { constructor(ctx, options) { @@ -191,10 +191,10 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { return datasetParentName; } - async removeSnapshotsFromDatatset(datasetName, options = {}) { + async removeSnapshotsFromDataset(callContext, datasetName, options = {}) { const zb = await this.getZetabyte(); - await zb.zfs.destroy(datasetName + "@%", options); + await zb.zfs.destroy(callContext, datasetName + "@%", options); } getFSTypes() { @@ -732,7 +732,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { // ensure volumes with the same name being requested a 2nd time but with a different size fails try { - let properties = await zb.zfs.get(datasetName, ["volsize", "refquota"]); + let properties = await zb.zfs.get(callContext, datasetName, ["volsize", "refquota"]); properties = properties[datasetName]; let size; switch (driverZfsResourceType) { @@ -887,7 +887,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { if (!zb.helpers.isZfsSnapshot(volume_content_source_snapshot_id)) { try { - await zb.zfs.snapshot(fullSnapshotName); + await zb.zfs.snapshot(callContext, fullSnapshotName); } catch (err) { if (err.toString().includes("dataset does not exist")) { throw new GrpcError( @@ -903,13 +903,14 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { if (detachedClone) { try { response = await zb.zfs.send_receive( + callContext, fullSnapshotName, [], datasetName, [] ); - response = await zb.zfs.set(datasetName, volumeProperties); + response = await zb.zfs.set(callContext, datasetName, volumeProperties); } catch (err) { if ( err.toString().includes("destination") && @@ -922,7 +923,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { } // remove snapshots from target - await this.removeSnapshotsFromDatatset(datasetName, { + await this.removeSnapshotsFromDataset(callContext, datasetName, { force: true, }); } else { @@ -933,7 +934,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { delete cloneProperties["aclinherit"]; delete cloneProperties["acltype"]; delete cloneProperties["casesensitivity"]; - response = await zb.zfs.clone(fullSnapshotName, datasetName, { + response = await zb.zfs.clone(callContext, fullSnapshotName, datasetName, { properties: volumeProperties, }); } catch (err) { @@ -951,7 +952,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { if (!zb.helpers.isZfsSnapshot(volume_content_source_snapshot_id)) { try { // schedule snapshot removal from source - await zb.zfs.destroy(fullSnapshotName, { + await zb.zfs.destroy(callContext, fullSnapshotName, { recurse: true, force: true, defer: true, @@ -1001,7 +1002,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { // create snapshot try { - response = await zb.zfs.snapshot(fullSnapshotName); + response = await zb.zfs.snapshot(callContext, fullSnapshotName); } catch (err) { if (err.toString().includes("dataset does not exist")) { throw new GrpcError( @@ -1016,6 +1017,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { if (detachedClone) { try { response = await zb.zfs.send_receive( + callContext, fullSnapshotName, [], datasetName, @@ -1032,15 +1034,15 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { } } - response = await zb.zfs.set(datasetName, volumeProperties); + response = await zb.zfs.set(callContext, datasetName, volumeProperties); // remove snapshots from target - await this.removeSnapshotsFromDatatset(datasetName, { + await this.removeSnapshotsFromDataset(callContext, datasetName, { force: true, }); // remove snapshot from source - await zb.zfs.destroy(fullSnapshotName, { + await zb.zfs.destroy(callContext, fullSnapshotName, { recurse: true, force: true, defer: true, @@ -1055,7 +1057,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { delete cloneProperties["acltype"]; delete cloneProperties["casesensitivity"]; try { - response = await zb.zfs.clone(fullSnapshotName, datasetName, { + response = await zb.zfs.clone(callContext, fullSnapshotName, datasetName, { properties: cloneProperties, }); } catch (err) { @@ -1083,7 +1085,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { volumeProperties.volblocksize = zvolBlocksize; } - await zb.zfs.create(datasetName, { + await zb.zfs.create(callContext, datasetName, { parents: true, properties: volumeProperties, size: driverZfsResourceType == "volume" ? capacity_bytes : false, @@ -1117,11 +1119,11 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { // set properties if (setProps) { - await zb.zfs.set(datasetName, properties); + await zb.zfs.set(callContext, datasetName, properties); } // get properties needed for remaining calls - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ "mountpoint", "refquota", "compression", @@ -1218,14 +1220,14 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { } if (setProps) { - await zb.zfs.set(datasetName, properties); + await zb.zfs.set(callContext, datasetName, properties); } break; } - volume_context = await this.createShare(call, datasetName, callContext); - await zb.zfs.set(datasetName, { + volume_context = await this.createShare(callContext, call, datasetName); + await zb.zfs.set(callContext, datasetName, { [SHARE_VOLUME_CONTEXT_PROPERTY_NAME]: JSON.stringify(volume_context), }); @@ -1237,7 +1239,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { // set this just before sending out response so we know if volume completed // this should give us a relatively sane way to clean up artifacts over time - await zb.zfs.set(datasetName, { [SUCCESS_PROPERTY_NAME]: "true" }); + await zb.zfs.set(callContext, datasetName, { [SUCCESS_PROPERTY_NAME]: "true" }); let accessible_topology; if (typeof this.getAccessibleTopology === "function") { @@ -1297,7 +1299,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { // get properties needed for remaining calls try { - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ "mountpoint", "origin", "refquota", @@ -1330,7 +1332,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { } // remove share resources - await this.deleteShare(call, datasetName, callContext); + await this.deleteShare(callContext, call, datasetName); // remove parent snapshot if appropriate with defer if ( @@ -1347,7 +1349,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { ); try { - await zb.zfs.destroy(properties.origin.value, { + await zb.zfs.destroy(callContext, properties.origin.value, { recurse: true, force: true, defer: true, @@ -1371,7 +1373,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { 12, 5000, async () => { - await zb.zfs.destroy(datasetName, { recurse: true, force: true }); + await zb.zfs.destroy(callContext, datasetName, { recurse: true, force: true }); }, { retryCondition: (err) => { @@ -1441,7 +1443,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { if (capacity_bytes && driverZfsResourceType == "volume") { //make sure to align capacity_bytes with zvol blocksize //volume size must be a multiple of volume block size - let properties = await zb.zfs.get(datasetName, ["volblocksize"]); + let properties = await zb.zfs.get(callContext, datasetName, ["volblocksize"]); properties = properties[datasetName]; capacity_bytes = zb.helpers.generateZvolSize( capacity_bytes, @@ -1502,10 +1504,10 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { } if (setProps) { - await zb.zfs.set(datasetName, properties); + await zb.zfs.set(callContext, datasetName, properties); } - await this.expandVolume(call, datasetName, callContext); + await this.expandVolume(callContext, call, datasetName); return { capacity_bytes: @@ -1545,13 +1547,13 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { const datasetName = datasetParentName; - await zb.zfs.create(datasetName, { + await zb.zfs.create(callContext, datasetName, { parents: true, }); let properties; try { - properties = await zb.zfs.get(datasetName, ["avail"]); + properties = await zb.zfs.get(callContext, datasetName, ["avail"]); properties = properties[datasetName]; return { available_capacity: properties.available.value }; @@ -1607,6 +1609,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { } try { response = await zb.zfs.list( + callContext, datasetName, [ "name", @@ -1719,6 +1722,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { } try { response = await zb.zfs.list( + callContext, datasetName, [ "name", @@ -1909,6 +1913,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { try { response = await zb.zfs.list( + callContext, operativeFilesystem, [ "name", @@ -2139,6 +2144,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { try { let datasets = []; datasets = await zb.zfs.list( + callContext, this.getDetachedSnapshotParentDatasetName(), [], { recurse: true, types } @@ -2163,7 +2169,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { } let snapshots = []; - snapshots = await zb.zfs.list(this.getVolumeParentDatasetName(), [], { + snapshots = await zb.zfs.list(callContext, this.getVolumeParentDatasetName(), [], { recurse: true, types, }); @@ -2198,10 +2204,10 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { volumeDatasetName + "@" + VOLUME_SOURCE_DETACHED_SNAPSHOT_PREFIX + name; snapshotDatasetName = datasetName + "/" + name; - await zb.zfs.create(datasetName, { parents: true }); + await zb.zfs.create(callContext, datasetName, { parents: true }); try { - await zb.zfs.snapshot(tmpSnapshotName); + await zb.zfs.snapshot(callContext, tmpSnapshotName); } catch (err) { if (err.toString().includes("dataset does not exist")) { throw new GrpcError( @@ -2215,13 +2221,14 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { try { response = await zb.zfs.send_receive( + callContext, tmpSnapshotName, [], snapshotDatasetName, [] ); - response = await zb.zfs.set(snapshotDatasetName, snapshotProperties); + response = await zb.zfs.set(callContext, snapshotDatasetName, snapshotProperties); } catch (err) { if ( err.toString().includes("destination") && @@ -2235,6 +2242,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { // remove snapshot from target await zb.zfs.destroy( + callContext, snapshotDatasetName + "@" + zb.helpers.extractSnapshotName(tmpSnapshotName), @@ -2246,7 +2254,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { ); // remove snapshot from source - await zb.zfs.destroy(tmpSnapshotName, { + await zb.zfs.destroy(callContext, tmpSnapshotName, { recurse: true, force: true, defer: true, @@ -2256,7 +2264,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { //await GneralUtils.sleep(3000); } else { try { - await zb.zfs.snapshot(fullSnapshotName, { + await zb.zfs.snapshot(callContext, fullSnapshotName, { properties: snapshotProperties, }); @@ -2278,6 +2286,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { // sysctl -d vfs.zfs.txg.timeout # vfs.zfs.txg.timeout: Max seconds worth of delta per txg let properties; properties = await zb.zfs.get( + callContext, fullSnapshotName, [ "name", @@ -2319,7 +2328,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { // set this just before sending out response so we know if volume completed // this should give us a relatively sane way to clean up artifacts over time - await zb.zfs.set(fullSnapshotName, { [SUCCESS_PROPERTY_NAME]: "true" }); + await zb.zfs.set(callContext, fullSnapshotName, { [SUCCESS_PROPERTY_NAME]: "true" }); return { snapshot: { @@ -2388,7 +2397,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { callContext.logger.verbose("deleting snapshot: %s", fullSnapshotName); try { - await zb.zfs.destroy(fullSnapshotName, { + await zb.zfs.destroy(callContext, fullSnapshotName, { recurse: true, force: true, defer: zb.helpers.isZfsSnapshot(snapshot_id), // only defer when snapshot @@ -2409,8 +2418,8 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { let containerDataset = zb.helpers.extractParentDatasetName(fullSnapshotName); try { - await this.removeSnapshotsFromDatatset(containerDataset); - await zb.zfs.destroy(containerDataset); + await this.removeSnapshotsFromDataset(callContext, containerDataset); + await zb.zfs.destroy(callContext, containerDataset); } catch (err) { if (!err.toString().includes("filesystem has children")) { throw err; @@ -2451,7 +2460,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver { const datasetName = datasetParentName + "/" + name; try { - await zb.zfs.get(datasetName, []); + await zb.zfs.get(callContext, datasetName, []); } catch (err) { if (err.toString().includes("dataset does not exist")) { throw new GrpcError( diff --git a/src/driver/freenas/api.js b/src/driver/freenas/api.js index c5df0a0..67bbcb9 100644 --- a/src/driver/freenas/api.js +++ b/src/driver/freenas/api.js @@ -174,7 +174,7 @@ class FreeNASApiDriver extends CsiBaseDriver { * * @param {*} datasetName */ - async createShare(call, datasetName) { + async createShare(callContext, call, datasetName) { const driver = this; const driverShareType = this.getDriverShareType(); const httpClient = await this.getHttpClient(); @@ -879,7 +879,7 @@ class FreeNASApiDriver extends CsiBaseDriver { this.ctx.logger.verbose("FreeNAS ISCSI TARGET: %j", target); // set target.id on zvol - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME]: target.id, }); @@ -1378,7 +1378,7 @@ class FreeNASApiDriver extends CsiBaseDriver { } } - async deleteShare(call, datasetName) { + async deleteShare(callContext, call, datasetName) { const driverShareType = this.getDriverShareType(); const httpClient = await this.getHttpClient(); const httpApiClient = await this.getTrueNASHttpApiClient(); @@ -1809,7 +1809,7 @@ class FreeNASApiDriver extends CsiBaseDriver { * @param {*} datasetName * @returns */ - async expandVolume(call, datasetName) { + async expandVolume(callContext, call, datasetName) { // TODO: fix me return; const driverShareType = this.getDriverShareType(); @@ -2228,7 +2228,7 @@ class FreeNASApiDriver extends CsiBaseDriver { * * @param {*} call */ - async CreateVolume(call) { + async CreateVolume(call, callContext) { const driver = this; const driverZfsResourceType = this.getDriverZfsResourceType(); const httpApiClient = await this.getTrueNASHttpApiClient(); @@ -2957,7 +2957,7 @@ class FreeNASApiDriver extends CsiBaseDriver { break; } - volume_context = await this.createShare(call, datasetName); + volume_context = await this.createShare(callContext, call, datasetName); await httpApiClient.DatasetSet(datasetName, { [SHARE_VOLUME_CONTEXT_PROPERTY_NAME]: JSON.stringify(volume_context), }); @@ -3000,7 +3000,7 @@ class FreeNASApiDriver extends CsiBaseDriver { * * @param {*} call */ - async DeleteVolume(call) { + async DeleteVolume(call, callContext) { const driver = this; const httpApiClient = await this.getTrueNASHttpApiClient(); const zb = await this.getZetabyte(); @@ -3059,7 +3059,7 @@ class FreeNASApiDriver extends CsiBaseDriver { } // remove share resources - await this.deleteShare(call, datasetName); + await this.deleteShare(callContext, call, datasetName); // remove parent snapshot if appropriate with defer if ( @@ -3237,7 +3237,7 @@ class FreeNASApiDriver extends CsiBaseDriver { await httpApiClient.DatasetSet(datasetName, properties); } - await this.expandVolume(call, datasetName); + await this.expandVolume(callContext, call, datasetName); return { capacity_bytes: diff --git a/src/driver/freenas/ssh.js b/src/driver/freenas/ssh.js index 3f635ac..05eacc4 100644 --- a/src/driver/freenas/ssh.js +++ b/src/driver/freenas/ssh.js @@ -249,7 +249,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { * * @param {*} datasetName */ - async createShare(call, datasetName) { + async createShare(callContext, call, datasetName) { const driver = this; const driverShareType = this.getDriverShareType(); const execClient = this.getExecClient(); @@ -279,7 +279,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { switch (driverShareType) { case "nfs": - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ "mountpoint", FREENAS_NFS_SHARE_PROPERTY_NAME, ]); @@ -413,7 +413,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { } //set zfs property - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_NFS_SHARE_PROPERTY_NAME]: response.body.id, }); } else { @@ -456,7 +456,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { } //set zfs property - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_NFS_SHARE_PROPERTY_NAME]: lookupShare.id, }); } else { @@ -490,7 +490,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { * ensuring the path is valid and the shareName */ case "smb": - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ "mountpoint", FREENAS_SMB_SHARE_PROPERTY_NAME, ]); @@ -667,7 +667,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { } //set zfs property - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_SMB_SHARE_PROPERTY_NAME]: response.body.id, }); } else { @@ -708,7 +708,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { } //set zfs property - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_SMB_SHARE_PROPERTY_NAME]: lookupShare.id, }); } else { @@ -738,7 +738,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { break; case "iscsi": - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME, FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME, FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME, @@ -956,7 +956,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { this.ctx.logger.verbose("FreeNAS ISCSI TARGET: %j", target); // set target.id on zvol - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME]: target.id, }); @@ -1103,7 +1103,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { this.ctx.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent); - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id, }); @@ -1164,7 +1164,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { targetToExtent ); - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME]: targetToExtent.id, }); @@ -1288,7 +1288,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { this.ctx.logger.verbose("FreeNAS ISCSI TARGET: %j", target); // set target.id on zvol - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME]: target.id, }); @@ -1352,7 +1352,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { this.ctx.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent); - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id, }); @@ -1412,7 +1412,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { targetToExtent ); - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME]: targetToExtent.id, }); @@ -1431,7 +1431,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { this.ctx.logger.info("FreeNAS iqn: " + iqn); // store this off to make delete process more bullet proof - await zb.zfs.set(datasetName, { + await zb.zfs.set(callContext, datasetName, { [FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME]: iscsiName, }); @@ -1455,7 +1455,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { } } - async deleteShare(call, datasetName) { + async deleteShare(callContext, call, datasetName) { const driverShareType = this.getDriverShareType(); const httpClient = await this.getHttpClient(); const apiVersion = httpClient.getApiVersion(); @@ -1471,7 +1471,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { switch (driverShareType) { case "nfs": try { - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ "mountpoint", FREENAS_NFS_SHARE_PROPERTY_NAME, ]); @@ -1558,6 +1558,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { // remove property to prevent delete race conditions // due to id re-use by FreeNAS/TrueNAS await zb.zfs.inherit( + callContext, datasetName, FREENAS_NFS_SHARE_PROPERTY_NAME ); @@ -1574,7 +1575,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { break; case "smb": try { - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ "mountpoint", FREENAS_SMB_SHARE_PROPERTY_NAME, ]); @@ -1663,6 +1664,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { // remove property to prevent delete race conditions // due to id re-use by FreeNAS/TrueNAS await zb.zfs.inherit( + callContext, datasetName, FREENAS_SMB_SHARE_PROPERTY_NAME ); @@ -1683,7 +1685,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { // Delete extent try { - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME, FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME, FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME, @@ -1784,6 +1786,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { // remove property to prevent delete race conditions // due to id re-use by FreeNAS/TrueNAS await zb.zfs.inherit( + callContext, datasetName, FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME ); @@ -1846,6 +1849,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { // remove property to prevent delete race conditions // due to id re-use by FreeNAS/TrueNAS await zb.zfs.inherit( + callContext, datasetName, FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME ); @@ -2011,7 +2015,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { } } - async expandVolume(call, datasetName) { + async expandVolume(callContext, call, datasetName) { const driverShareType = this.getDriverShareType(); const execClient = this.getExecClient(); const httpClient = await this.getHttpClient(); @@ -2025,7 +2029,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { let reload = false; if (isScale) { let properties; - properties = await zb.zfs.get(datasetName, [ + properties = await zb.zfs.get(callContext, datasetName, [ FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME, ]); properties = properties[datasetName]; diff --git a/src/driver/index.js b/src/driver/index.js index 701a1d7..229998b 100644 --- a/src/driver/index.js +++ b/src/driver/index.js @@ -1389,8 +1389,8 @@ class CsiBaseDriver { case "zfs-local": // TODO: make this a geneic zb instance (to ensure works with node-manual driver) const zb = driver.getDefaultZetabyteInstance(); - result = await zb.zfs.get(`${volume_context.zfs_asset_name}`, [ - "type", + "type", + result = await zb.zfs.get(callContext, `${volume_context.zfs_asset_name}`, [ "mountpoint", ]); result = result[`${volume_context.zfs_asset_name}`]; @@ -1399,7 +1399,7 @@ class CsiBaseDriver { if (result.mountpoint.value != "legacy") { // zfs set mountpoint=legacy // zfs inherit mountpoint - await zb.zfs.set(`${volume_context.zfs_asset_name}`, { + await zb.zfs.set(callContext, `${volume_context.zfs_asset_name}`, { mountpoint: "legacy", }); } diff --git a/src/driver/zfs-local-ephemeral-inline/index.js b/src/driver/zfs-local-ephemeral-inline/index.js index c415fc2..f083d4c 100644 --- a/src/driver/zfs-local-ephemeral-inline/index.js +++ b/src/driver/zfs-local-ephemeral-inline/index.js @@ -368,7 +368,7 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver { } // TODO: catch out of space errors and return specifc grpc message? - await zb.zfs.create(datasetName, { + await zb.zfs.create(callContext, datasetName, { parents: true, properties: volumeProperties, }); @@ -424,7 +424,7 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver { // NOTE: -R will recursively delete items + dependent filesets // delete dataset try { - await zb.zfs.destroy(datasetName, { recurse: true, force: true }); + await zb.zfs.destroy(callContext, datasetName, { recurse: true, force: true }); } catch (err) { if (err.toString().includes("filesystem has dependent clones")) { throw new GrpcError( @@ -478,7 +478,7 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver { const datasetName = datasetParentName; let properties; - properties = await zb.zfs.get(datasetName, ["avail"]); + properties = await zb.zfs.get(callContext, datasetName, ["avail"]); properties = properties[datasetName]; return { available_capacity: properties.available.value }; diff --git a/src/utils/zfs.js b/src/utils/zfs.js index a26db89..be31080 100644 --- a/src/utils/zfs.js +++ b/src/utils/zfs.js @@ -911,8 +911,8 @@ class Zetabyte { * @param {*} dataset * @param {*} options */ - create: function (dataset, options = {}) { - if (!(arguments.length >= 1)) throw new (Error("Invalid arguments"))(); + create: function (callContext, dataset, options = {}) { + if (!(arguments.length >= 2)) throw new (Error("Invalid arguments"))(); return new Promise((resolve, reject) => { const idempotent = @@ -962,8 +962,8 @@ class Zetabyte { * @param {*} dataset * @param {*} options */ - destroy: function (dataset, options = {}) { - if (!(arguments.length >= 1)) throw Error("Invalid arguments"); + destroy: function (callContext, dataset, options = {}) { + if (!(arguments.length >= 2)) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { const idempotent = @@ -1013,8 +1013,8 @@ class Zetabyte { * @param {*} dataset * @param {*} options */ - snapshot: function (dataset, options = {}) { - if (!(arguments.length >= 1)) throw Error("Invalid arguments"); + snapshot: function (callContext, dataset, options = {}) { + if (!(arguments.length >= 2)) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { const idempotent = @@ -1061,8 +1061,8 @@ class Zetabyte { * @param {*} dataset * @param {*} options */ - rollback: function (dataset, options = {}) { - if (!(arguments.length >= 1)) throw Error("Invalid arguments"); + rollback: function (callContext, dataset, options = {}) { + if (!(arguments.length >= 2)) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { let args = []; @@ -1095,8 +1095,8 @@ class Zetabyte { * @param {*} dataset * @param {*} options */ - clone: function (snapshot, dataset, options = {}) { - if (!(arguments.length >= 2)) throw Error("Invalid arguments"); + clone: function (callContext, snapshot, dataset, options = {}) { + if (!(arguments.length >= 3)) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { const idempotent = @@ -1143,8 +1143,8 @@ class Zetabyte { * @param {*} target * @param {*} receive_options */ - send_receive(source, send_options = [], target, receive_options = []) { - if (arguments.length < 4) throw Error("Invalid arguments"); + send_receive(callContext, source, send_options = [], target, receive_options = []) { + if (arguments.length < 5) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { // specially handle sudo here to avoid the need for using sudo on the whole script @@ -1187,8 +1187,8 @@ class Zetabyte { * * @param {*} dataset */ - promote: function (dataset) { - if (arguments.length != 1) throw Error("Invalid arguments"); + promote: function (callContext, dataset) { + if (arguments.length != 2) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { let args = []; @@ -1217,8 +1217,8 @@ class Zetabyte { * @param {*} target * @param {*} options */ - rename: function (source, target, options = {}) { - if (!(arguments.length >= 2)) throw Error("Invalid arguments"); + rename: function (callContext, source, target, options = {}) { + if (!(arguments.length >= 3)) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { let args = []; @@ -1251,8 +1251,8 @@ class Zetabyte { * @param {*} properties * @param {*} options */ - list: function (dataset, properties, options = {}) { - if (!(arguments.length >= 1)) throw Error("Invalid arguments"); + list: function (callContext, dataset, properties, options = {}) { + if (!(arguments.length >= 2)) throw Error("Invalid arguments"); if (!properties) properties = zb.DEFAULT_ZFS_LIST_PROPERTIES; return new Promise((resolve, reject) => { @@ -1317,8 +1317,8 @@ class Zetabyte { * @param {*} dataset * @param {*} properties */ - set: function (dataset, properties) { - if (arguments.length != 2) throw Error("Invalid arguments"); + set: function (callContext, dataset, properties) { + if (arguments.length != 3) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { if (!Object.keys(properties).length) { @@ -1361,8 +1361,8 @@ class Zetabyte { * @param {*} dataset * @param {*} properties */ - get: function (dataset, properties = "all", options = {}) { - if (!(arguments.length >= 2)) throw Error("Invalid arguments"); + get: function (callContext, dataset, properties = "all", options = {}) { + if (!(arguments.length >= 3)) throw Error("Invalid arguments"); if (!properties) properties = "all"; if (Array.isArray(properties) && !properties.length > 0) properties = "all"; @@ -1445,8 +1445,8 @@ class Zetabyte { * @param {*} dataset * @param {*} property */ - inherit: function (dataset, property) { - if (arguments.length != 2) throw Error("Invalid arguments"); + inherit: function (callContext, dataset, property) { + if (arguments.length != 3) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { let args = []; @@ -1473,8 +1473,8 @@ class Zetabyte { * * @param {*} dataset */ - remap: function (dataset) { - if (arguments.length != 1) throw Error("Invalid arguments"); + remap: function (callContext, dataset) { + if (arguments.length != 2) throw Error("Invalid arguments"); return new Promise((resolve, reject) => { let args = []; @@ -1499,7 +1499,7 @@ class Zetabyte { * * @param {*} dataset */ - upgrade: function (options = {}, dataset) { + upgrade: function (callContext, options = {}, dataset) { return new Promise((resolve, reject) => { let args = []; args.push("upgrade");