Merge pull request #70 from democratic-csi/next

Next
This commit is contained in:
Travis Glenn Hansen 2021-04-12 10:16:37 -06:00 committed by GitHub
commit be8f882815
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 71 additions and 2 deletions

View File

@ -1,3 +1,9 @@
# v1.1.1
Released 2021-04-12
- rescan iscsi sessions after login during stage call
# v1.1.0 # v1.1.0
Released 2021-02-21 Released 2021-02-21

View File

@ -40,6 +40,8 @@ Predominantly 3 things are needed:
## Guides ## Guides
- https://jonathangazeley.com/2021/01/05/using-truenas-to-provide-persistent-storage-for-kubernetes/ - https://jonathangazeley.com/2021/01/05/using-truenas-to-provide-persistent-storage-for-kubernetes/
- https://gist.github.com/admun/4372899f20421a947b7544e5fc9f9117 (migrating
from `nfs-client-provisioner` to `democratic-csi`)
## Node Prep ## Node Prep

View File

@ -1,6 +1,6 @@
{ {
"name": "democratic-csi", "name": "democratic-csi",
"version": "1.1.0", "version": "1.1.1",
"description": "kubernetes csi driver framework", "description": "kubernetes csi driver framework",
"main": "bin/democratic-csi", "main": "bin/democratic-csi",
"scripts": { "scripts": {

View File

@ -343,6 +343,7 @@ class CsiBaseDriver {
// put these options in place to force targets managed by csi to be explicitly attached (in the case of unclearn shutdown etc) // put these options in place to force targets managed by csi to be explicitly attached (in the case of unclearn shutdown etc)
let nodeDB = { let nodeDB = {
"node.startup": "manual", "node.startup": "manual",
//"node.session.scan": "manual",
}; };
const nodeDBKeyPrefix = "node-db."; const nodeDBKeyPrefix = "node-db.";
for (const key in normalizedSecrets) { for (const key in normalizedSecrets) {
@ -359,6 +360,15 @@ class CsiBaseDriver {
// login // login
await iscsi.iscsiadm.login(volume_context.iqn, portal); await iscsi.iscsiadm.login(volume_context.iqn, portal);
// get associated session
let session = await iscsi.iscsiadm.getSession(
volume_context.iqn,
portal
);
// rescan in scenarios when login previously occurred but volumes never appeared
await iscsi.iscsiadm.rescanSession(session);
// find device name // find device name
device = `/dev/disk/by-path/ip-${portal}-iscsi-${volume_context.iqn}-lun-${volume_context.lun}`; device = `/dev/disk/by-path/ip-${portal}-iscsi-${volume_context.iqn}-lun-${volume_context.lun}`;
let deviceByPath = device; let deviceByPath = device;

View File

@ -147,6 +147,27 @@ class ISCSI {
await iscsi.exec(options.paths.iscsiadm, args); await iscsi.exec(options.paths.iscsiadm, args);
}, },
/**
* get session object by iqn/portal
*/
async getSession(tgtIQN, portal) {
const sessions = await iscsi.iscsiadm.getSessions();
let session = false;
sessions.every((i_session) => {
if (
`${i_session.iqn}:${i_session.target}` == tgtIQN &&
portal == i_session.portal
) {
session = i_session;
return false;
}
return true;
});
return session;
},
/** /**
* iscsiadm -m session * iscsiadm -m session
*/ */
@ -178,7 +199,7 @@ class ISCSI {
fields = entry.split(" "); fields = entry.split(" ");
sessions.push({ sessions.push({
protocol: entry.split(":")[0], protocol: entry.split(":")[0],
id: fields[1].replace("[", "").replace("]", ""), id: Number(fields[1].replace("[", "").replace("]", "")),
portal: fields[2].split(",")[0], portal: fields[2].split(",")[0],
target_portal_group_tag: fields[2].split(",")[1], target_portal_group_tag: fields[2].split(",")[1],
iqn: fields[3].split(":")[0], iqn: fields[3].split(":")[0],
@ -438,6 +459,36 @@ class ISCSI {
return true; return true;
}, },
/**
* iscsiadm -m session -r SID --rescan
*
* @param {*} session
*/
async rescanSession(session) {
let sid;
if (typeof session === "object") {
sid = session.id;
} else {
sid = session;
}
// make sure session is a valid number
if (session !== 0 && session > 0) {
throw new Error("cannot scan empty session id");
}
let args = [];
args = args.concat(["-m", "session", "-r", sid, "--rescan"]);
try {
await iscsi.exec(options.paths.iscsiadm, args);
} catch (err) {
throw err;
}
return true;
},
}; };
} }