From 1cabae4f84f5c8871e3f94a629a4bb9bf5d14c03 Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Sat, 11 Jun 2022 10:24:47 -0600 Subject: [PATCH] SCALE 22.12 support/tests Signed-off-by: Travis Glenn Hansen --- .github/workflows/main.yml | 34 ++++++++++++- README.md | 2 + .../truenas/scale/22.12/scale-iscsi.yaml | 31 ++++++++++++ ci/configs/truenas/scale/22.12/scale-nfs.yaml | 29 +++++++++++ ci/configs/truenas/scale/22.12/scale-smb.yaml | 50 +++++++++++++++++++ package-lock.json | 4 +- package.json | 2 +- src/driver/freenas/api.js | 26 ++++++++-- src/driver/freenas/ssh.js | 27 ++++++++-- 9 files changed, 194 insertions(+), 11 deletions(-) create mode 100644 ci/configs/truenas/scale/22.12/scale-iscsi.yaml create mode 100644 ci/configs/truenas/scale/22.12/scale-nfs.yaml create mode 100644 ci/configs/truenas/scale/22.12/scale-smb.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fafd564..ea7c393 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -146,6 +146,38 @@ jobs: TRUENAS_USERNAME: ${{ secrets.SANITY_TRUENAS_USERNAME }} TRUENAS_PASSWORD: ${{ secrets.SANITY_TRUENAS_PASSWORD }} + csi-sanity-truenas-scale-22_12: + needs: + - build-npm-linux-amd64 + strategy: + fail-fast: false + matrix: + config: + - truenas/scale/22.12/scale-iscsi.yaml + - truenas/scale/22.12/scale-nfs.yaml + # 80 char limit + - truenas/scale/22.12/scale-smb.yaml + runs-on: + - self-hosted + - Linux + - X64 + #- csi-sanity-truenas + - csi-sanity-zfs-generic + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: node-modules-linux-amd64 + - name: csi-sanity + run: | + # run tests + ci/bin/run.sh + env: + TEMPLATE_CONFIG_FILE: "./ci/configs/${{ matrix.config }}" + TRUENAS_HOST: ${{ secrets.SANITY_TRUENAS_SCALE_22_12_HOST }} + TRUENAS_USERNAME: ${{ secrets.SANITY_TRUENAS_USERNAME }} + TRUENAS_PASSWORD: ${{ secrets.SANITY_TRUENAS_PASSWORD }} + # ssh-based drivers csi-sanity-truenas-core-12_0: needs: @@ -302,8 +334,6 @@ jobs: SHARE_NAME: tank_client_smb CSI_SANITY_SKIP: "should fail when requesting to create a snapshot with already existing name and different source volume ID|should fail when requesting to create a volume with already existing name and different capacity" - - # zfs-local drivers csi-sanity-zfs-local: needs: diff --git a/README.md b/README.md index ae5d8db..629a220 100644 --- a/README.md +++ b/README.md @@ -324,6 +324,8 @@ unecessarily: - https://askubuntu.com/questions/318592/how-can-i-remove-the-landscape-canonical-com-greeting-from-motd - https://linuxconfig.org/disable-dynamic-motd-and-news-on-ubuntu-20-04-focal-fossa-linux +- https://github.com/democratic-csi/democratic-csi/issues/151 (some notes on + using delegated zfs permissions) ``` ####### iscsi diff --git a/ci/configs/truenas/scale/22.12/scale-iscsi.yaml b/ci/configs/truenas/scale/22.12/scale-iscsi.yaml new file mode 100644 index 0000000..b6b6f43 --- /dev/null +++ b/ci/configs/truenas/scale/22.12/scale-iscsi.yaml @@ -0,0 +1,31 @@ +driver: freenas-api-iscsi + +httpConnection: + protocol: http + host: ${TRUENAS_HOST} + port: 80 + #apiKey: + username: ${TRUENAS_USERNAME} + password: ${TRUENAS_PASSWORD} + +zfs: + datasetParentName: tank/ci/${CI_BUILD_KEY}/v + detachedSnapshotsDatasetParentName: tank/ci/${CI_BUILD_KEY}/s + + zvolCompression: + zvolDedup: + zvolEnableReservation: false + zvolBlocksize: + +iscsi: + targetPortal: ${TRUENAS_HOST} + interface: "" + namePrefix: "csi-ci-${CI_BUILD_KEY}-" + nameSuffix: "" + targetGroups: + - targetGroupPortalGroup: 1 + targetGroupInitiatorGroup: 1 + targetGroupAuthType: None + targetGroupAuthGroup: + # 0-100 (0 == ignore) + extentAvailThreshold: 0 diff --git a/ci/configs/truenas/scale/22.12/scale-nfs.yaml b/ci/configs/truenas/scale/22.12/scale-nfs.yaml new file mode 100644 index 0000000..42818ae --- /dev/null +++ b/ci/configs/truenas/scale/22.12/scale-nfs.yaml @@ -0,0 +1,29 @@ +driver: freenas-api-nfs + +httpConnection: + protocol: http + host: ${TRUENAS_HOST} + port: 80 + #apiKey: + username: ${TRUENAS_USERNAME} + password: ${TRUENAS_PASSWORD} + +zfs: + datasetParentName: tank/ci/${CI_BUILD_KEY}/v + detachedSnapshotsDatasetParentName: tank/ci/${CI_BUILD_KEY}/s + + datasetEnableQuotas: true + datasetEnableReservation: false + datasetPermissionsMode: "0777" + datasetPermissionsUser: 0 + datasetPermissionsGroup: 0 + +nfs: + shareHost: ${TRUENAS_HOST} + shareAlldirs: false + shareAllowedHosts: [] + shareAllowedNetworks: [] + shareMaprootUser: root + shareMaprootGroup: root + shareMapallUser: "" + shareMapallGroup: "" diff --git a/ci/configs/truenas/scale/22.12/scale-smb.yaml b/ci/configs/truenas/scale/22.12/scale-smb.yaml new file mode 100644 index 0000000..2a8861e --- /dev/null +++ b/ci/configs/truenas/scale/22.12/scale-smb.yaml @@ -0,0 +1,50 @@ +driver: freenas-api-smb + +httpConnection: + protocol: http + host: ${TRUENAS_HOST} + port: 80 + #apiKey: + username: ${TRUENAS_USERNAME} + password: ${TRUENAS_PASSWORD} + +zfs: + datasetParentName: tank/ci/${CI_BUILD_KEY}/v + detachedSnapshotsDatasetParentName: tank/ci/${CI_BUILD_KEY}/s + + datasetEnableQuotas: true + datasetEnableReservation: false + datasetPermissionsMode: "0770" + datasetPermissionsUser: 1001 + datasetPermissionsGroup: 1001 + +smb: + shareHost: ${TRUENAS_HOST} + #nameTemplate: "" + namePrefix: "csi-ci-${CI_BUILD_KEY}-" + nameSuffix: "" + shareAuxiliaryConfigurationTemplate: | + #guest ok = yes + #guest only = yes + shareHome: false + shareAllowedHosts: [] + shareDeniedHosts: [] + #shareDefaultPermissions: true + shareGuestOk: false + #shareGuestOnly: true + #shareShowHiddenFiles: true + shareRecycleBin: false + shareBrowsable: false + shareAccessBasedEnumeration: true + shareTimeMachine: false + #shareStorageTask: + +node: + mount: + mount_flags: "username=smbroot,password=smbroot" + +_private: + csi: + volume: + idHash: + strategy: crc16 diff --git a/package-lock.json b/package-lock.json index a6d0980..64607d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "democratic-csi", - "version": "1.7.0", + "version": "1.7.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "democratic-csi", - "version": "1.7.0", + "version": "1.7.1", "license": "MIT", "dependencies": { "@grpc/grpc-js": "^1.5.7", diff --git a/package.json b/package.json index 4d16cb0..c35ee58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "democratic-csi", - "version": "1.7.0", + "version": "1.7.1", "description": "kubernetes csi driver framework", "main": "bin/democratic-csi", "scripts": { diff --git a/src/driver/freenas/api.js b/src/driver/freenas/api.js index 3dd86aa..0b83d84 100644 --- a/src/driver/freenas/api.js +++ b/src/driver/freenas/api.js @@ -182,6 +182,10 @@ class FreeNASApiDriver extends CsiBaseDriver { const httpApiClient = await this.getTrueNASHttpApiClient(); const apiVersion = httpClient.getApiVersion(); const zb = await this.getZetabyte(); + const truenasVersion = semver.coerce( + await httpApiClient.getSystemVersionMajorMinor() + ); + const isScale = await httpApiClient.getIsScale(); let volume_context; let properties; @@ -261,6 +265,12 @@ class FreeNASApiDriver extends CsiBaseDriver { break; } + if (isScale && semver.satisfies(truenasVersion, ">=22.12")) { + share.path = share.paths[0]; + delete share.paths; + delete share.alldirs; + } + response = await GeneralUtils.retry( 3, 1000, @@ -294,7 +304,11 @@ class FreeNASApiDriver extends CsiBaseDriver { sharePaths = response.body.nfs_paths; break; case 2: - sharePaths = response.body.paths; + if (response.body.path) { + sharePaths = [response.body.path]; + } else { + sharePaths = response.body.paths; + } break; } @@ -336,7 +350,9 @@ class FreeNASApiDriver extends CsiBaseDriver { properties.mountpoint.value )) || (item.paths && - item.paths.includes(properties.mountpoint.value)) + item.paths.includes(properties.mountpoint.value)) || + (item.path && + item.path == properties.mountpoint.value) ) { return true; } @@ -1393,7 +1409,11 @@ class FreeNASApiDriver extends CsiBaseDriver { sharePaths = response.body.nfs_paths; break; case 2: - sharePaths = response.body.paths; + if (response.body.path) { + sharePaths = [response.body.path]; + } else { + sharePaths = response.body.paths; + } break; } diff --git a/src/driver/freenas/ssh.js b/src/driver/freenas/ssh.js index 3debb76..1920202 100644 --- a/src/driver/freenas/ssh.js +++ b/src/driver/freenas/ssh.js @@ -9,6 +9,7 @@ const { Zetabyte, ZfsSshProcessManager } = require("../../utils/zfs"); const GeneralUtils = require("../../utils/general"); const Handlebars = require("handlebars"); +const semver = require("semver"); // freenas properties const FREENAS_NFS_SHARE_PROPERTY_NAME = "democratic-csi:freenas_nfs_share_id"; @@ -226,8 +227,13 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { const driverShareType = this.getDriverShareType(); const execClient = this.getExecClient(); const httpClient = await this.getHttpClient(); + const httpApiClient = await this.getTrueNASHttpApiClient(); const apiVersion = httpClient.getApiVersion(); const zb = await this.getZetabyte(); + const truenasVersion = semver.coerce( + await httpApiClient.getSystemVersionMajorMinor() + ); + const isScale = await httpApiClient.getIsScale(); let volume_context; let properties; @@ -308,6 +314,12 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { break; } + if (isScale && semver.satisfies(truenasVersion, ">=22.12")) { + share.path = share.paths[0]; + delete share.paths; + delete share.alldirs; + } + response = await GeneralUtils.retry( 3, 1000, @@ -341,7 +353,11 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { sharePaths = response.body.nfs_paths; break; case 2: - sharePaths = response.body.paths; + if (response.body.path) { + sharePaths = [response.body.path]; + } else { + sharePaths = response.body.paths; + } break; } @@ -382,7 +398,8 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { properties.mountpoint.value )) || (item.paths && - item.paths.includes(properties.mountpoint.value)) + item.paths.includes(properties.mountpoint.value)) || + (item.path && item.path == properties.mountpoint.value) ) { return true; } @@ -1441,7 +1458,11 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver { sharePaths = response.body.nfs_paths; break; case 2: - sharePaths = response.body.paths; + if (response.body.path) { + sharePaths = [response.body.path]; + } else { + sharePaths = response.body.paths; + } break; }