logs: use context logger in freenas drivers

This commit is contained in:
Danil Uzlov 2025-03-24 21:42:05 +00:00
parent 93a6991897
commit 2e29580a64
2 changed files with 79 additions and 79 deletions

View File

@ -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(callContext, datasetName, { await zb.zfs.set(callContext, 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, {
@ -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,
@ -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(capabilities, callContext) {
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(call, callContext) {
const driver = this; const driver = this;
const httpApiClient = await driver.getTrueNASHttpApiClient(); const httpApiClient = await driver.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(call.request.volume_capabilities, callContext);
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 = {
@ -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(
@ -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(call, callContext) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
@ -3254,7 +3254,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
* *
* @param {*} call * @param {*} call
*/ */
async GetCapacity(call) { async GetCapacity(call, callContext) {
const driver = this; const driver = this;
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -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(call.request.volume_capabilities, callContext);
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(call, callContext) {
const driver = this; const driver = this;
const driverZfsResourceType = this.getDriverZfsResourceType(); const driverZfsResourceType = this.getDriverZfsResourceType();
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
@ -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(call, callContext) {
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(call, callContext) {
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(call, callContext) {
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(call, callContext) {
const driver = this; const driver = this;
const httpApiClient = await this.getTrueNASHttpApiClient(); const httpApiClient = await this.getTrueNASHttpApiClient();
const zb = await this.getZetabyte(); const zb = await this.getZetabyte();
@ -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(call, callContext) {
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(capabilities, callContext);
if (result.valid !== true) { if (result.valid !== true) {
return { message: result.message }; return { message: result.message };

View File

@ -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;
@ -774,7 +774,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
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
@ -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(callContext, datasetName, { await zb.zfs.set(callContext, 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(callContext, datasetName, { await zb.zfs.set(callContext, 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(callContext, datasetName, { await zb.zfs.set(callContext, 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(callContext, datasetName, { await zb.zfs.set(callContext, 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(callContext, datasetName, { await zb.zfs.set(callContext, datasetName, {
@ -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;
@ -1586,7 +1586,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;
@ -1699,7 +1699,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;
@ -1765,7 +1765,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
@ -1791,7 +1791,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,
@ -1854,7 +1854,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,
@ -2033,7 +2033,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;
@ -2067,7 +2067,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
@ -2100,7 +2100,7 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
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
); );