logs: use context logger in node driver

This commit is contained in:
Danil Uzlov 2025-03-24 21:42:05 +00:00
parent 7e78977c83
commit 3ec110a7d9
1 changed files with 22 additions and 22 deletions

View File

@ -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}`
); );
} }
@ -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(
@ -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(
@ -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":
@ -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