diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6a85c..4ba95a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# v1.4.4 + +Release 2021-12-11 + +- better adherence to expected csi behavior when volume request for less than + minimum volume size is requested (see #137) +- avoid unnecessary data copy for `ListVolumes` operation + # v1.4.3 Released 2021-12-01 diff --git a/README.md b/README.md index 94fdaed..23b4417 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,7 @@ Install `democratic-csi` as usual with `volumeSnapshotClasses` defined as approp - https://kubernetes.io/docs/concepts/storage/volume-snapshots/ - https://github.com/kubernetes-csi/external-snapshotter#usage +- https://github.com/democratic-csi/democratic-csi/issues/129#issuecomment-961489810 # Migrating from freenas-provisioner and freenas-iscsi-provisioner diff --git a/ci/bin/launch-server.sh b/ci/bin/launch-server.sh index 52753c3..93274a5 100755 --- a/ci/bin/launch-server.sh +++ b/ci/bin/launch-server.sh @@ -23,4 +23,4 @@ if [[ "x${CSI_MODE}" != "x" ]];then fi # > "${LOG_PATH}" 2>&1 -./bin/democratic-csi --log-level debug --driver-config-file "${CONFIG_FILE}" --csi-version "${CSI_VERSION}" --csi-name "driver-test" --server-socket "${CSI_ENDPOINT}" ${EXTRA_ARGS} +exec ./bin/democratic-csi --log-level debug --driver-config-file "${CONFIG_FILE}" --csi-version "${CSI_VERSION}" --csi-name "driver-test" --server-socket "${CSI_ENDPOINT}" ${EXTRA_ARGS} diff --git a/ci/bin/run.sh b/ci/bin/run.sh index b951a99..c6eedb0 100755 --- a/ci/bin/run.sh +++ b/ci/bin/run.sh @@ -3,6 +3,14 @@ set -e set -x +_term() { + # no idea why this does not work + #[[ -n "${SUDO_PID}" ]] && sudo kill -15 "${SUDO_PID}" + [[ -n "${SUDO_PID}" ]] && sudo kill -15 $(pgrep -P "${SUDO_PID}") || true +} + +trap _term EXIT + export PATH="/usr/local/lib/nodejs/bin:${PATH}" # install deps npm i @@ -12,6 +20,7 @@ export CI_BUILD_KEY=$(uuidgen | cut -d "-" -f 1) # launch the server sudo -E ci/bin/launch-server.sh & +SUDO_PID=$! # wait for server to launch sleep 10 diff --git a/docs/Nomad/examples/volume-iscsi.hcl b/docs/Nomad/examples/volume-iscsi.hcl index 6a25c0c..ac9a9ce 100644 --- a/docs/Nomad/examples/volume-iscsi.hcl +++ b/docs/Nomad/examples/volume-iscsi.hcl @@ -9,3 +9,10 @@ capability { access_mode = "single-node-writer" attachment_mode = "file-system" } + +mount_options { + # ext4|xfs + # default is ext4 when left unset + #fs_type = "ext4" + #mount_flags = ["noatime"] +} diff --git a/docs/Nomad/examples/volume-nfs.hcl b/docs/Nomad/examples/volume-nfs.hcl index 6e54674..21d01b9 100644 --- a/docs/Nomad/examples/volume-nfs.hcl +++ b/docs/Nomad/examples/volume-nfs.hcl @@ -9,3 +9,7 @@ capability { access_mode = "multi-node-multi-writer" attachment_mode = "file-system" } + +mount_options { + mount_flags = ["noatime", "nfsvers=3"] +} diff --git a/package-lock.json b/package-lock.json index 9581c80..8a80094 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,14 +43,14 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.4.tgz", - "integrity": "sha512-h8Vx6MdxwWI2WM8/zREHMoqdgLNXEL4QX3MWSVMdyNJGvXVOs+6lp+m2hc3FnuMHDc4poxFNI20vCk0OmI4G0Q==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz", + "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.0.0", + "espree": "^9.2.0", "globals": "^13.9.0", "ignore": "^4.0.6", "import-fresh": "^3.2.1", @@ -118,12 +118,12 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", - "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz", + "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.0", + "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", "minimatch": "^3.0.4" }, @@ -303,9 +303,9 @@ } }, "node_modules/@types/node": { - "version": "16.11.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", - "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==" + "version": "16.11.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", + "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==" }, "node_modules/@types/request": { "version": "2.48.7", @@ -683,6 +683,14 @@ "mimic-response": "^1.0.0" } }, + "node_modules/code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/color": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", @@ -709,9 +717,9 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "node_modules/color-string": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.8.2.tgz", - "integrity": "sha512-w5ZkKRdLsc5NOYsmnpS2DpyRW71npwZGwbRpLrJTuqjfTs2Bhrba7UiV59IX9siBlCPl2pne5NtiwnVWUzvYFA==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.0.tgz", + "integrity": "sha512-9Mrz2AQLefkH1UvASKj6v6hj/7eWgjnT/cVsR8CumieLoT+g900exWeNogqtweI8dxloXN9BDQTYro1oWu/5CQ==", "dependencies": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" @@ -978,13 +986,13 @@ } }, "node_modules/eslint": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.3.0.tgz", - "integrity": "sha512-aIay56Ph6RxOTC7xyr59Kt3ewX185SaGnAr8eWukoPLeriCrvGjvAubxuvaXOfsxhtwV5g0uBOsyhAom4qJdww==", + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.1.tgz", + "integrity": "sha512-TxU/p7LB1KxQ6+7aztTnO7K0i+h0tDi81YRY9VzB6Id71kNz+fFYnf5HD5UOQmxkzcoa0TlVZf9dpMtUv0GpWg==", "dev": true, "dependencies": { - "@eslint/eslintrc": "^1.0.4", - "@humanwhocodes/config-array": "^0.6.0", + "@eslint/eslintrc": "^1.0.5", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -995,7 +1003,7 @@ "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.1.0", - "espree": "^9.1.0", + "espree": "^9.2.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -1082,9 +1090,9 @@ } }, "node_modules/espree": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.1.0.tgz", - "integrity": "sha512-ZgYLvCS1wxOczBYGcQT9DDWgicXwJ4dbocr9uYN+/eresBAUuBu+O4WzB21ufQ/JqQT8gyp7hJ3z8SHii32mTQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.2.0.tgz", + "integrity": "sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg==", "dev": true, "dependencies": { "acorn": "^8.6.0", @@ -2501,9 +2509,9 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "node_modules/minipass": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.5.tgz", - "integrity": "sha512-+8NzxD82XQoNKNrl1d/FSi+X8wAEWR+sbYAfIvub4Nz0d22plFG72CEVVaufV8PNf4qSslFTD8VMOxNVhHCjTw==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz", + "integrity": "sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==", "dependencies": { "yallist": "^4.0.0" }, @@ -2643,6 +2651,14 @@ "node": ">=8" } }, + "node_modules/number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -3694,14 +3710,14 @@ } }, "@eslint/eslintrc": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.4.tgz", - "integrity": "sha512-h8Vx6MdxwWI2WM8/zREHMoqdgLNXEL4QX3MWSVMdyNJGvXVOs+6lp+m2hc3FnuMHDc4poxFNI20vCk0OmI4G0Q==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz", + "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.0.0", + "espree": "^9.2.0", "globals": "^13.9.0", "ignore": "^4.0.6", "import-fresh": "^3.2.1", @@ -3753,12 +3769,12 @@ } }, "@humanwhocodes/config-array": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", - "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz", + "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^1.2.0", + "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", "minimatch": "^3.0.4" } @@ -3925,9 +3941,9 @@ } }, "@types/node": { - "version": "16.11.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", - "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==" + "version": "16.11.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", + "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==" }, "@types/request": { "version": "2.48.7", @@ -4233,6 +4249,10 @@ "mimic-response": "^1.0.0" } }, + "code-point-at": { + "version": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, "color": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", @@ -4271,9 +4291,9 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "color-string": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.8.2.tgz", - "integrity": "sha512-w5ZkKRdLsc5NOYsmnpS2DpyRW71npwZGwbRpLrJTuqjfTs2Bhrba7UiV59IX9siBlCPl2pne5NtiwnVWUzvYFA==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.0.tgz", + "integrity": "sha512-9Mrz2AQLefkH1UvASKj6v6hj/7eWgjnT/cVsR8CumieLoT+g900exWeNogqtweI8dxloXN9BDQTYro1oWu/5CQ==", "requires": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" @@ -4459,13 +4479,13 @@ "dev": true }, "eslint": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.3.0.tgz", - "integrity": "sha512-aIay56Ph6RxOTC7xyr59Kt3ewX185SaGnAr8eWukoPLeriCrvGjvAubxuvaXOfsxhtwV5g0uBOsyhAom4qJdww==", + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.1.tgz", + "integrity": "sha512-TxU/p7LB1KxQ6+7aztTnO7K0i+h0tDi81YRY9VzB6Id71kNz+fFYnf5HD5UOQmxkzcoa0TlVZf9dpMtUv0GpWg==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.0.4", - "@humanwhocodes/config-array": "^0.6.0", + "@eslint/eslintrc": "^1.0.5", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -4476,7 +4496,7 @@ "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.1.0", - "espree": "^9.1.0", + "espree": "^9.2.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -4538,9 +4558,9 @@ "dev": true }, "espree": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.1.0.tgz", - "integrity": "sha512-ZgYLvCS1wxOczBYGcQT9DDWgicXwJ4dbocr9uYN+/eresBAUuBu+O4WzB21ufQ/JqQT8gyp7hJ3z8SHii32mTQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.2.0.tgz", + "integrity": "sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg==", "dev": true, "requires": { "acorn": "^8.6.0", @@ -5610,9 +5630,9 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "minipass": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.5.tgz", - "integrity": "sha512-+8NzxD82XQoNKNrl1d/FSi+X8wAEWR+sbYAfIvub4Nz0d22plFG72CEVVaufV8PNf4qSslFTD8VMOxNVhHCjTw==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz", + "integrity": "sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==", "requires": { "yallist": "^4.0.0" } @@ -5721,6 +5741,10 @@ "path-key": "^3.0.0" } }, + "number-is-nan": { + "version": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", diff --git a/src/driver/controller-zfs-ssh/index.js b/src/driver/controller-zfs-ssh/index.js index 7764887..2ce1a1e 100644 --- a/src/driver/controller-zfs-ssh/index.js +++ b/src/driver/controller-zfs-ssh/index.js @@ -571,6 +571,7 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { ); } + // if no capacity_range specified set a required_bytes at least if ( !call.request.capacity_range || Object.keys(call.request.capacity_range).length === 0 @@ -592,15 +593,18 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { ); } - /** - * NOTE: avoid the urge to templatize this given the name length limits for zvols - * ie: namespace-name may quite easily exceed 58 chars - */ - const datasetName = datasetParentName + "/" + name; let capacity_bytes = call.request.capacity_range.required_bytes || call.request.capacity_range.limit_bytes; + if (!capacity_bytes) { + //should never happen, value must be set + throw new GrpcError( + grpc.status.INVALID_ARGUMENT, + `volume capacity is required (either required_bytes or limit_bytes)` + ); + } + if (capacity_bytes && driverZfsResourceType == "volume") { //make sure to align capacity_bytes with zvol blocksize //volume size must be a multiple of volume block size @@ -609,13 +613,6 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { zvolBlocksize ); } - if (!capacity_bytes) { - //should never happen, value must be set - throw new GrpcError( - grpc.status.INVALID_ARGUMENT, - `volume capacity is required (either required_bytes or limit_bytes)` - ); - } // ensure *actual* capacity is not greater than limit if ( @@ -629,6 +626,12 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { ); } + /** + * NOTE: avoid the urge to templatize this given the name length limits for zvols + * ie: namespace-name may quite easily exceed 58 chars + */ + const datasetName = datasetParentName + "/" + name; + // ensure volumes with the same name being requested a 2nd time but with a different size fails try { let properties = await zb.zfs.get(datasetName, ["volsize", "refquota"]); @@ -1706,7 +1709,6 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { } entries = this.ctx.cache.get(`ListSnapshots:result:${uuid}`); if (entries) { - entries = JSON.parse(JSON.stringify(entries)); entries_length = entries.length; entries = entries.slice(start_position, end_position); if (max_entries > 0 && end_position > entries_length) { @@ -1914,10 +1916,7 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { if (max_entries && entries.length > max_entries) { uuid = uuidv4(); - this.ctx.cache.set( - `ListSnapshots:result:${uuid}`, - JSON.parse(JSON.stringify(entries)) - ); + this.ctx.cache.set(`ListSnapshots:result:${uuid}`, entries); next_token = `${uuid}:${max_entries}`; entries = entries.slice(0, max_entries); } diff --git a/src/driver/freenas/api.js b/src/driver/freenas/api.js index 12431b0..eb16c55 100644 --- a/src/driver/freenas/api.js +++ b/src/driver/freenas/api.js @@ -2044,6 +2044,7 @@ class FreeNASApiDriver extends CsiBaseDriver { ); } + // if no capacity_range specified set a required_bytes at least if ( !call.request.capacity_range || Object.keys(call.request.capacity_range).length === 0 @@ -2065,23 +2066,10 @@ class FreeNASApiDriver extends CsiBaseDriver { ); } - /** - * NOTE: avoid the urge to templatize this given the name length limits for zvols - * ie: namespace-name may quite easily exceed 58 chars - */ - const datasetName = datasetParentName + "/" + name; let capacity_bytes = call.request.capacity_range.required_bytes || call.request.capacity_range.limit_bytes; - if (capacity_bytes && driverZfsResourceType == "volume") { - //make sure to align capacity_bytes with zvol blocksize - //volume size must be a multiple of volume block size - capacity_bytes = zb.helpers.generateZvolSize( - capacity_bytes, - zvolBlocksize - ); - } if (!capacity_bytes) { //should never happen, value must be set throw new GrpcError( @@ -2091,10 +2079,24 @@ class FreeNASApiDriver extends CsiBaseDriver { } // ensure *actual* capacity is not too small - if (minimum_volume_size > 0 && capacity_bytes < minimum_volume_size) { - throw new GrpcError( - grpc.status.OUT_OF_RANGE, - `volume capacity is smaller than the minimum: ${minimum_volume_size}` + if ( + capacity_bytes > 0 && + minimum_volume_size > 0 && + capacity_bytes < minimum_volume_size + ) { + //throw new GrpcError( + // grpc.status.OUT_OF_RANGE, + // `volume capacity is smaller than the minimum: ${minimum_volume_size}` + //); + capacity_bytes = minimum_volume_size; + } + + if (capacity_bytes && driverZfsResourceType == "volume") { + //make sure to align capacity_bytes with zvol blocksize + //volume size must be a multiple of volume block size + capacity_bytes = zb.helpers.generateZvolSize( + capacity_bytes, + zvolBlocksize ); } @@ -2110,6 +2112,12 @@ class FreeNASApiDriver extends CsiBaseDriver { ); } + /** + * NOTE: avoid the urge to templatize this given the name length limits for zvols + * ie: namespace-name may quite easily exceed 58 chars + */ + const datasetName = datasetParentName + "/" + name; + // ensure volumes with the same name being requested a 2nd time but with a different size fails try { let properties = await httpApiClient.DatasetGet(datasetName, [ @@ -3263,7 +3271,6 @@ class FreeNASApiDriver extends CsiBaseDriver { } entries = this.ctx.cache.get(`ListSnapshots:result:${uuid}`); if (entries) { - entries = JSON.parse(JSON.stringify(entries)); entries_length = entries.length; entries = entries.slice(start_position, end_position); if (max_entries > 0 && end_position > entries_length) { @@ -3629,10 +3636,7 @@ class FreeNASApiDriver extends CsiBaseDriver { if (max_entries && entries.length > max_entries) { uuid = uuidv4(); - this.ctx.cache.set( - `ListSnapshots:result:${uuid}`, - JSON.parse(JSON.stringify(entries)) - ); + this.ctx.cache.set(`ListSnapshots:result:${uuid}`, entries); next_token = `${uuid}:${max_entries}`; entries = entries.slice(0, max_entries); } @@ -3992,6 +3996,7 @@ class FreeNASApiDriver extends CsiBaseDriver { size_bytes = getLargestNumber( properties.referenced.rawvalue, properties.logicalreferenced.rawvalue + // TODO: perhaps include minimum volume size here? ); } else { // get the size of the parent volume