diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 107c4c0..e0c8f10 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: access_token: ${{ github.token }} build-npm: - name: build + name: build-npm runs-on: - self-hosted steps: @@ -33,6 +33,7 @@ jobs: name: node-modules #path: node_modules/ path: node_modules.tar.gz + retention-days: 7 csi-sanity-synology: needs: @@ -156,7 +157,6 @@ jobs: TRUENAS_USERNAME: ${{ secrets.SANITY_TRUENAS_USERNAME }} TRUENAS_PASSWORD: ${{ secrets.SANITY_TRUENAS_PASSWORD }} - # ssh-based drivers csi-sanity-zfs-generic: needs: @@ -210,6 +210,30 @@ jobs: env: TEMPLATE_CONFIG_FILE: "./ci/configs/${{ matrix.config }}" + # zfs-local drivers + csi-sanity-local-hostpath: + needs: + - build-npm + strategy: + fail-fast: false + matrix: + config: + - local-hostpath/basic.yaml + runs-on: + - self-hosted + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: node-modules + - name: csi-sanity + run: | + # run tests + ci/bin/run.sh + env: + TEMPLATE_CONFIG_FILE: "./ci/configs/${{ matrix.config }}" + 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" + build-docker: needs: - csi-sanity-synology diff --git a/ci/bin/launch-csi-sanity.sh b/ci/bin/launch-csi-sanity.sh index 2d82f89..9e2cb36 100755 --- a/ci/bin/launch-csi-sanity.sh +++ b/ci/bin/launch-csi-sanity.sh @@ -34,6 +34,8 @@ csi-sanity --csi.endpoint "unix://${CSI_ENDPOINT}" \ --csi.mountdir "${CSI_SANITY_TEMP_DIR}/mnt" \ --csi.stagingdir "${CSI_SANITY_TEMP_DIR}/stage" \ --csi.testvolumeexpandsize 2147483648 \ ---csi.testvolumesize 1073741824 +--csi.testvolumesize 1073741824 \ +-ginkgo.skip "${CSI_SANITY_SKIP}" \ +-ginkgo.focus "${CSI_SANITY_FOCUS}" rm -rf "${CSI_SANITY_TEMP_DIR}" diff --git a/ci/configs/local-hostpath/basic.yaml b/ci/configs/local-hostpath/basic.yaml new file mode 100644 index 0000000..036d68e --- /dev/null +++ b/ci/configs/local-hostpath/basic.yaml @@ -0,0 +1,8 @@ +driver: local-hostpath +instance_id: +local-hostpath: + shareBasePath: "/tmp/local-hostpath/${CI_BUILD_KEY}/controller" + controllerBasePath: "/tmp/local-hostpath/${CI_BUILD_KEY}/controller" + dirPermissionsMode: "0777" + dirPermissionsUser: root + dirPermissionsGroup: wheel diff --git a/src/driver/controller-client-common/index.js b/src/driver/controller-client-common/index.js index 7d48b88..1849dc2 100644 --- a/src/driver/controller-client-common/index.js +++ b/src/driver/controller-client-common/index.js @@ -41,7 +41,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver { options.service.identity.capabilities.volume_expansion = [ //"UNKNOWN", - "ONLINE", + //"ONLINE", //"OFFLINE" ]; } diff --git a/src/driver/controller-local-hostpath/index.js b/src/driver/controller-local-hostpath/index.js new file mode 100644 index 0000000..ee7c6d3 --- /dev/null +++ b/src/driver/controller-local-hostpath/index.js @@ -0,0 +1,65 @@ +const _ = require("lodash"); + +const { ControllerClientCommonDriver } = require("../controller-client-common"); + +const NODE_TOPOLOGY_KEY_NAME = "org.democratic-csi.topology/node"; + +/** + * Crude local-hostpath driver which simply creates directories to be mounted + * and uses rsync for cloning/snapshots + */ +class ControllerLocalHostpathDriver extends ControllerClientCommonDriver { + constructor(ctx, options) { + const i_caps = _.get( + options, + "service.identity.capabilities.service", + false + ); + super(...arguments); + + if (!i_caps) { + this.ctx.logger.debug("setting local-hostpath identity service caps"); + + options.service.identity.capabilities.service = [ + //"UNKNOWN", + "CONTROLLER_SERVICE", + "VOLUME_ACCESSIBILITY_CONSTRAINTS", + ]; + } + } + + getConfigKey() { + return "local-hostpath"; + } + + getVolumeContext(name) { + const driver = this; + const config_key = driver.getConfigKey(); + return { + node_attach_driver: "hostpath", + path: driver.getShareVolumePath(name), + }; + } + + getFsTypes() { + return []; + } + + /** + * Add node topologies + * + * @param {*} call + * @returns + */ + async NodeGetInfo(call) { + const response = await super.NodeGetInfo(...arguments); + response.accessible_topology = { + segments: { + [NODE_TOPOLOGY_KEY_NAME]: response.node_id, + }, + }; + return response; + } +} + +module.exports.ControllerLocalHostpathDriver = ControllerLocalHostpathDriver; diff --git a/src/driver/factory.js b/src/driver/factory.js index 174e563..6cb4850 100644 --- a/src/driver/factory.js +++ b/src/driver/factory.js @@ -1,5 +1,8 @@ const { FreeNASSshDriver } = require("./freenas/ssh"); const { FreeNASApiDriver } = require("./freenas/api"); +const { + ControllerLocalHostpathDriver, +} = require("./controller-local-hostpath"); const { ControllerZfsGenericDriver } = require("./controller-zfs-generic"); const { ControllerZfsLocalDriver } = require("./controller-zfs-local"); const { @@ -41,6 +44,8 @@ function factory(ctx, options) { return new ControllerSmbClientDriver(ctx, options); case "nfs-client": return new ControllerNfsClientDriver(ctx, options); + case "local-hostpath": + return new ControllerLocalHostpathDriver(ctx, options); case "lustre-client": return new ControllerLustreClientDriver(ctx, options); case "node-manual": diff --git a/src/driver/index.js b/src/driver/index.js index f701e57..be193e4 100644 --- a/src/driver/index.js +++ b/src/driver/index.js @@ -575,6 +575,17 @@ class CsiBaseDriver { ); } } + break; + case "hostpath": + result = await mount.pathIsMounted(staging_target_path); + // if not mounted, mount + if (!result) { + await mount.bindMount(volume_context.path, staging_target_path); + return {}; + } else { + return {}; + } + break; case "oneclient": let oneclient = new OneClient(); @@ -1119,6 +1130,8 @@ class CsiBaseDriver { case "nfs": case "smb": case "lustre": + case "oneclient": + case "hostpath": case "iscsi": case "zfs-local": // ensure appropriate directories/files