Merge pull request #30 from democratic-csi/next

Next
This commit is contained in:
Travis Glenn Hansen 2020-12-10 21:17:20 -07:00 committed by GitHub
commit 9156b65b07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1563 additions and 13 deletions

View File

@ -5,3 +5,4 @@ contrib
node_modules node_modules
Dockerfile* Dockerfile*
TODO.md TODO.md
.git

View File

@ -32,7 +32,7 @@ const args = require("yargs")
}) })
.option("csi-version", { .option("csi-version", {
describe: "versin of the csi spec to load", describe: "versin of the csi spec to load",
choices: ["0.2.0", "0.3.0", "1.0.0", "1.1.0", "1.2.0"], choices: ["0.2.0", "0.3.0", "1.0.0", "1.1.0", "1.2.0", "1.3.0"],
}) })
.demandOption(["csi-version"], "csi-version is required") .demandOption(["csi-version"], "csi-version is required")
.option("csi-name", { .option("csi-name", {
@ -78,7 +78,7 @@ const { logger } = require("../src/utils/logger");
if (args.logLevel) { if (args.logLevel) {
logger.level = args.logLevel; logger.level = args.logLevel;
} }
const csiVersion = process.env.CSI_VERSION || "1.1.0"; const csiVersion = process.env.CSI_VERSION || "1.2.0";
const PROTO_PATH = __dirname + "/../csi_proto/csi-v" + csiVersion + ".proto"; const PROTO_PATH = __dirname + "/../csi_proto/csi-v" + csiVersion + ".proto";
// Suggested options for similarity to existing grpc.load behavior // Suggested options for similarity to existing grpc.load behavior

1502
csi_proto/csi-v1.3.0.proto Normal file

File diff suppressed because it is too large Load Diff

View File

@ -49,6 +49,8 @@ zfs:
# standard volume naming overhead is 46 chars # standard volume naming overhead is 46 chars
# datasetParentName should therefore be 17 chars or less # datasetParentName should therefore be 17 chars or less
datasetParentName: tank/k8s/b/vols datasetParentName: tank/k8s/b/vols
# do NOT make datasetParentName and detachedSnapshotsDatasetParentName overlap
# they may be siblings, but neither should be nested in the other
detachedSnapshotsDatasetParentName: tanks/k8s/b/snaps detachedSnapshotsDatasetParentName: tanks/k8s/b/snaps
# "" (inherit), lz4, gzip-9, etc # "" (inherit), lz4, gzip-9, etc
zvolCompression: zvolCompression:

View File

@ -45,6 +45,8 @@ zfs:
# "org.freenas:test2": "some value" # "org.freenas:test2": "some value"
datasetParentName: tank/k8s/a/vols datasetParentName: tank/k8s/a/vols
# do NOT make datasetParentName and detachedSnapshotsDatasetParentName overlap
# they may be siblings, but neither should be nested in the other
detachedSnapshotsDatasetParentName: tank/k8s/a/snaps detachedSnapshotsDatasetParentName: tank/k8s/a/snaps
datasetEnableQuotas: true datasetEnableQuotas: true
datasetEnableReservation: false datasetEnableReservation: false

View File

@ -49,6 +49,8 @@ zfs:
casesensitivity: mixed casesensitivity: mixed
datasetParentName: tank/k8s/a/vols datasetParentName: tank/k8s/a/vols
# do NOT make datasetParentName and detachedSnapshotsDatasetParentName overlap
# they may be siblings, but neither should be nested in the other
detachedSnapshotsDatasetParentName: tank/k8s/a/snaps detachedSnapshotsDatasetParentName: tank/k8s/a/snaps
datasetEnableQuotas: true datasetEnableQuotas: true
datasetEnableReservation: false datasetEnableReservation: false

View File

@ -32,6 +32,8 @@ zfs:
# "org.freenas:test2": "some value" # "org.freenas:test2": "some value"
datasetParentName: tank/k8s/test datasetParentName: tank/k8s/test
# do NOT make datasetParentName and detachedSnapshotsDatasetParentName overlap
# they may be siblings, but neither should be nested in the other
detachedSnapshotsDatasetParentName: tanks/k8s/test-snapshots detachedSnapshotsDatasetParentName: tanks/k8s/test-snapshots
# "" (inherit), lz4, gzip-9, etc # "" (inherit), lz4, gzip-9, etc

View File

@ -32,6 +32,8 @@ zfs:
# "org.freenas:test2": "some value" # "org.freenas:test2": "some value"
datasetParentName: tank/k8s/test datasetParentName: tank/k8s/test
# do NOT make datasetParentName and detachedSnapshotsDatasetParentName overlap
# they may be siblings, but neither should be nested in the other
detachedSnapshotsDatasetParentName: tanks/k8s/test-snapshots detachedSnapshotsDatasetParentName: tanks/k8s/test-snapshots
datasetEnableQuotas: true datasetEnableQuotas: true

View File

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

View File

@ -257,6 +257,37 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
return { valid, message }; return { valid, message };
} }
/**
* Ensure sane options are used etc
* true = ready
* false = not ready, but progressiong towards ready
* throw error = faulty setup
*
* @param {*} call
*/
async Probe(call) {
const driver = this;
if (driver.ctx.args.csiMode.includes("controller")) {
let datasetParentName = this.getVolumeParentDatasetName() + "/";
let snapshotParentDatasetName =
this.getDetachedSnapshotParentDatasetName() + "/";
if (
datasetParentName.startsWith(snapshotParentDatasetName) ||
snapshotParentDatasetName.startsWith(datasetParentName)
) {
throw new GrpcError(
grpc.status.FAILED_PRECONDITION,
`datasetParentName and detachedSnapshotsDatasetParentName must not overlap`
);
}
return { ready: { value: true } };
} else {
return { ready: { value: true } };
}
}
/** /**
* Create a volume doing in essence the following: * Create a volume doing in essence the following:
* 1. create dataset * 1. create dataset

View File

@ -15,6 +15,9 @@ const FREENAS_ISCSI_TARGETTOEXTENT_ID_PROPERTY_NAME =
"democratic-csi:freenas_iscsi_targettoextent_id"; "democratic-csi:freenas_iscsi_targettoextent_id";
const FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME = const FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME =
"democratic-csi:freenas_iscsi_assets_name"; "democratic-csi:freenas_iscsi_assets_name";
// used for in-memory cache of the version info
const FREENAS_SYSTEM_VERSION_CACHE_KEY = "freenas:system_version";
class FreeNASDriver extends ControllerZfsSshBaseDriver { class FreeNASDriver extends ControllerZfsSshBaseDriver {
/** /**
* cannot make this a storage class parameter as storage class/etc context is *not* sent * cannot make this a storage class parameter as storage class/etc context is *not* sent
@ -1513,7 +1516,7 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
if (![200, 204].includes(response.statusCode)) { if (![200, 204].includes(response.statusCode)) {
throw new GrpcError( throw new GrpcError(
grpc.status.UNKNOWN, grpc.status.UNKNOWN,
`received error deleting iscsi target - extent: ${targetId} code: ${ `received error deleting iscsi target - target: ${targetId} code: ${
response.statusCode response.statusCode
} body: ${JSON.stringify(response.body)}` } body: ${JSON.stringify(response.body)}`
); );
@ -1756,19 +1759,22 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
async setVersionInfoCache(versionInfo) { async setVersionInfoCache(versionInfo) {
const driver = this; const driver = this;
this.cache = this.cache || {};
this.cache.versionInfo = versionInfo;
// crude timeout await driver.ctx.cache.set(
setTimeout(function () { FREENAS_SYSTEM_VERSION_CACHE_KEY,
driver.cache.versionInfo = null; versionInfo,
}, 60 * 1000); 60 * 1000
);
} }
async getSystemVersion() { async getSystemVersion() {
this.cache = this.cache || {}; const driver = this;
if (this.cache.versionInfo) { let cacheData = await driver.ctx.cache.get(
return this.cache.versionInfo; FREENAS_SYSTEM_VERSION_CACHE_KEY
);
if (cacheData) {
return cacheData;
} }
const httpClient = await this.getHttpClient(false); const httpClient = await this.getHttpClient(false);