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