This commit is contained in:
Danil Uzlov 2025-04-13 13:24:52 +07:00 committed by GitHub
commit dd96cbd7de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 363 additions and 312 deletions

View File

@ -118,6 +118,7 @@ const cache = new LRU({ max: 500 });
const { logger } = require("../src/utils/logger"); const { logger } = require("../src/utils/logger");
const { GrpcError } = require("../src/utils/grpc"); const { GrpcError } = require("../src/utils/grpc");
const GeneralUtils = require("../src/utils/general"); const GeneralUtils = require("../src/utils/general");
const uuidv4 = require("uuid").v4;
if (args.logLevel) { if (args.logLevel) {
logger.level = args.logLevel; logger.level = args.logLevel;
@ -178,17 +179,25 @@ async function requestHandlerProxy(call, callback, serviceMethodName) {
} }
} }
const requestReadableID = GeneralUtils.loggerIdFromRequest(call, serviceMethodName);
const requestUUID = uuidv4();
const callContext = {
logger: logger.child({
method: serviceMethodName,
requestId: requestReadableID,
uuid: requestUUID,
}),
};
try { try {
logger.info( callContext.logger.info(
"new request - driver: %s method: %s call: %j", "new request: driver: %s, call: %j",
driver.constructor.name, driver.constructor.name,
serviceMethodName,
cleansedCall cleansedCall
); );
const lockKeys = GeneralUtils.lockKeysFromRequest(call, serviceMethodName); const lockKeys = GeneralUtils.lockKeysFromRequest(call, serviceMethodName);
if (lockKeys.length > 0) { if (lockKeys.length > 0) {
logger.debug("operation lock keys: %j", lockKeys); callContext.logger.debug("operation lock keys: %j", lockKeys);
// check locks // check locks
lockKeys.forEach((key) => { lockKeys.forEach((key) => {
if (operationLock.has(key)) { if (operationLock.has(key)) {
@ -216,13 +225,13 @@ async function requestHandlerProxy(call, callback, serviceMethodName) {
let response; let response;
let responseError; let responseError;
try { try {
// aquire locks // acquire locks
if (lockKeys.length > 0) { if (lockKeys.length > 0) {
lockKeys.forEach((key) => { lockKeys.forEach((key) => {
operationLock.add(key); operationLock.add(key);
}); });
} }
response = await driver[serviceMethodName](call); response = await driver[serviceMethodName](callContext, call);
} catch (e) { } catch (e) {
responseError = e; responseError = e;
} finally { } finally {
@ -246,10 +255,8 @@ async function requestHandlerProxy(call, callback, serviceMethodName) {
); );
} }
logger.info( callContext.logger.info(
"new response - driver: %s method: %s response: %j", "new response: %j",
driver.constructor.name,
serviceMethodName,
response response
); );
@ -265,10 +272,8 @@ async function requestHandlerProxy(call, callback, serviceMethodName) {
message = stringify(e); message = stringify(e);
} }
logger.error( callContext.logger.error(
"handler error - driver: %s method: %s error: %s", "handler error: %s",
driver.constructor.name,
serviceMethodName,
message message
); );

View File

@ -156,9 +156,9 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
return access_modes; return access_modes;
} }
assertCapabilities(capabilities) { assertCapabilities(callContext, capabilities) {
const driver = this; const driver = this;
this.ctx.logger.verbose("validating capabilities: %j", capabilities); callContext.logger.verbose("validating capabilities: %j", capabilities);
let message = null; let message = null;
let fs_types = driver.getFsTypes(); let fs_types = driver.getFsTypes();
@ -548,7 +548,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateVolume(call) { async CreateVolume(callContext, call) {
const driver = this; const driver = this;
const config_key = driver.getConfigKey(); const config_key = driver.getConfigKey();
@ -560,7 +560,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
call.request.volume_capabilities && call.request.volume_capabilities &&
call.request.volume_capabilities.length > 0 call.request.volume_capabilities.length > 0
) { ) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message); throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message);
} }
@ -661,7 +661,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
); );
} }
driver.ctx.logger.debug( callContext.logger.debug(
"controller volume source path: %s", "controller volume source path: %s",
source_path source_path
); );
@ -740,7 +740,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
); );
} }
break; break;
// must be available when adverstising CLONE_VOLUME // must be available when advertising CLONE_VOLUME
// create snapshot first, then clone // create snapshot first, then clone
case "volume": case "volume":
source_path = driver.getControllerVolumePath( source_path = driver.getControllerVolumePath(
@ -754,7 +754,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
); );
} }
driver.ctx.logger.debug( callContext.logger.debug(
"controller volume source path: %s", "controller volume source path: %s",
source_path source_path
); );
@ -770,7 +770,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
// set mode // set mode
if (this.options[config_key].dirPermissionsMode) { if (this.options[config_key].dirPermissionsMode) {
driver.ctx.logger.verbose( callContext.logger.verbose(
"setting dir mode to: %s on dir: %s", "setting dir mode to: %s on dir: %s",
this.options[config_key].dirPermissionsMode, this.options[config_key].dirPermissionsMode,
volume_path volume_path
@ -783,14 +783,14 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
this.options[config_key].dirPermissionsUser || this.options[config_key].dirPermissionsUser ||
this.options[config_key].dirPermissionsGroup this.options[config_key].dirPermissionsGroup
) { ) {
driver.ctx.logger.verbose( callContext.logger.verbose(
"setting ownership to: %s:%s on dir: %s", "setting ownership to: %s:%s on dir: %s",
this.options[config_key].dirPermissionsUser, this.options[config_key].dirPermissionsUser,
this.options[config_key].dirPermissionsGroup, this.options[config_key].dirPermissionsGroup,
volume_path volume_path
); );
if (this.getNodeIsWindows()) { if (this.getNodeIsWindows()) {
driver.ctx.logger.warn("chown not implemented on windows"); callContext.logger.warn("chown not implemented on windows");
} else { } else {
await driver.exec("chown", [ await driver.exec("chown", [
(this.options[config_key].dirPermissionsUser (this.options[config_key].dirPermissionsUser
@ -840,7 +840,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteVolume(call) { async DeleteVolume(callContext, call) {
const driver = this; const driver = this;
const volume_id = call.request.volume_id; const volume_id = call.request.volume_id;
@ -873,7 +873,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ControllerExpandVolume(call) { async ControllerExpandVolume(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -885,7 +885,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async GetCapacity(call) { async GetCapacity(callContext, call) {
const driver = this; const driver = this;
if ( if (
@ -902,7 +902,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
} }
if (call.request.volume_capabilities) { if (call.request.volume_capabilities) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { available_capacity: 0 }; return { available_capacity: 0 };
@ -925,7 +925,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListVolumes(call) { async ListVolumes(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -936,7 +936,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListSnapshots(call) { async ListSnapshots(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -963,7 +963,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateSnapshot(call) { async CreateSnapshot(callContext, call) {
const driver = this; const driver = this;
const config_key = driver.getConfigKey(); const config_key = driver.getConfigKey();
@ -1003,7 +1003,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
); );
} }
driver.ctx.logger.verbose("requested snapshot name: %s", name); callContext.logger.verbose("requested snapshot name: %s", name);
let invalid_chars; let invalid_chars;
invalid_chars = name.match(/[^a-z0-9_\-:.+]+/gi); invalid_chars = name.match(/[^a-z0-9_\-:.+]+/gi);
@ -1020,7 +1020,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
// https://stackoverflow.com/questions/32106243/regex-to-remove-all-non-alpha-numeric-and-replace-spaces-with/32106277 // https://stackoverflow.com/questions/32106243/regex-to-remove-all-non-alpha-numeric-and-replace-spaces-with/32106277
name = name.replace(/[^a-z0-9_\-:.+]+/gi, ""); name = name.replace(/[^a-z0-9_\-:.+]+/gi, "");
driver.ctx.logger.verbose("cleansed snapshot name: %s", name); callContext.logger.verbose("cleansed snapshot name: %s", name);
const volume_path = driver.getControllerVolumePath(source_volume_id); const volume_path = driver.getControllerVolumePath(source_volume_id);
//const volume_path = "/home/thansen/beets/"; //const volume_path = "/home/thansen/beets/";
//const volume_path = "/var/lib/docker/"; //const volume_path = "/var/lib/docker/";
@ -1044,11 +1044,11 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
await driver.cloneDir(volume_path, snapshot_path).finally(() => { await driver.cloneDir(volume_path, snapshot_path).finally(() => {
SNAPSHOTS_CUT_IN_FLIGHT.delete(name); SNAPSHOTS_CUT_IN_FLIGHT.delete(name);
}); });
driver.ctx.logger.info( callContext.logger.info(
`filecopy backup finished: snapshot_id=${snapshot_id}, path=${volume_path}` `filecopy backup finished: snapshot_id=${snapshot_id}, path=${volume_path}`
); );
} else { } else {
driver.ctx.logger.debug( callContext.logger.debug(
`filecopy backup already cut: ${snapshot_id}` `filecopy backup already cut: ${snapshot_id}`
); );
} }
@ -1099,7 +1099,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
if (response.length > 0) { if (response.length > 0) {
snapshot_exists = true; snapshot_exists = true;
const snapshot = response[response.length - 1]; const snapshot = response[response.length - 1];
driver.ctx.logger.debug( callContext.logger.debug(
`restic backup already cut: ${snapshot.id}` `restic backup already cut: ${snapshot.id}`
); );
const stats = await restic.stats([snapshot.id]); const stats = await restic.stats([snapshot.id]);
@ -1136,7 +1136,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
return message.message_type == "summary"; return message.message_type == "summary";
}); });
snapshot_id = summary.snapshot_id; snapshot_id = summary.snapshot_id;
driver.ctx.logger.info( callContext.logger.info(
`restic backup finished: snapshot_id=${snapshot_id}, path=${volume_path}, total_duration=${ `restic backup finished: snapshot_id=${snapshot_id}, path=${volume_path}, total_duration=${
summary.total_duration | 0 summary.total_duration | 0
}s` }s`
@ -1194,7 +1194,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
); );
} }
snapshot_id = snapshot.id; snapshot_id = snapshot.id;
driver.ctx.logger.info( callContext.logger.info(
`restic backup successfully applied additional tags: new_snapshot_id=${snapshot_id}, original_snapshot_id=${original_snapshot_id} path=${volume_path}` `restic backup successfully applied additional tags: new_snapshot_id=${snapshot_id}, original_snapshot_id=${original_snapshot_id} path=${volume_path}`
); );
} }
@ -1233,7 +1233,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
if (response.length > 0) { if (response.length > 0) {
snapshot_exists = true; snapshot_exists = true;
const snapshot = response[response.length - 1]; const snapshot = response[response.length - 1];
driver.ctx.logger.debug( callContext.logger.debug(
`kopia snapshot already cut: ${snapshot.id}` `kopia snapshot already cut: ${snapshot.id}`
); );
@ -1262,7 +1262,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
1000; 1000;
size_bytes = response.rootEntry.summ.size; size_bytes = response.rootEntry.summ.size;
driver.ctx.logger.info( callContext.logger.info(
`kopia backup finished: snapshot_id=${snapshot_id}, path=${volume_path}, total_duration=${ `kopia backup finished: snapshot_id=${snapshot_id}, path=${volume_path}, total_duration=${
total_duration | 0 total_duration | 0
}s` }s`
@ -1305,7 +1305,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteSnapshot(call) { async DeleteSnapshot(callContext, call) {
const driver = this; const driver = this;
let snapshot_id = call.request.snapshot_id; let snapshot_id = call.request.snapshot_id;
@ -1393,7 +1393,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ValidateVolumeCapabilities(call) { async ValidateVolumeCapabilities(callContext, call) {
const driver = this; const driver = this;
const volume_id = call.request.volume_id; const volume_id = call.request.volume_id;
@ -1414,7 +1414,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
); );
} }
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { message: result.message }; return { message: result.message };

View File

@ -78,7 +78,7 @@ class ControllerLocalHostpathDriver extends ControllerClientCommonDriver {
* @param {*} call * @param {*} call
* @returns * @returns
*/ */
async NodeGetInfo(call) { async NodeGetInfo(callContext, call) {
const response = await super.NodeGetInfo(...arguments); const response = await super.NodeGetInfo(...arguments);
response.accessible_topology = { response.accessible_topology = {
segments: { segments: {

View File

@ -159,9 +159,9 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
return ["fuse.objectivefs", "objectivefs"]; return ["fuse.objectivefs", "objectivefs"];
} }
assertCapabilities(capabilities) { assertCapabilities(callContext, capabilities) {
const driver = this; const driver = this;
this.ctx.logger.verbose("validating capabilities: %j", capabilities); callContext.logger.verbose("validating capabilities: %j", capabilities);
let message = null; let message = null;
let fs_types = driver.getFsTypes(); let fs_types = driver.getFsTypes();
@ -270,7 +270,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async Probe(call) { async Probe(callContext, call) {
const driver = this; const driver = this;
const pool = _.get(driver.options, "objectivefs.pool"); const pool = _.get(driver.options, "objectivefs.pool");
const object_store = _.get(driver.options, "objectivefs.env.OBJECTSTORE"); const object_store = _.get(driver.options, "objectivefs.env.OBJECTSTORE");
@ -301,7 +301,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateVolume(call) { async CreateVolume(callContext, call) {
const driver = this; const driver = this;
const ofsClient = await driver.getObjectiveFSClient(); const ofsClient = await driver.getObjectiveFSClient();
const pool = _.get(driver.options, "objectivefs.pool"); const pool = _.get(driver.options, "objectivefs.pool");
@ -347,7 +347,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
call.request.volume_capabilities && call.request.volume_capabilities &&
call.request.volume_capabilities.length > 0 call.request.volume_capabilities.length > 0
) { ) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message); throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message);
} }
@ -446,7 +446,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteVolume(call) { async DeleteVolume(callContext, call) {
const driver = this; const driver = this;
const ofsClient = await driver.getObjectiveFSClient(); const ofsClient = await driver.getObjectiveFSClient();
const pool = _.get(driver.options, "objectivefs.pool"); const pool = _.get(driver.options, "objectivefs.pool");
@ -481,7 +481,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ControllerExpandVolume(call) { async ControllerExpandVolume(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -493,7 +493,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async GetCapacity(call) { async GetCapacity(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -506,7 +506,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListVolumes(call) { async ListVolumes(callContext, call) {
const driver = this; const driver = this;
const ofsClient = await driver.getObjectiveFSClient(); const ofsClient = await driver.getObjectiveFSClient();
const pool = _.get(driver.options, "objectivefs.pool"); const pool = _.get(driver.options, "objectivefs.pool");
@ -588,7 +588,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListSnapshots(call) { async ListSnapshots(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -599,7 +599,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateSnapshot(call) { async CreateSnapshot(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -612,7 +612,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteSnapshot(call) { async DeleteSnapshot(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -623,7 +623,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ValidateVolumeCapabilities(call) { async ValidateVolumeCapabilities(callContext, call) {
const driver = this; const driver = this;
const ofsClient = await driver.getObjectiveFSClient(); const ofsClient = await driver.getObjectiveFSClient();
const pool = _.get(driver.options, "objectivefs.pool"); const pool = _.get(driver.options, "objectivefs.pool");
@ -651,7 +651,7 @@ class ControllerObjectiveFSDriver extends CsiBaseDriver {
throw new GrpcError(grpc.status.INVALID_ARGUMENT, `missing capabilities`); throw new GrpcError(grpc.status.INVALID_ARGUMENT, `missing capabilities`);
} }
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { message: result.message }; return { message: result.message };

View File

@ -250,9 +250,9 @@ class ControllerSynologyDriver extends CsiBaseDriver {
return access_modes; return access_modes;
} }
assertCapabilities(capabilities) { assertCapabilities(callContext, capabilities) {
const driverResourceType = this.getDriverResourceType(); const driverResourceType = this.getDriverResourceType();
this.ctx.logger.verbose("validating capabilities: %j", capabilities); callContext.logger.verbose("validating capabilities: %j", capabilities);
let message = null; let message = null;
//[{"access_mode":{"mode":"SINGLE_NODE_WRITER"},"mount":{"mount_flags":["noatime","_netdev"],"fs_type":"nfs"},"access_type":"mount"}] //[{"access_mode":{"mode":"SINGLE_NODE_WRITER"},"mount":{"mount_flags":["noatime","_netdev"],"fs_type":"nfs"},"access_type":"mount"}]
@ -319,7 +319,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateVolume(call) { async CreateVolume(callContext, call) {
const driver = this; const driver = this;
const httpClient = await driver.getHttpClient(); const httpClient = await driver.getHttpClient();
@ -330,7 +330,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
call.request.volume_capabilities && call.request.volume_capabilities &&
call.request.volume_capabilities.length > 0 call.request.volume_capabilities.length > 0
) { ) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message); throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message);
} }
@ -677,7 +677,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteVolume(call) { async DeleteVolume(callContext, call) {
const driver = this; const driver = this;
const httpClient = await driver.getHttpClient(); const httpClient = await driver.getHttpClient();
@ -785,7 +785,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ControllerExpandVolume(call) { async ControllerExpandVolume(callContext, call) {
const driver = this; const driver = this;
const httpClient = await driver.getHttpClient(); const httpClient = await driver.getHttpClient();
@ -877,7 +877,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async GetCapacity(call) { async GetCapacity(callContext, call) {
const driver = this; const driver = this;
const httpClient = await driver.getHttpClient(); const httpClient = await driver.getHttpClient();
const location = driver.getLocation(); const location = driver.getLocation();
@ -890,7 +890,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
} }
if (call.request.volume_capabilities) { if (call.request.volume_capabilities) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { available_capacity: 0 }; return { available_capacity: 0 };
@ -907,7 +907,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListVolumes(call) { async ListVolumes(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -918,7 +918,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListSnapshots(call) { async ListSnapshots(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -929,7 +929,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateSnapshot(call) { async CreateSnapshot(callContext, call) {
const driver = this; const driver = this;
const httpClient = await driver.getHttpClient(); const httpClient = await driver.getHttpClient();
@ -951,7 +951,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
); );
} }
driver.ctx.logger.verbose("requested snapshot name: %s", name); callContext.logger.verbose("requested snapshot name: %s", name);
let invalid_chars; let invalid_chars;
invalid_chars = name.match(/[^a-z0-9_\-:.+]+/gi); invalid_chars = name.match(/[^a-z0-9_\-:.+]+/gi);
@ -1049,7 +1049,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteSnapshot(call) { async DeleteSnapshot(callContext, call) {
// throw new GrpcError( // throw new GrpcError(
// grpc.status.UNIMPLEMENTED, // grpc.status.UNIMPLEMENTED,
// `operation not supported by driver` // `operation not supported by driver`
@ -1100,7 +1100,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ValidateVolumeCapabilities(call) { async ValidateVolumeCapabilities(callContext, call) {
const driver = this; const driver = this;
const httpClient = await driver.getHttpClient(); const httpClient = await driver.getHttpClient();
@ -1150,7 +1150,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
break; break;
} }
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { message: result.message }; return { message: result.message };
} }

View File

@ -74,10 +74,10 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
} }
} }
generateSmbShareName(datasetName) { generateSmbShareName(callContext, datasetName) {
const driver = this; const driver = this;
driver.ctx.logger.verbose( callContext.logger.verbose(
`generating smb share name for dataset: ${datasetName}` `generating smb share name for dataset: ${datasetName}`
); );
@ -85,7 +85,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
name = name.replaceAll("/", "_"); name = name.replaceAll("/", "_");
name = name.replaceAll("-", "_"); name = name.replaceAll("-", "_");
driver.ctx.logger.verbose( callContext.logger.verbose(
`generated smb share name for dataset (${datasetName}): ${name}` `generated smb share name for dataset (${datasetName}): ${name}`
); );
@ -98,7 +98,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
* *
* @param {*} datasetName * @param {*} datasetName
*/ */
async createShare(call, datasetName) { 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();
@ -133,7 +133,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
properties = await zb.zfs.get(datasetName, ["mountpoint"]); properties = await zb.zfs.get(datasetName, ["mountpoint"]);
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
volume_context = { volume_context = {
node_attach_driver: "nfs", node_attach_driver: "nfs",
@ -160,7 +160,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
} }
} }
share = driver.generateSmbShareName(datasetName); share = driver.generateSmbShareName(callContext, datasetName);
break; break;
default: default:
break; break;
@ -168,7 +168,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
properties = await zb.zfs.get(datasetName, ["mountpoint"]); properties = await zb.zfs.get(datasetName, ["mountpoint"]);
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
volume_context = { volume_context = {
node_attach_driver: "smb", node_attach_driver: "smb",
@ -264,7 +264,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
3, 3,
2000, 2000,
async () => { async () => {
await this.targetCliCommand( await this.targetCliCommand(callContext,
` `
# create target # create target
cd /iscsi cd /iscsi
@ -303,7 +303,7 @@ create /backstores/block/${assetName}
// iqn = target // iqn = target
let iqn = basename + ":" + assetName; let iqn = basename + ":" + assetName;
this.ctx.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(datasetName, {
@ -403,7 +403,7 @@ create ${basename}:${assetName}
3, 3,
2000, 2000,
async () => { async () => {
await this.nvmetCliCommand( await this.nvmetCliCommand(callContext,
` `
# create subsystem # create subsystem
cd /subsystems cd /subsystems
@ -487,7 +487,7 @@ create ${listenerAttributesText}
3, 3,
2000, 2000,
async () => { async () => {
await this.spdkCliCommand( await this.spdkCliCommand(callContext,
` `
# create bdev # create bdev
cd /bdevs/${this.options.nvmeof.shareStrategySpdkCli.bdev.type} cd /bdevs/${this.options.nvmeof.shareStrategySpdkCli.bdev.type}
@ -528,7 +528,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
// iqn = target // iqn = target
let nqn = basename + ":" + assetName; let nqn = basename + ":" + assetName;
this.ctx.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(datasetName, {
@ -555,7 +555,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
} }
} }
async deleteShare(call, datasetName) { async deleteShare(callContext, call, datasetName) {
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
const execClient = this.getExecClient(); const execClient = this.getExecClient();
@ -640,7 +640,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
} }
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
assetName = properties[ISCSI_ASSETS_NAME_PROPERTY_NAME].value; assetName = properties[ISCSI_ASSETS_NAME_PROPERTY_NAME].value;
@ -666,7 +666,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
3, 3,
2000, 2000,
async () => { async () => {
await this.targetCliCommand( await this.targetCliCommand(callContext,
` `
# delete target # delete target
cd /iscsi cd /iscsi
@ -712,7 +712,7 @@ delete ${assetName}
} }
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
assetName = properties[NVMEOF_ASSETS_NAME_PROPERTY_NAME].value; assetName = properties[NVMEOF_ASSETS_NAME_PROPERTY_NAME].value;
@ -756,7 +756,7 @@ delete ${basename}:${assetName}
3, 3,
2000, 2000,
async () => { async () => {
await this.nvmetCliCommand( await this.nvmetCliCommand(callContext,
` `
# delete subsystem from port # delete subsystem from port
${portCommands} ${portCommands}
@ -787,7 +787,7 @@ saveconfig ${savefile}
3, 3,
2000, 2000,
async () => { async () => {
await this.spdkCliCommand( await this.spdkCliCommand(callContext,
` `
# delete subsystem # delete subsystem
cd /nvmf/subsystem/ cd /nvmf/subsystem/
@ -830,7 +830,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
return {}; return {};
} }
async expandVolume(call, datasetName) { async expandVolume(callContext, call, datasetName) {
switch (this.options.driver) { switch (this.options.driver) {
case "zfs-generic-nfs": case "zfs-generic-nfs":
break; break;
@ -850,7 +850,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
} }
} }
async targetCliCommand(data) { async targetCliCommand(callContext, data) {
const execClient = this.getExecClient(); const execClient = this.getExecClient();
const driver = this; const driver = this;
@ -887,7 +887,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
logCommand += "\n"; logCommand += "\n";
}); });
driver.ctx.logger.verbose("TargetCLI command: " + logCommand); callContext.logger.verbose("TargetCLI command: " + logCommand);
// https://github.com/democratic-csi/democratic-csi/issues/127 // https://github.com/democratic-csi/democratic-csi/issues/127
// https://bugs.launchpad.net/ubuntu/+source/python-configshell-fb/+bug/1776761 // https://bugs.launchpad.net/ubuntu/+source/python-configshell-fb/+bug/1776761
@ -901,7 +901,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
execClient.buildCommand(command, args), execClient.buildCommand(command, args),
options options
); );
driver.ctx.logger.verbose( callContext.logger.verbose(
"TargetCLI response: " + JSON.stringify(response) "TargetCLI response: " + JSON.stringify(response)
); );
if (response.code != 0) { if (response.code != 0) {
@ -910,7 +910,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
return response; return response;
} }
async nvmetCliCommand(data) { async nvmetCliCommand(callContext, data) {
const execClient = this.getExecClient(); const execClient = this.getExecClient();
const driver = this; const driver = this;
@ -974,7 +974,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
logCommand += "\n"; logCommand += "\n";
}); });
driver.ctx.logger.verbose("nvmetCLI command: " + logCommand); callContext.logger.verbose("nvmetCLI command: " + logCommand);
//process.exit(0); //process.exit(0);
// https://github.com/democratic-csi/democratic-csi/issues/127 // https://github.com/democratic-csi/democratic-csi/issues/127
@ -989,14 +989,14 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
execClient.buildCommand(command, args), execClient.buildCommand(command, args),
options options
); );
driver.ctx.logger.verbose("nvmetCLI response: " + JSON.stringify(response)); callContext.logger.verbose("nvmetCLI response: " + JSON.stringify(response));
if (response.code != 0) { if (response.code != 0) {
throw response; throw response;
} }
return response; return response;
} }
async spdkCliCommand(data) { async spdkCliCommand(callContext, data) {
const execClient = this.getExecClient(); const execClient = this.getExecClient();
const driver = this; const driver = this;
@ -1033,7 +1033,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
logCommand += "\n"; logCommand += "\n";
}); });
driver.ctx.logger.verbose("spdkCLI command: " + logCommand); callContext.logger.verbose("spdkCLI command: " + logCommand);
//process.exit(0); //process.exit(0);
// https://github.com/democratic-csi/democratic-csi/issues/127 // https://github.com/democratic-csi/democratic-csi/issues/127
@ -1048,7 +1048,7 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath}
execClient.buildCommand(command, args), execClient.buildCommand(command, args),
options options
); );
driver.ctx.logger.verbose("spdkCLI response: " + JSON.stringify(response)); callContext.logger.verbose("spdkCLI response: " + JSON.stringify(response));
if (response.code != 0) { if (response.code != 0) {
throw response; throw response;
} }

View File

@ -160,7 +160,7 @@ class ControllerZfsLocalDriver extends ControllerZfsBaseDriver {
* *
* @param {*} datasetName * @param {*} datasetName
*/ */
async createShare(call, datasetName) { 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) { 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) {} async expandVolume(callContext, call, datasetName) {}
/** /**
* List of topologies associated with the *volume* * List of topologies associated with the *volume*
@ -227,7 +227,7 @@ class ControllerZfsLocalDriver extends ControllerZfsBaseDriver {
* @param {*} call * @param {*} call
* @returns * @returns
*/ */
async NodeGetInfo(call) { async NodeGetInfo(callContext, call) {
const response = await super.NodeGetInfo(...arguments); const response = await super.NodeGetInfo(...arguments);
response.accessible_topology = { response.accessible_topology = {
segments: { segments: {

View File

@ -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) // return appropriate volume_context for Node operations * - async createShare(callContext, call, datasetName) // return appropriate volume_context for Node operations
* - async deleteShare(call, datasetName) // no return expected * - async deleteShare(callContext, call, datasetName) // no return expected
* - async expandVolume(call, datasetName) // 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) {
@ -152,11 +152,11 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
} }
} }
async getWhoAmI() { async getWhoAmI(callContext) {
const driver = this; const driver = this;
const execClient = driver.getExecClient(); const execClient = driver.getExecClient();
const command = "whoami"; const command = "whoami";
driver.ctx.logger.verbose("whoami command: %s", command); callContext.logger.verbose("whoami command: %s", command);
const response = await execClient.exec(command); const response = await execClient.exec(command);
if (response.code !== 0) { if (response.code !== 0) {
throw new Error("failed to run uname to determine max zvol name length"); throw new Error("failed to run uname to determine max zvol name length");
@ -250,9 +250,9 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
return access_modes; return access_modes;
} }
assertCapabilities(capabilities) { assertCapabilities(callContext, capabilities) {
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
this.ctx.logger.verbose("validating capabilities: %j", capabilities); callContext.logger.verbose("validating capabilities: %j", capabilities);
let message = null; let message = null;
//[{"access_mode":{"mode":"SINGLE_NODE_WRITER"},"mount":{"mount_flags":["noatime","_netdev"],"fs_type":"nfs"},"access_type":"mount"}] //[{"access_mode":{"mode":"SINGLE_NODE_WRITER"},"mount":{"mount_flags":["noatime","_netdev"],"fs_type":"nfs"},"access_type":"mount"}]
@ -346,7 +346,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
return volume_status; return volume_status;
} }
async populateCsiVolumeFromData(row) { async populateCsiVolumeFromData(callContext, row) {
const driver = this; const driver = this;
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
@ -360,7 +360,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
if ( if (
!zb.helpers.isPropertyValueSet(row[SHARE_VOLUME_CONTEXT_PROPERTY_NAME]) !zb.helpers.isPropertyValueSet(row[SHARE_VOLUME_CONTEXT_PROPERTY_NAME])
) { ) {
driver.ctx.logger.warn(`${row.name} is missing share context`); callContext.logger.warn(`${row.name} is missing share context`);
return; return;
} }
@ -430,7 +430,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238112 * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238112
* https://svnweb.freebsd.org/base?view=revision&revision=343485 * https://svnweb.freebsd.org/base?view=revision&revision=343485
*/ */
async getMaxZvolNameLength() { async getMaxZvolNameLength(callContext) {
const driver = this; const driver = this;
const execClient = driver.getExecClient(); const execClient = driver.getExecClient();
@ -449,7 +449,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
// get kernel // get kernel
command = "uname -s"; command = "uname -s";
driver.ctx.logger.verbose("uname command: %s", command); callContext.logger.verbose("uname command: %s", command);
response = await execClient.exec(command); response = await execClient.exec(command);
if (response.code !== 0) { if (response.code !== 0) {
throw new Error("failed to run uname to determine max zvol name length"); throw new Error("failed to run uname to determine max zvol name length");
@ -468,7 +468,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
case "freebsd": case "freebsd":
// get kernel_release // get kernel_release
command = "uname -r"; command = "uname -r";
driver.ctx.logger.verbose("uname command: %s", command); callContext.logger.verbose("uname command: %s", command);
response = await execClient.exec(command); response = await execClient.exec(command);
if (response.code !== 0) { if (response.code !== 0) {
throw new Error( throw new Error(
@ -496,16 +496,16 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
return max; return max;
} }
async setFilesystemMode(path, mode) { async setFilesystemMode(callContext, path, mode) {
const driver = this; const driver = this;
const execClient = this.getExecClient(); const execClient = this.getExecClient();
let command = execClient.buildCommand("chmod", [mode, path]); let command = execClient.buildCommand("chmod", [mode, path]);
if ((await driver.getWhoAmI()) != "root") { if ((await driver.getWhoAmI(callContext)) != "root") {
command = (await driver.getSudoPath()) + " " + command; command = (await driver.getSudoPath()) + " " + command;
} }
driver.ctx.logger.verbose("set permission command: %s", command); callContext.logger.verbose("set permission command: %s", command);
let response = await execClient.exec(command); let response = await execClient.exec(command);
if (response.code != 0) { if (response.code != 0) {
@ -516,7 +516,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
} }
} }
async setFilesystemOwnership(path, user = false, group = false) { async setFilesystemOwnership(callContext, path, user = false, group = false) {
const driver = this; const driver = this;
const execClient = this.getExecClient(); const execClient = this.getExecClient();
@ -539,11 +539,11 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
(user.length > 0 ? user : "") + ":" + (group.length > 0 ? group : ""), (user.length > 0 ? user : "") + ":" + (group.length > 0 ? group : ""),
path, path,
]); ]);
if ((await driver.getWhoAmI()) != "root") { if ((await driver.getWhoAmI(callContext)) != "root") {
command = (await driver.getSudoPath()) + " " + command; command = (await driver.getSudoPath()) + " " + command;
} }
driver.ctx.logger.verbose("set ownership command: %s", command); callContext.logger.verbose("set ownership command: %s", command);
let response = await execClient.exec(command); let response = await execClient.exec(command);
if (response.code != 0) { if (response.code != 0) {
@ -562,7 +562,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async Probe(call) { async Probe(callContext, call) {
const driver = this; const driver = this;
if (driver.ctx.args.csiMode.includes("controller")) { if (driver.ctx.args.csiMode.includes("controller")) {
@ -590,7 +590,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
*/ */
if (!driver.currentExecShell || timerEnabled === false) { if (!driver.currentExecShell || timerEnabled === false) {
const execClient = this.getExecClient(); const execClient = this.getExecClient();
driver.ctx.logger.debug("performing exec sanity check.."); callContext.logger.debug("performing exec sanity check..");
const response = await execClient.exec("echo $0"); const response = await execClient.exec("echo $0");
driver.currentExecShell = response.stdout.split("\n")[0]; driver.currentExecShell = response.stdout.split("\n")[0];
} }
@ -600,7 +600,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
const intervalTime = 60000; const intervalTime = 60000;
driver.currentExecShellInterval = setInterval(async () => { driver.currentExecShellInterval = setInterval(async () => {
try { try {
driver.ctx.logger.debug("performing exec sanity check.."); callContext.logger.debug("performing exec sanity check..");
const execClient = this.getExecClient(); const execClient = this.getExecClient();
const response = await execClient.exec("echo $0"); const response = await execClient.exec("echo $0");
driver.currentExecShell = response.stdout.split("\n")[0]; driver.currentExecShell = response.stdout.split("\n")[0];
@ -634,7 +634,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateVolume(call) { async CreateVolume(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const execClient = this.getExecClient(); const execClient = this.getExecClient();
@ -658,7 +658,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
call.request.volume_capabilities && call.request.volume_capabilities &&
call.request.volume_capabilities.length > 0 call.request.volume_capabilities.length > 0
) { ) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message); throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message);
} }
@ -792,8 +792,8 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
*/ */
if (driverZfsResourceType == "volume") { if (driverZfsResourceType == "volume") {
let extentDiskName = "zvol/" + datasetName; let extentDiskName = "zvol/" + datasetName;
let maxZvolNameLength = await driver.getMaxZvolNameLength(); let maxZvolNameLength = await driver.getMaxZvolNameLength(callContext);
driver.ctx.logger.debug("max zvol name length: %s", maxZvolNameLength); callContext.logger.debug("max zvol name length: %s", maxZvolNameLength);
if (extentDiskName.length > maxZvolNameLength) { if (extentDiskName.length > maxZvolNameLength) {
throw new GrpcError( throw new GrpcError(
@ -849,7 +849,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
volumeProperties[VOLUME_CONTENT_SOURCE_TYPE_PROPERTY_NAME] = volumeProperties[VOLUME_CONTENT_SOURCE_TYPE_PROPERTY_NAME] =
volume_content_source.type; volume_content_source.type;
switch (volume_content_source.type) { switch (volume_content_source.type) {
// must be available when adverstising CREATE_DELETE_SNAPSHOT // must be available when advertising CREATE_DELETE_SNAPSHOT
// simply clone // simply clone
case "snapshot": case "snapshot":
try { try {
@ -883,7 +883,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
volume_id; volume_id;
} }
driver.ctx.logger.debug("full snapshot name: %s", fullSnapshotName); callContext.logger.debug("full snapshot name: %s", fullSnapshotName);
if (!zb.helpers.isZfsSnapshot(volume_content_source_snapshot_id)) { if (!zb.helpers.isZfsSnapshot(volume_content_source_snapshot_id)) {
try { try {
@ -997,7 +997,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
VOLUME_SOURCE_CLONE_SNAPSHOT_PREFIX + VOLUME_SOURCE_CLONE_SNAPSHOT_PREFIX +
volume_id; volume_id;
driver.ctx.logger.debug("full snapshot name: %s", fullSnapshotName); callContext.logger.debug("full snapshot name: %s", fullSnapshotName);
// create snapshot // create snapshot
try { try {
@ -1130,11 +1130,12 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
VOLUME_CONTENT_SOURCE_ID_PROPERTY_NAME, VOLUME_CONTENT_SOURCE_ID_PROPERTY_NAME,
]); ]);
properties = properties[datasetName]; properties = properties[datasetName];
driver.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
// set mode // set mode
if (this.options.zfs.datasetPermissionsMode) { if (this.options.zfs.datasetPermissionsMode) {
await driver.setFilesystemMode( await driver.setFilesystemMode(
callContext,
properties.mountpoint.value, properties.mountpoint.value,
this.options.zfs.datasetPermissionsMode this.options.zfs.datasetPermissionsMode
); );
@ -1148,6 +1149,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
.length > 0 .length > 0
) { ) {
await driver.setFilesystemOwnership( await driver.setFilesystemOwnership(
callContext,
properties.mountpoint.value, properties.mountpoint.value,
this.options.zfs.datasetPermissionsUser, this.options.zfs.datasetPermissionsUser,
this.options.zfs.datasetPermissionsGroup this.options.zfs.datasetPermissionsGroup
@ -1155,7 +1157,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
} }
// set acls // set acls
// TODO: this is unsfafe approach, make it better // TODO: this is unsafe approach, make it better
// probably could see if ^-.*\s and split and then shell escape // probably could see if ^-.*\s and split and then shell escape
if (this.options.zfs.datasetPermissionsAcls) { if (this.options.zfs.datasetPermissionsAcls) {
let aclBinary = _.get( let aclBinary = _.get(
@ -1168,11 +1170,11 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
acl, acl,
properties.mountpoint.value, properties.mountpoint.value,
]); ]);
if ((await this.getWhoAmI()) != "root") { if ((await driver.getWhoAmI(callContext)) != "root") {
command = (await this.getSudoPath()) + " " + command; command = (await this.getSudoPath()) + " " + command;
} }
driver.ctx.logger.verbose("set acl command: %s", command); callContext.logger.verbose("set acl command: %s", command);
response = await execClient.exec(command); response = await execClient.exec(command);
if (response.code != 0) { if (response.code != 0) {
throw new GrpcError( throw new GrpcError(
@ -1222,7 +1224,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
break; break;
} }
volume_context = await this.createShare(call, datasetName); volume_context = await this.createShare(callContext, call, datasetName);
await zb.zfs.set(datasetName, { await zb.zfs.set(datasetName, {
[SHARE_VOLUME_CONTEXT_PROPERTY_NAME]: JSON.stringify(volume_context), [SHARE_VOLUME_CONTEXT_PROPERTY_NAME]: JSON.stringify(volume_context),
}); });
@ -1269,7 +1271,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteVolume(call) { async DeleteVolume(callContext, call) {
const driver = this; const driver = this;
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -1314,7 +1316,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
} }
} }
driver.ctx.logger.debug("dataset properties: %j", properties); callContext.logger.debug("dataset properties: %j", properties);
// deleteStrategy // deleteStrategy
const delete_strategy = _.get( const delete_strategy = _.get(
@ -1328,7 +1330,7 @@ class ControllerZfsBaseDriver 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 (
@ -1339,7 +1341,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
.extractSnapshotName(properties.origin.value) .extractSnapshotName(properties.origin.value)
.startsWith(VOLUME_SOURCE_CLONE_SNAPSHOT_PREFIX) .startsWith(VOLUME_SOURCE_CLONE_SNAPSHOT_PREFIX)
) { ) {
driver.ctx.logger.debug( callContext.logger.debug(
"removing with defer source snapshot: %s", "removing with defer source snapshot: %s",
properties.origin.value properties.origin.value
); );
@ -1401,7 +1403,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ControllerExpandVolume(call) { async ControllerExpandVolume(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -1503,7 +1505,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
await zb.zfs.set(datasetName, properties); await zb.zfs.set(datasetName, properties);
} }
await this.expandVolume(call, datasetName); await this.expandVolume(callContext, call, datasetName);
return { return {
capacity_bytes: capacity_bytes:
@ -1520,7 +1522,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async GetCapacity(call) { async GetCapacity(callContext, call) {
const driver = this; const driver = this;
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -1534,7 +1536,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
} }
if (call.request.volume_capabilities) { if (call.request.volume_capabilities) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { available_capacity: 0 }; return { available_capacity: 0 };
@ -1569,7 +1571,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ControllerGetVolume(call) { async ControllerGetVolume(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -1632,8 +1634,8 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
throw err; throw err;
} }
driver.ctx.logger.debug("list volumes result: %j", response); callContext.logger.debug("list volumes result: %j", response);
let volume = await driver.populateCsiVolumeFromData(response.indexed[0]); let volume = await driver.populateCsiVolumeFromData(callContext, response.indexed[0]);
let status = await driver.getVolumeStatus(datasetName); let status = await driver.getVolumeStatus(datasetName);
let res = { volume }; let res = { volume };
@ -1650,7 +1652,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListVolumes(call) { async ListVolumes(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -1747,7 +1749,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
throw err; throw err;
} }
driver.ctx.logger.debug("list volumes result: %j", response); callContext.logger.debug("list volumes result: %j", response);
// remove parent dataset from results // remove parent dataset from results
if (driverZfsResourceType == "filesystem") { if (driverZfsResourceType == "filesystem") {
@ -1761,7 +1763,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
continue; continue;
} }
let volume = await driver.populateCsiVolumeFromData(row); let volume = await driver.populateCsiVolumeFromData(callContext, row);
if (volume) { if (volume) {
let status = await driver.getVolumeStatus(datasetName); let status = await driver.getVolumeStatus(datasetName);
entries.push({ entries.push({
@ -1790,7 +1792,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListSnapshots(call) { async ListSnapshots(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -2044,7 +2046,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateSnapshot(call) { async CreateSnapshot(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -2113,7 +2115,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
source_volume_id; source_volume_id;
snapshotProperties[MANAGED_PROPERTY_NAME] = "true"; snapshotProperties[MANAGED_PROPERTY_NAME] = "true";
driver.ctx.logger.verbose("requested snapshot name: %s", name); callContext.logger.verbose("requested snapshot name: %s", name);
let invalid_chars; let invalid_chars;
invalid_chars = name.match(/[^a-z0-9_\-:.+]+/gi); invalid_chars = name.match(/[^a-z0-9_\-:.+]+/gi);
@ -2130,7 +2132,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
// https://stackoverflow.com/questions/32106243/regex-to-remove-all-non-alpha-numeric-and-replace-spaces-with/32106277 // https://stackoverflow.com/questions/32106243/regex-to-remove-all-non-alpha-numeric-and-replace-spaces-with/32106277
name = name.replace(/[^a-z0-9_\-:.+]+/gi, ""); name = name.replace(/[^a-z0-9_\-:.+]+/gi, "");
driver.ctx.logger.verbose("cleansed snapshot name: %s", name); callContext.logger.verbose("cleansed snapshot name: %s", name);
// check for other snapshopts with the same name on other volumes and fail as appropriate // check for other snapshopts with the same name on other volumes and fail as appropriate
{ {
@ -2189,7 +2191,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
fullSnapshotName = datasetName + "@" + name; fullSnapshotName = datasetName + "@" + name;
} }
driver.ctx.logger.verbose("full snapshot name: %s", fullSnapshotName); callContext.logger.verbose("full snapshot name: %s", fullSnapshotName);
if (detachedSnapshot) { if (detachedSnapshot) {
tmpSnapshotName = tmpSnapshotName =
@ -2297,7 +2299,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
{ types } { types }
); );
properties = properties[fullSnapshotName]; properties = properties[fullSnapshotName];
driver.ctx.logger.verbose("snapshot properties: %j", properties); callContext.logger.verbose("snapshot properties: %j", properties);
// TODO: properly handle use-case where datasetEnableQuotas is not turned on // TODO: properly handle use-case where datasetEnableQuotas is not turned on
if (driverZfsResourceType == "filesystem") { if (driverZfsResourceType == "filesystem") {
@ -2352,7 +2354,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteSnapshot(call) { async DeleteSnapshot(callContext, call) {
const driver = this; const driver = this;
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -2383,7 +2385,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
const fullSnapshotName = datasetParentName + "/" + snapshot_id; const fullSnapshotName = datasetParentName + "/" + snapshot_id;
driver.ctx.logger.verbose("deleting snapshot: %s", fullSnapshotName); callContext.logger.verbose("deleting snapshot: %s", fullSnapshotName);
try { try {
await zb.zfs.destroy(fullSnapshotName, { await zb.zfs.destroy(fullSnapshotName, {
@ -2423,7 +2425,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ValidateVolumeCapabilities(call) { async ValidateVolumeCapabilities(callContext, call) {
const driver = this; const driver = this;
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -2461,7 +2463,7 @@ class ControllerZfsBaseDriver extends CsiBaseDriver {
} }
} }
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { message: result.message }; return { message: result.message };

View File

@ -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();
@ -207,7 +207,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
"mountpoint", "mountpoint",
FREENAS_NFS_SHARE_PROPERTY_NAME, FREENAS_NFS_SHARE_PROPERTY_NAME,
]); ]);
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
// create nfs share // create nfs share
if ( if (
@ -419,7 +419,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
"mountpoint", "mountpoint",
FREENAS_SMB_SHARE_PROPERTY_NAME, FREENAS_SMB_SHARE_PROPERTY_NAME,
]); ]);
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
let smbName; let smbName;
@ -442,7 +442,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
smbName = smbName.toLowerCase(); smbName = smbName.toLowerCase();
this.ctx.logger.info( callContext.logger.info(
"FreeNAS creating smb share with name: " + smbName "FreeNAS creating smb share with name: " + smbName
); );
@ -668,7 +668,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME, FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME,
FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME, FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME,
]); ]);
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
let basename; let basename;
let iscsiName; let iscsiName;
@ -698,7 +698,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
let extentDiskName = "zvol/" + datasetName; let extentDiskName = "zvol/" + datasetName;
let maxZvolNameLength = await driver.getMaxZvolNameLength(); let maxZvolNameLength = await driver.getMaxZvolNameLength();
driver.ctx.logger.debug("max zvol name length: %s", maxZvolNameLength); callContext.logger.debug("max zvol name length: %s", maxZvolNameLength);
/** /**
* limit is a FreeBSD limitation * limit is a FreeBSD limitation
@ -719,7 +719,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
); );
} }
this.ctx.logger.info( callContext.logger.info(
"FreeNAS creating iscsi assets with name: " + iscsiName "FreeNAS creating iscsi assets with name: " + iscsiName
); );
@ -793,7 +793,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
); );
} }
basename = response.body.iscsi_basename; basename = response.body.iscsi_basename;
this.ctx.logger.verbose("FreeNAS ISCSI BASENAME: " + basename); callContext.logger.verbose("FreeNAS ISCSI BASENAME: " + basename);
break; break;
case 2: case 2:
response = await httpClient.get("/iscsi/global"); response = await httpClient.get("/iscsi/global");
@ -806,7 +806,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
); );
} }
basename = response.body.basename; basename = response.body.basename;
this.ctx.logger.verbose("FreeNAS ISCSI BASENAME: " + basename); callContext.logger.verbose("FreeNAS ISCSI BASENAME: " + basename);
break; break;
default: default:
throw new GrpcError( throw new GrpcError(
@ -876,7 +876,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
); );
} }
this.ctx.logger.verbose("FreeNAS ISCSI TARGET: %j", target); callContext.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(datasetName, {
@ -958,7 +958,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
); );
} }
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS ISCSI TARGET_GROUP: %j", "FreeNAS ISCSI TARGET_GROUP: %j",
targetGroup targetGroup
); );
@ -1024,7 +1024,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
); );
} }
this.ctx.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent); callContext.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent);
await httpApiClient.DatasetSet(datasetName, { await httpApiClient.DatasetSet(datasetName, {
[FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id, [FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id,
@ -1082,7 +1082,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
`unknown error creating iscsi targettoextent` `unknown error creating iscsi targettoextent`
); );
} }
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS ISCSI TARGET_TO_EXTENT: %j", "FreeNAS ISCSI TARGET_TO_EXTENT: %j",
targetToExtent targetToExtent
); );
@ -1208,7 +1208,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
} }
} }
this.ctx.logger.verbose("FreeNAS ISCSI TARGET: %j", target); callContext.logger.verbose("FreeNAS ISCSI TARGET: %j", target);
// set target.id on zvol // set target.id on zvol
await httpApiClient.DatasetSet(datasetName, { await httpApiClient.DatasetSet(datasetName, {
@ -1273,7 +1273,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
); );
} }
this.ctx.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent); callContext.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent);
await httpApiClient.DatasetSet(datasetName, { await httpApiClient.DatasetSet(datasetName, {
[FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id, [FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id,
@ -1330,7 +1330,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
`unknown error creating iscsi targetextent` `unknown error creating iscsi targetextent`
); );
} }
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS ISCSI TARGET_TO_EXTENT: %j", "FreeNAS ISCSI TARGET_TO_EXTENT: %j",
targetToExtent targetToExtent
); );
@ -1351,7 +1351,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
// iqn = target // iqn = target
let iqn = basename + ":" + iscsiName; let iqn = basename + ":" + iscsiName;
this.ctx.logger.info("FreeNAS iqn: " + iqn); callContext.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 httpApiClient.DatasetSet(datasetName, { await httpApiClient.DatasetSet(datasetName, {
@ -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();
@ -1405,7 +1405,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
} }
throw err; throw err;
} }
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
shareId = properties[FREENAS_NFS_SHARE_PROPERTY_NAME].value; shareId = properties[FREENAS_NFS_SHARE_PROPERTY_NAME].value;
@ -1507,7 +1507,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
} }
throw err; throw err;
} }
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
shareId = properties[FREENAS_SMB_SHARE_PROPERTY_NAME].value; shareId = properties[FREENAS_SMB_SHARE_PROPERTY_NAME].value;
@ -1618,7 +1618,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
throw err; throw err;
} }
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
let targetId = properties[FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME].value; let targetId = properties[FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME].value;
let extentId = properties[FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME].value; let extentId = properties[FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME].value;
@ -1684,7 +1684,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
_.get(response, "body.errno") == 14 _.get(response, "body.errno") == 14
) { ) {
retries++; retries++;
this.ctx.logger.debug( callContext.logger.debug(
"target: %s is in use, retry %s shortly", "target: %s is in use, retry %s shortly",
targetId, targetId,
retries retries
@ -1709,7 +1709,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME
); );
} else { } else {
this.ctx.logger.debug( callContext.logger.debug(
"not deleting iscsitarget asset as it appears ID %s has been re-used: zfs name - %s, iscsitarget name - %s", "not deleting iscsitarget asset as it appears ID %s has been re-used: zfs name - %s, iscsitarget name - %s",
targetId, targetId,
iscsiName, iscsiName,
@ -1771,7 +1771,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME
); );
} else { } else {
this.ctx.logger.debug( callContext.logger.debug(
"not deleting iscsiextent asset as it appears ID %s has been re-used: zfs name - %s, iscsiextent name - %s", "not deleting iscsiextent asset as it appears ID %s has been re-used: zfs name - %s, iscsiextent name - %s",
extentId, extentId,
iscsiName, iscsiName,
@ -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();
@ -1833,7 +1833,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
command = (await this.getSudoPath()) + " " + command; command = (await this.getSudoPath()) + " " + command;
} }
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS reloading iscsi daemon: %s", "FreeNAS reloading iscsi daemon: %s",
command command
); );
@ -1887,7 +1887,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
return volume_status; return volume_status;
} }
async populateCsiVolumeFromData(row) { async populateCsiVolumeFromData(callContext, row) {
const driver = this; const driver = this;
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
@ -1901,7 +1901,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
if ( if (
!zb.helpers.isPropertyValueSet(row[SHARE_VOLUME_CONTEXT_PROPERTY_NAME]) !zb.helpers.isPropertyValueSet(row[SHARE_VOLUME_CONTEXT_PROPERTY_NAME])
) { ) {
driver.ctx.logger.warn(`${row.name} is missing share context`); callContext.logger.warn(`${row.name} is missing share context`);
return; return;
} }
@ -2082,9 +2082,9 @@ class FreeNASApiDriver extends CsiBaseDriver {
return access_modes; return access_modes;
} }
assertCapabilities(capabilities) { assertCapabilities(callContext, capabilities) {
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
this.ctx.logger.verbose("validating capabilities: %j", capabilities); callContext.logger.verbose("validating capabilities: %j", capabilities);
let message = null; let message = null;
//[{"access_mode":{"mode":"SINGLE_NODE_WRITER"},"mount":{"mount_flags":["noatime","_netdev"],"fs_type":"nfs"},"access_type":"mount"}] //[{"access_mode":{"mode":"SINGLE_NODE_WRITER"},"mount":{"mount_flags":["noatime","_netdev"],"fs_type":"nfs"},"access_type":"mount"}]
@ -2177,7 +2177,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async Probe(call) { async Probe(callContext, call) {
const driver = this; const driver = this;
const httpApiClient = await driver.getTrueNASHttpApiClient(); const httpApiClient = await driver.getTrueNASHttpApiClient();
@ -2228,7 +2228,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateVolume(call) { async CreateVolume(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
@ -2254,7 +2254,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
call.request.volume_capabilities && call.request.volume_capabilities &&
call.request.volume_capabilities.length > 0 call.request.volume_capabilities.length > 0
) { ) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message); throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message);
} }
@ -2403,7 +2403,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
if (driverZfsResourceType == "volume") { if (driverZfsResourceType == "volume") {
let extentDiskName = "zvol/" + datasetName; let extentDiskName = "zvol/" + datasetName;
let maxZvolNameLength = await driver.getMaxZvolNameLength(); let maxZvolNameLength = await driver.getMaxZvolNameLength();
driver.ctx.logger.debug("max zvol name length: %s", maxZvolNameLength); callContext.logger.debug("max zvol name length: %s", maxZvolNameLength);
if (extentDiskName.length > maxZvolNameLength) { if (extentDiskName.length > maxZvolNameLength) {
throw new GrpcError( throw new GrpcError(
grpc.status.FAILED_PRECONDITION, grpc.status.FAILED_PRECONDITION,
@ -2495,7 +2495,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
volume_id; volume_id;
} }
driver.ctx.logger.debug("full snapshot name: %s", fullSnapshotName); callContext.logger.debug("full snapshot name: %s", fullSnapshotName);
if (!zb.helpers.isZfsSnapshot(volume_content_source_snapshot_id)) { if (!zb.helpers.isZfsSnapshot(volume_content_source_snapshot_id)) {
try { try {
@ -2656,7 +2656,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
VOLUME_SOURCE_CLONE_SNAPSHOT_PREFIX + VOLUME_SOURCE_CLONE_SNAPSHOT_PREFIX +
volume_id; volume_id;
driver.ctx.logger.debug("full snapshot name: %s", fullSnapshotName); callContext.logger.debug("full snapshot name: %s", fullSnapshotName);
// create snapshot // create snapshot
try { try {
@ -2841,7 +2841,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
VOLUME_CONTENT_SOURCE_TYPE_PROPERTY_NAME, VOLUME_CONTENT_SOURCE_TYPE_PROPERTY_NAME,
VOLUME_CONTENT_SOURCE_ID_PROPERTY_NAME, VOLUME_CONTENT_SOURCE_ID_PROPERTY_NAME,
]); ]);
driver.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
// set mode // set mode
let perms = { let perms = {
@ -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(callContext, call) {
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();
@ -3045,7 +3045,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
} }
} }
driver.ctx.logger.debug("dataset properties: %j", properties); callContext.logger.debug("dataset properties: %j", properties);
// deleteStrategy // deleteStrategy
const delete_strategy = _.get( const delete_strategy = _.get(
@ -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 (
@ -3070,7 +3070,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
.extractSnapshotName(properties.origin.value) .extractSnapshotName(properties.origin.value)
.startsWith(VOLUME_SOURCE_CLONE_SNAPSHOT_PREFIX) .startsWith(VOLUME_SOURCE_CLONE_SNAPSHOT_PREFIX)
) { ) {
driver.ctx.logger.debug( callContext.logger.debug(
"removing with defer source snapshot: %s", "removing with defer source snapshot: %s",
properties.origin.value properties.origin.value
); );
@ -3133,7 +3133,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ControllerExpandVolume(call) { async ControllerExpandVolume(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
@ -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:
@ -3254,7 +3254,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async GetCapacity(call) { async GetCapacity(callContext, call) {
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();
@ -3269,7 +3269,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
} }
if (call.request.volume_capabilities) { if (call.request.volume_capabilities) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { available_capacity: 0 }; return { available_capacity: 0 };
@ -3302,7 +3302,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ControllerGetVolume(call) { async ControllerGetVolume(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
@ -3358,8 +3358,8 @@ class FreeNASApiDriver extends CsiBaseDriver {
row[p] = response[p].rawvalue; row[p] = response[p].rawvalue;
} }
driver.ctx.logger.debug("list volumes result: %j", row); callContext.logger.debug("list volumes result: %j", row);
let volume = await driver.populateCsiVolumeFromData(row); let volume = await driver.populateCsiVolumeFromData(callContext, row);
let status = await driver.getVolumeStatus(datasetName); let status = await driver.getVolumeStatus(datasetName);
let res = { volume }; let res = { volume };
@ -3376,7 +3376,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListVolumes(call) { async ListVolumes(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const httpClient = await this.getHttpClient(); const httpClient = await this.getHttpClient();
@ -3475,7 +3475,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
} }
} }
driver.ctx.logger.debug("list volumes result: %j", rows); callContext.logger.debug("list volumes result: %j", rows);
entries = []; entries = [];
for (let row of rows) { for (let row of rows) {
@ -3489,7 +3489,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
"" ""
); );
let volume = await driver.populateCsiVolumeFromData(row); let volume = await driver.populateCsiVolumeFromData(callContext, row);
if (volume) { if (volume) {
let status = await driver.getVolumeStatus(volume_id); let status = await driver.getVolumeStatus(volume_id);
entries.push({ entries.push({
@ -3518,7 +3518,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListSnapshots(call) { async ListSnapshots(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const httpClient = await this.getHttpClient(); const httpClient = await this.getHttpClient();
@ -3935,7 +3935,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateSnapshot(call) { async CreateSnapshot(callContext, call) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const httpClient = await this.getHttpClient(); const httpClient = await this.getHttpClient();
@ -4005,7 +4005,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
source_volume_id; source_volume_id;
snapshotProperties[MANAGED_PROPERTY_NAME] = "true"; snapshotProperties[MANAGED_PROPERTY_NAME] = "true";
driver.ctx.logger.verbose("requested snapshot name: %s", name); callContext.logger.verbose("requested snapshot name: %s", name);
let invalid_chars; let invalid_chars;
invalid_chars = name.match(/[^a-z0-9_\-:.+]+/gi); invalid_chars = name.match(/[^a-z0-9_\-:.+]+/gi);
@ -4022,7 +4022,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
// https://stackoverflow.com/questions/32106243/regex-to-remove-all-non-alpha-numeric-and-replace-spaces-with/32106277 // https://stackoverflow.com/questions/32106243/regex-to-remove-all-non-alpha-numeric-and-replace-spaces-with/32106277
name = name.replace(/[^a-z0-9_\-:.+]+/gi, ""); name = name.replace(/[^a-z0-9_\-:.+]+/gi, "");
driver.ctx.logger.verbose("cleansed snapshot name: %s", name); callContext.logger.verbose("cleansed snapshot name: %s", name);
// check for other snapshopts with the same name on other volumes and fail as appropriate // check for other snapshopts with the same name on other volumes and fail as appropriate
{ {
@ -4107,7 +4107,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
fullSnapshotName = datasetName + "@" + name; fullSnapshotName = datasetName + "@" + name;
} }
driver.ctx.logger.verbose("full snapshot name: %s", fullSnapshotName); callContext.logger.verbose("full snapshot name: %s", fullSnapshotName);
if (detachedSnapshot) { if (detachedSnapshot) {
tmpSnapshotName = tmpSnapshotName =
@ -4266,7 +4266,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
); );
} }
driver.ctx.logger.verbose("snapshot properties: %j", properties); callContext.logger.verbose("snapshot properties: %j", properties);
// TODO: properly handle use-case where datasetEnableQuotas is not turned on // TODO: properly handle use-case where datasetEnableQuotas is not turned on
if (driverZfsResourceType == "filesystem") { if (driverZfsResourceType == "filesystem") {
@ -4333,7 +4333,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteSnapshot(call) { async DeleteSnapshot(callContext, call) {
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();
@ -4365,7 +4365,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
const fullSnapshotName = datasetParentName + "/" + snapshot_id; const fullSnapshotName = datasetParentName + "/" + snapshot_id;
driver.ctx.logger.verbose("deleting snapshot: %s", fullSnapshotName); callContext.logger.verbose("deleting snapshot: %s", fullSnapshotName);
if (detachedSnapshot) { if (detachedSnapshot) {
try { try {
@ -4413,7 +4413,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ValidateVolumeCapabilities(call) { async ValidateVolumeCapabilities(callContext, call) {
const driver = this; const driver = this;
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
@ -4450,7 +4450,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
} }
} }
const result = this.assertCapabilities(capabilities); const result = this.assertCapabilities(callContext, capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { message: result.message }; return { message: result.message };

View File

@ -35,7 +35,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async Probe(call) { async Probe(callContext, call) {
const driver = this; const driver = this;
if (driver.ctx.args.csiMode.includes("controller")) { if (driver.ctx.args.csiMode.includes("controller")) {
@ -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();
@ -284,7 +284,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
FREENAS_NFS_SHARE_PROPERTY_NAME, FREENAS_NFS_SHARE_PROPERTY_NAME,
]); ]);
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
// create nfs share // create nfs share
if ( if (
@ -495,7 +495,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
FREENAS_SMB_SHARE_PROPERTY_NAME, FREENAS_SMB_SHARE_PROPERTY_NAME,
]); ]);
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
let smbName; let smbName;
@ -518,7 +518,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
smbName = smbName.toLowerCase(); smbName = smbName.toLowerCase();
this.ctx.logger.info( callContext.logger.info(
"FreeNAS creating smb share with name: " + smbName "FreeNAS creating smb share with name: " + smbName
); );
@ -744,7 +744,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME, FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME,
]); ]);
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
let basename; let basename;
let iscsiName; let iscsiName;
@ -773,8 +773,8 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
iscsiName = iscsiName.toLowerCase(); iscsiName = iscsiName.toLowerCase();
let extentDiskName = "zvol/" + datasetName; let extentDiskName = "zvol/" + datasetName;
let maxZvolNameLength = await driver.getMaxZvolNameLength(); let maxZvolNameLength = await driver.getMaxZvolNameLength(callContext);
driver.ctx.logger.debug("max zvol name length: %s", maxZvolNameLength); callContext.logger.debug("max zvol name length: %s", maxZvolNameLength);
/** /**
* limit is a FreeBSD limitation * limit is a FreeBSD limitation
@ -796,7 +796,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
); );
} }
this.ctx.logger.info( callContext.logger.info(
"FreeNAS creating iscsi assets with name: " + iscsiName "FreeNAS creating iscsi assets with name: " + iscsiName
); );
@ -870,7 +870,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
); );
} }
basename = response.body.iscsi_basename; basename = response.body.iscsi_basename;
this.ctx.logger.verbose("FreeNAS ISCSI BASENAME: " + basename); callContext.logger.verbose("FreeNAS ISCSI BASENAME: " + basename);
break; break;
case 2: case 2:
response = await httpClient.get("/iscsi/global"); response = await httpClient.get("/iscsi/global");
@ -883,7 +883,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
); );
} }
basename = response.body.basename; basename = response.body.basename;
this.ctx.logger.verbose("FreeNAS ISCSI BASENAME: " + basename); callContext.logger.verbose("FreeNAS ISCSI BASENAME: " + basename);
break; break;
default: default:
throw new GrpcError( throw new GrpcError(
@ -953,7 +953,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
); );
} }
this.ctx.logger.verbose("FreeNAS ISCSI TARGET: %j", target); callContext.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(datasetName, {
@ -1035,7 +1035,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
); );
} }
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS ISCSI TARGET_GROUP: %j", "FreeNAS ISCSI TARGET_GROUP: %j",
targetGroup targetGroup
); );
@ -1101,7 +1101,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
); );
} }
this.ctx.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent); callContext.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent);
await zb.zfs.set(datasetName, { await zb.zfs.set(datasetName, {
[FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id, [FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id,
@ -1159,7 +1159,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
`unknown error creating iscsi targettoextent` `unknown error creating iscsi targettoextent`
); );
} }
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS ISCSI TARGET_TO_EXTENT: %j", "FreeNAS ISCSI TARGET_TO_EXTENT: %j",
targetToExtent targetToExtent
); );
@ -1285,7 +1285,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
} }
} }
this.ctx.logger.verbose("FreeNAS ISCSI TARGET: %j", target); callContext.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(datasetName, {
@ -1350,7 +1350,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
); );
} }
this.ctx.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent); callContext.logger.verbose("FreeNAS ISCSI EXTENT: %j", extent);
await zb.zfs.set(datasetName, { await zb.zfs.set(datasetName, {
[FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id, [FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME]: extent.id,
@ -1407,7 +1407,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
`unknown error creating iscsi targetextent` `unknown error creating iscsi targetextent`
); );
} }
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS ISCSI TARGET_TO_EXTENT: %j", "FreeNAS ISCSI TARGET_TO_EXTENT: %j",
targetToExtent targetToExtent
); );
@ -1428,7 +1428,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
// iqn = target // iqn = target
let iqn = basename + ":" + iscsiName; let iqn = basename + ":" + iscsiName;
this.ctx.logger.info("FreeNAS iqn: " + iqn); callContext.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(datasetName, {
@ -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();
@ -1482,7 +1482,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
throw err; throw err;
} }
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
shareId = properties[FREENAS_NFS_SHARE_PROPERTY_NAME].value; shareId = properties[FREENAS_NFS_SHARE_PROPERTY_NAME].value;
@ -1585,7 +1585,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
throw err; throw err;
} }
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
shareId = properties[FREENAS_SMB_SHARE_PROPERTY_NAME].value; shareId = properties[FREENAS_SMB_SHARE_PROPERTY_NAME].value;
@ -1697,7 +1697,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
} }
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
let targetId = properties[FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME].value; let targetId = properties[FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME].value;
let extentId = properties[FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME].value; let extentId = properties[FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME].value;
@ -1763,7 +1763,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
_.get(response, "body.errno") == 14 _.get(response, "body.errno") == 14
) { ) {
retries++; retries++;
this.ctx.logger.debug( callContext.logger.debug(
"target: %s is in use, retry %s shortly", "target: %s is in use, retry %s shortly",
targetId, targetId,
retries retries
@ -1788,7 +1788,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME
); );
} else { } else {
this.ctx.logger.debug( callContext.logger.debug(
"not deleting iscsitarget asset as it appears ID %s has been re-used: zfs name - %s, iscsitarget name - %s", "not deleting iscsitarget asset as it appears ID %s has been re-used: zfs name - %s, iscsitarget name - %s",
targetId, targetId,
iscsiName, iscsiName,
@ -1850,7 +1850,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME
); );
} else { } else {
this.ctx.logger.debug( callContext.logger.debug(
"not deleting iscsiextent asset as it appears ID %s has been re-used: zfs name - %s, iscsiextent name - %s", "not deleting iscsiextent asset as it appears ID %s has been re-used: zfs name - %s, iscsiextent name - %s",
extentId, extentId,
iscsiName, iscsiName,
@ -1875,7 +1875,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
} }
} }
async setFilesystemMode(path, mode) { async setFilesystemMode(callContext, path, mode) {
const httpClient = await this.getHttpClient(); const httpClient = await this.getHttpClient();
const apiVersion = httpClient.getApiVersion(); const apiVersion = httpClient.getApiVersion();
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
@ -1925,7 +1925,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
} }
} }
async setFilesystemOwnership(path, user = false, group = false) { async setFilesystemOwnership(callContext, path, user = false, group = false) {
const httpClient = await this.getHttpClient(); const httpClient = await this.getHttpClient();
const apiVersion = httpClient.getApiVersion(); const apiVersion = httpClient.getApiVersion();
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
@ -2011,7 +2011,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();
@ -2029,7 +2029,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME, FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME,
]); ]);
properties = properties[datasetName]; properties = properties[datasetName];
this.ctx.logger.debug("zfs props data: %j", properties); callContext.logger.debug("zfs props data: %j", properties);
let iscsiName = let iscsiName =
properties[FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME].value; properties[FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME].value;
@ -2063,7 +2063,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
reload = true; reload = true;
break; break;
case 2: case 2:
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS reloading iscsi daemon using api" "FreeNAS reloading iscsi daemon using api"
); );
// POST /service/reload // POST /service/reload
@ -2092,11 +2092,11 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
} }
if (reload) { if (reload) {
if ((await this.getWhoAmI()) != "root") { if ((await this.getWhoAmI(callContext)) != "root") {
command = (await this.getSudoPath()) + " " + command; command = (await this.getSudoPath()) + " " + command;
} }
this.ctx.logger.verbose( callContext.logger.verbose(
"FreeNAS reloading iscsi daemon: %s", "FreeNAS reloading iscsi daemon: %s",
command command
); );

View File

@ -497,14 +497,14 @@ class CsiBaseDriver {
return volume_id; return volume_id;
} }
async GetPluginInfo(call) { async GetPluginInfo(callContext, call) {
return { return {
name: this.ctx.args.csiName, name: this.ctx.args.csiName,
vendor_version: this.ctx.args.version, vendor_version: this.ctx.args.version,
}; };
} }
async GetPluginCapabilities(call) { async GetPluginCapabilities(callContext, call) {
let capabilities; let capabilities;
const response = { const response = {
capabilities: [], capabilities: [],
@ -589,11 +589,11 @@ class CsiBaseDriver {
return response; return response;
} }
async Probe(call) { async Probe(callContext, call) {
return { ready: { value: true } }; return { ready: { value: true } };
} }
async ControllerGetCapabilities(call) { async ControllerGetCapabilities(callContext, call) {
let capabilities; let capabilities;
const response = { const response = {
capabilities: [], capabilities: [],
@ -636,7 +636,7 @@ class CsiBaseDriver {
return response; return response;
} }
async NodeGetCapabilities(call) { async NodeGetCapabilities(callContext, call) {
let capabilities; let capabilities;
const response = { const response = {
capabilities: [], capabilities: [],
@ -661,7 +661,7 @@ class CsiBaseDriver {
return response; return response;
} }
async NodeGetInfo(call) { async NodeGetInfo(callContext, call) {
return { return {
node_id: process.env.CSI_NODE_ID || os.hostname(), node_id: process.env.CSI_NODE_ID || os.hostname(),
max_volumes_per_node: 0, max_volumes_per_node: 0,
@ -678,7 +678,7 @@ class CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async NodeStageVolume(call) { async NodeStageVolume(callContext, call) {
const driver = this; const driver = this;
const mount = driver.getDefaultMountInstance(); const mount = driver.getDefaultMountInstance();
const filesystem = driver.getDefaultFilesystemInstance(); const filesystem = driver.getDefaultFilesystemInstance();
@ -767,7 +767,7 @@ class CsiBaseDriver {
} }
if (call.request.volume_context.provisioner_driver == "node-manual") { if (call.request.volume_context.provisioner_driver == "node-manual") {
result = await this.assertCapabilities([capability], node_attach_driver); result = await this.assertCapabilities(callContext, [capability], node_attach_driver);
if (!result.valid) { if (!result.valid) {
throw new GrpcError( throw new GrpcError(
grpc.status.INVALID_ARGUMENT, grpc.status.INVALID_ARGUMENT,
@ -775,7 +775,7 @@ class CsiBaseDriver {
); );
} }
} else { } else {
result = await this.assertCapabilities([capability]); result = await this.assertCapabilities(callContext, [capability]);
if (!result.valid) { if (!result.valid) {
throw new GrpcError( throw new GrpcError(
grpc.status.INVALID_ARGUMENT, grpc.status.INVALID_ARGUMENT,
@ -944,7 +944,7 @@ class CsiBaseDriver {
let current_time = Math.round(new Date().getTime() / 1000); let current_time = Math.round(new Date().getTime() / 1000);
if (!result && current_time - timer_start > timer_max) { if (!result && current_time - timer_start > timer_max) {
driver.ctx.logger.warn( callContext.logger.warn(
`hit timeout waiting for device node to appear: ${device}` `hit timeout waiting for device node to appear: ${device}`
); );
break; break;
@ -955,7 +955,7 @@ class CsiBaseDriver {
device = await filesystem.realpath(device); device = await filesystem.realpath(device);
iscsiDevices.push(device); iscsiDevices.push(device);
driver.ctx.logger.info( callContext.logger.info(
`successfully logged into portal ${iscsiConnection.portal} and created device ${deviceByPath} with realpath ${device}` `successfully logged into portal ${iscsiConnection.portal} and created device ${deviceByPath} with realpath ${device}`
); );
} }
@ -979,7 +979,7 @@ class CsiBaseDriver {
} }
if (iscsiDevices.length != iscsiConnections.length) { if (iscsiDevices.length != iscsiConnections.length) {
driver.ctx.logger.warn( callContext.logger.warn(
`failed to attach all iscsi devices/targets/portals` `failed to attach all iscsi devices/targets/portals`
); );
@ -1061,7 +1061,7 @@ class CsiBaseDriver {
); );
}); });
} catch (err) { } catch (err) {
driver.ctx.logger.warn( callContext.logger.warn(
`error: ${JSON.stringify(err)} connecting to transport: ${ `error: ${JSON.stringify(err)} connecting to transport: ${
nvmeofConnection.transport nvmeofConnection.transport
}` }`
@ -1085,7 +1085,7 @@ class CsiBaseDriver {
} }
}); });
} catch (err) { } catch (err) {
driver.ctx.logger.warn( callContext.logger.warn(
`error finding nvme controller device: ${JSON.stringify( `error finding nvme controller device: ${JSON.stringify(
err err
)}` )}`
@ -1112,7 +1112,7 @@ class CsiBaseDriver {
} }
}); });
} catch (err) { } catch (err) {
driver.ctx.logger.warn( callContext.logger.warn(
`error finding nvme namespace device: ${JSON.stringify( `error finding nvme namespace device: ${JSON.stringify(
err err
)}` )}`
@ -1146,7 +1146,7 @@ class CsiBaseDriver {
let current_time = Math.round(new Date().getTime() / 1000); let current_time = Math.round(new Date().getTime() / 1000);
if (!result && current_time - timer_start > timer_max) { if (!result && current_time - timer_start > timer_max) {
driver.ctx.logger.warn( callContext.logger.warn(
`hit timeout waiting for namespace device node to appear: ${namespaceDevice}` `hit timeout waiting for namespace device node to appear: ${namespaceDevice}`
); );
break; break;
@ -1158,7 +1158,7 @@ class CsiBaseDriver {
nvmeofControllerDevices.push(controllerDevice); nvmeofControllerDevices.push(controllerDevice);
nvmeofNamespaceDevices.push(namespaceDevice); nvmeofNamespaceDevices.push(namespaceDevice);
driver.ctx.logger.info( callContext.logger.info(
`successfully logged into nvmeof transport ${nvmeofConnection.transport} and created controller device: ${controllerDevice}, namespace device: ${namespaceDevice}` `successfully logged into nvmeof transport ${nvmeofConnection.transport} and created controller device: ${controllerDevice}, namespace device: ${namespaceDevice}`
); );
} }
@ -1190,7 +1190,7 @@ class CsiBaseDriver {
} }
if (nvmeofControllerDevices.length != nvmeofConnections.length) { if (nvmeofControllerDevices.length != nvmeofConnections.length) {
driver.ctx.logger.warn( callContext.logger.warn(
`failed to attach all nvmeof devices/subsystems/transports` `failed to attach all nvmeof devices/subsystems/transports`
); );
@ -1452,7 +1452,7 @@ class CsiBaseDriver {
// data partion MUST be the last partition on the drive // data partion MUST be the last partition on the drive
// to properly support expand/resize operations // to properly support expand/resize operations
device = await filesystem.getBlockDeviceLastPartition(device); device = await filesystem.getBlockDeviceLastPartition(device);
driver.ctx.logger.debug( callContext.logger.debug(
`device has partitions, mount device is: ${device}` `device has partitions, mount device is: ${device}`
); );
@ -1623,7 +1623,7 @@ class CsiBaseDriver {
err.stdout.includes("find valid filesystem superblock") && err.stdout.includes("find valid filesystem superblock") &&
err.stderr.includes("checksum does not match superblock") err.stderr.includes("checksum does not match superblock")
) { ) {
driver.ctx.logger.warn( callContext.logger.warn(
`successful mount, unsuccessful fs resize: attempting abnormal umount/mount/resize2fs to clear things up ${staging_target_path} (${device})` `successful mount, unsuccessful fs resize: attempting abnormal umount/mount/resize2fs to clear things up ${staging_target_path} (${device})`
); );
@ -1846,7 +1846,7 @@ class CsiBaseDriver {
target_port target_port
); );
} catch (e) { } catch (e) {
driver.ctx.logger.warn( callContext.logger.warn(
`failed adding target portal: ${JSON.stringify( `failed adding target portal: ${JSON.stringify(
iscsiConnection iscsiConnection
)}: ${e.stderr}` )}: ${e.stderr}`
@ -1927,7 +1927,7 @@ class CsiBaseDriver {
"The target has already been logged in via an iSCSI session" "The target has already been logged in via an iSCSI session"
) )
) { ) {
driver.ctx.logger.warn( callContext.logger.warn(
`failed connection to ${JSON.stringify( `failed connection to ${JSON.stringify(
iscsiConnection iscsiConnection
)}: ${e.stderr}` )}: ${e.stderr}`
@ -1946,7 +1946,7 @@ class CsiBaseDriver {
} }
if (iscsiConnections.length != successful_logins) { if (iscsiConnections.length != successful_logins) {
driver.ctx.logger.warn( callContext.logger.warn(
`failed to login to all portals: total - ${iscsiConnections.length}, logins - ${successful_logins}` `failed to login to all portals: total - ${iscsiConnections.length}, logins - ${successful_logins}`
); );
} }
@ -2437,7 +2437,7 @@ class CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async NodeUnstageVolume(call) { async NodeUnstageVolume(callContext, call) {
const driver = this; const driver = this;
const mount = driver.getDefaultMountInstance(); const mount = driver.getDefaultMountInstance();
const filesystem = driver.getDefaultFilesystemInstance(); const filesystem = driver.getDefaultFilesystemInstance();
@ -2481,7 +2481,7 @@ class CsiBaseDriver {
* AND the fs is probably stalled * AND the fs is probably stalled
*/ */
if (err.timeout) { if (err.timeout) {
driver.ctx.logger.warn( callContext.logger.warn(
`detected stale mount, attempting to force unmount: ${normalized_staging_path}` `detected stale mount, attempting to force unmount: ${normalized_staging_path}`
); );
await mount.umount( await mount.umount(
@ -2531,14 +2531,14 @@ class CsiBaseDriver {
); );
} catch (err) { } catch (err) {
if (err.timeout) { if (err.timeout) {
driver.ctx.logger.warn( callContext.logger.warn(
`hit timeout waiting to unmount path: ${normalized_staging_path}` `hit timeout waiting to unmount path: ${normalized_staging_path}`
); );
result = await mount.getMountDetails(normalized_staging_path); result = await mount.getMountDetails(normalized_staging_path);
switch (result.fstype) { switch (result.fstype) {
case "nfs": case "nfs":
case "nfs4": case "nfs4":
driver.ctx.logger.warn( callContext.logger.warn(
`detected stale nfs filesystem, attempting to force unmount: ${normalized_staging_path}` `detected stale nfs filesystem, attempting to force unmount: ${normalized_staging_path}`
); );
result = await mount.umount( result = await mount.umount(
@ -2969,7 +2969,7 @@ class CsiBaseDriver {
return {}; return {};
} }
async NodePublishVolume(call) { async NodePublishVolume(callContext, call) {
const driver = this; const driver = this;
const mount = driver.getDefaultMountInstance(); const mount = driver.getDefaultMountInstance();
const filesystem = driver.getDefaultFilesystemInstance(); const filesystem = driver.getDefaultFilesystemInstance();
@ -3290,7 +3290,7 @@ class CsiBaseDriver {
} }
} }
async NodeUnpublishVolume(call) { async NodeUnpublishVolume(callContext, call) {
const driver = this; const driver = this;
const mount = driver.getDefaultMountInstance(); const mount = driver.getDefaultMountInstance();
const filesystem = driver.getDefaultFilesystemInstance(); const filesystem = driver.getDefaultFilesystemInstance();
@ -3316,7 +3316,7 @@ class CsiBaseDriver {
// the only time this should timeout is on a stale fs // the only time this should timeout is on a stale fs
// so if timeout is hit we should be near certain it is indeed mounted // so if timeout is hit we should be near certain it is indeed mounted
if (err.timeout) { if (err.timeout) {
driver.ctx.logger.warn( callContext.logger.warn(
`detected stale mount, attempting to force unmount: ${target_path}` `detected stale mount, attempting to force unmount: ${target_path}`
); );
await mount.umount( await mount.umount(
@ -3348,7 +3348,7 @@ class CsiBaseDriver {
); );
} catch (err) { } catch (err) {
if (err.timeout) { if (err.timeout) {
driver.ctx.logger.warn( callContext.logger.warn(
`hit timeout waiting to unmount path: ${target_path}` `hit timeout waiting to unmount path: ${target_path}`
); );
// bind mounts do show the 'real' fs details // bind mounts do show the 'real' fs details
@ -3356,7 +3356,7 @@ class CsiBaseDriver {
switch (result.fstype) { switch (result.fstype) {
case "nfs": case "nfs":
case "nfs4": case "nfs4":
driver.ctx.logger.warn( callContext.logger.warn(
`detected stale nfs filesystem, attempting to force unmount: ${target_path}` `detected stale nfs filesystem, attempting to force unmount: ${target_path}`
); );
result = await mount.umount( result = await mount.umount(
@ -3458,7 +3458,7 @@ class CsiBaseDriver {
return {}; return {};
} }
async NodeGetVolumeStats(call) { async NodeGetVolumeStats(callContext, call) {
const driver = this; const driver = this;
const mount = driver.getDefaultMountInstance(); const mount = driver.getDefaultMountInstance();
const filesystem = driver.getDefaultFilesystemInstance(); const filesystem = driver.getDefaultFilesystemInstance();
@ -3536,7 +3536,7 @@ class CsiBaseDriver {
}); });
} }
} catch (err) { } catch (err) {
driver.ctx.logger.debug("failed to retrieve inode info", err); callContext.logger.debug("failed to retrieve inode info", err);
} }
break; break;
case "block": case "block":
@ -3692,7 +3692,7 @@ class CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async NodeExpandVolume(call) { async NodeExpandVolume(callContext, call) {
const driver = this; const driver = this;
const mount = driver.getDefaultMountInstance(); const mount = driver.getDefaultMountInstance();
const filesystem = driver.getDefaultFilesystemInstance(); const filesystem = driver.getDefaultFilesystemInstance();
@ -3954,7 +3954,7 @@ class CsiBaseDriver {
* TODO: possibly change this to a percentage instead of absolute numbers * TODO: possibly change this to a percentage instead of absolute numbers
*/ */
let max_delta = 104857600; let max_delta = 104857600;
driver.ctx.logger.debug( callContext.logger.debug(
"resize diff %s (%s%%)", "resize diff %s (%s%%)",
diff, diff,
percentage_diff percentage_diff

View File

@ -100,7 +100,7 @@ class NodeManualDriver extends CsiBaseDriver {
} }
} }
assertCapabilities(capabilities, node_attach_driver) { assertCapabilities(callContext, capabilities, node_attach_driver) {
this.ctx.logger.verbose("validating capabilities: %j", capabilities); this.ctx.logger.verbose("validating capabilities: %j", capabilities);
let message = null; let message = null;
@ -242,7 +242,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateVolume(call) { async CreateVolume(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -253,7 +253,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteVolume(call) { async DeleteVolume(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -264,7 +264,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ControllerExpandVolume(call) { async ControllerExpandVolume(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -275,7 +275,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async GetCapacity(call) { async GetCapacity(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -286,7 +286,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListVolumes(call) { async ListVolumes(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -297,7 +297,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ListSnapshots(call) { async ListSnapshots(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -308,7 +308,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async CreateSnapshot(call) { async CreateSnapshot(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -319,7 +319,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async DeleteSnapshot(call) { async DeleteSnapshot(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`
@ -330,7 +330,7 @@ class NodeManualDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ValidateVolumeCapabilities(call) { async ValidateVolumeCapabilities(callContext, call) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNIMPLEMENTED, grpc.status.UNIMPLEMENTED,
`operation not supported by driver` `operation not supported by driver`

View File

@ -165,10 +165,10 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
return datasetParentName; return datasetParentName;
} }
assertCapabilities(capabilities) { assertCapabilities(callContext, capabilities) {
// hard code this for now // hard code this for now
const driverZfsResourceType = "filesystem"; const driverZfsResourceType = "filesystem";
this.ctx.logger.verbose("validating capabilities: %j", capabilities); callContext.logger.verbose("validating capabilities: %j", capabilities);
let message = null; let message = null;
//[{"access_mode":{"mode":"SINGLE_NODE_WRITER"},"mount":{"mount_flags":["noatime","_netdev"],"fs_type":"nfs"},"access_type":"mount"}] //[{"access_mode":{"mode":"SINGLE_NODE_WRITER"},"mount":{"mount_flags":["noatime","_netdev"],"fs_type":"nfs"},"access_type":"mount"}]
@ -272,7 +272,7 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async NodePublishVolume(call) { async NodePublishVolume(callContext, call) {
const driver = this; const driver = this;
const zb = this.getZetabyte(); const zb = this.getZetabyte();
@ -309,7 +309,7 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
} }
if (capability) { if (capability) {
const result = this.assertCapabilities([capability]); const result = this.assertCapabilities(callContext, [capability]);
if (result.valid !== true) { if (result.valid !== true) {
throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message); throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message);
@ -386,7 +386,7 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async NodeUnpublishVolume(call) { async NodeUnpublishVolume(callContext, call) {
const zb = this.getZetabyte(); const zb = this.getZetabyte();
const filesystem = new Filesystem(); const filesystem = new Filesystem();
let result; let result;
@ -454,7 +454,7 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async GetCapacity(call) { async GetCapacity(callContext, call) {
const driver = this; const driver = this;
const zb = this.getZetabyte(); const zb = this.getZetabyte();
@ -468,7 +468,7 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
} }
if (call.request.volume_capabilities) { if (call.request.volume_capabilities) {
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { available_capacity: 0 }; return { available_capacity: 0 };
@ -488,9 +488,9 @@ class ZfsLocalEphemeralInlineDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async ValidateVolumeCapabilities(call) { async ValidateVolumeCapabilities(callContext, call) {
const driver = this; const driver = this;
const result = this.assertCapabilities(call.request.volume_capabilities); const result = this.assertCapabilities(callContext, call.request.volume_capabilities);
if (result.valid !== true) { if (result.valid !== true) {
return { message: result.message }; return { message: result.message };

View File

@ -92,6 +92,49 @@ function lockKeysFromRequest(call, serviceMethodName) {
} }
} }
function loggerIdFromRequest(call, serviceMethodName) {
switch (serviceMethodName) {
// controller
case "CreateVolume":
return call.request.name;
case "DeleteVolume":
case "ControllerExpandVolume":
case "ControllerPublishVolume":
case "ControllerUnpublishVolume":
case "ValidateVolumeCapabilities":
case "ControllerGetVolume":
case "ControllerModifyVolume":
return call.request.volume_id;
case "CreateSnapshot":
return call.request.source_volume_id;
case "DeleteSnapshot":
return call.request.snapshot_id;
case "ListVolumes":
case "GetCapacity":
case "ControllerGetCapabilities":
case "ListSnapshots":
return '';
// node
case "NodeStageVolume":
case "NodeUnstageVolume":
case "NodePublishVolume":
case "NodeUnpublishVolume":
case "NodeGetVolumeStats":
case "NodeExpandVolume":
return call.request.volume_id;
case "NodeGetCapabilities":
case "NodeGetInfo":
case "GetPluginInfo":
case "GetPluginCapabilities":
case "Probe":
return '';
default:
throw `loggerIdFromRequest: unknown method: ${serviceMethodName}`;
}
}
function getLargestNumber() { function getLargestNumber() {
let number; let number;
for (let i = 0; i < arguments.length; i++) { for (let i = 0; i < arguments.length; i++) {
@ -278,6 +321,7 @@ module.exports.crc32 = crc32;
module.exports.crc16 = crc16; module.exports.crc16 = crc16;
module.exports.crc8 = crc8; module.exports.crc8 = crc8;
module.exports.lockKeysFromRequest = lockKeysFromRequest; module.exports.lockKeysFromRequest = lockKeysFromRequest;
module.exports.loggerIdFromRequest = loggerIdFromRequest;
module.exports.getLargestNumber = getLargestNumber; module.exports.getLargestNumber = getLargestNumber;
module.exports.stringify = stringify; module.exports.stringify = stringify;
module.exports.before_string = before_string; module.exports.before_string = before_string;