diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 27b0e55..b9df326 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,14 +13,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.6.0 + uses: styfle/cancel-workflow-action@0.11.0 with: access_token: ${{ github.token }} build-npm-linux-amd64: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 16 @@ -29,7 +29,7 @@ jobs: run: | ci/bin/build.sh - name: upload build - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: node-modules-linux-amd64 path: node_modules-linux-amd64.tar.gz @@ -38,7 +38,7 @@ jobs: build-npm-windows-amd64: runs-on: windows-2022 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 16 @@ -47,7 +47,7 @@ jobs: run: | ci\bin\build.ps1 - name: upload build - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: node-modules-windows-amd64 path: node_modules-windows-amd64.tar.gz @@ -67,8 +67,8 @@ jobs: - X64 - csi-sanity-synology steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -97,8 +97,8 @@ jobs: - X64 - csi-sanity-synology steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -132,8 +132,8 @@ jobs: - csi-sanity-truenas #- csi-sanity-zfs-generic steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -164,8 +164,8 @@ jobs: #- csi-sanity-truenas - csi-sanity-zfs-generic steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -198,8 +198,8 @@ jobs: #- csi-sanity-truenas - csi-sanity-zfs-generic steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -231,8 +231,8 @@ jobs: #- csi-sanity-truenas - csi-sanity-zfs-generic steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -263,8 +263,8 @@ jobs: - X64 - csi-sanity-zfs-generic steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -293,8 +293,8 @@ jobs: - X64 - csi-sanity-client steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -321,8 +321,8 @@ jobs: - X64 - csi-sanity-client steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-windows-amd64 - name: csi-sanity @@ -351,8 +351,8 @@ jobs: - X64 - csi-sanity-zfs-local steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-linux-amd64 - name: csi-sanity @@ -390,8 +390,8 @@ jobs: - X64 - csi-sanity-local-hostpath steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: ${{ matrix.npmartifact }} - name: csi-sanity @@ -414,8 +414,8 @@ jobs: - Windows - X64 steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: node-modules-windows-amd64 - name: csi-sanity @@ -469,7 +469,7 @@ jobs: - csi-sanity-windows-node runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: docker build run: | export ARCH=$([ $(uname -m) = "x86_64" ] && echo "amd64" || echo "arm64") @@ -520,7 +520,7 @@ jobs: nano_base_tag: ltsc2022 file: Dockerfile.Windows steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: docker build shell: bash run: | @@ -532,7 +532,7 @@ jobs: docker inspect democratic-csi-windows:${GITHUB_RUN_ID}-${{ matrix.core_base_tag }} docker save democratic-csi-windows:${GITHUB_RUN_ID}-${{ matrix.core_base_tag }} -o democratic-csi-windows-${{ matrix.core_base_tag }}.tar - name: upload image tar - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: democratic-csi-windows-${{ matrix.core_base_tag }}.tar path: democratic-csi-windows-${{ matrix.core_base_tag }}.tar @@ -547,7 +547,7 @@ jobs: - self-hosted - buildah steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 with: name: democratic-csi-windows-ltsc2019.tar diff --git a/Dockerfile b/Dockerfile index fb42b40..f6f2076 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,7 @@ COPY --from=build /usr/local/lib/nodejs/bin/node /usr/local/bin/node # netbase is required by rpcbind/rpcinfo to work properly # /etc/{services,rpc} are required RUN apt-get update && \ - apt-get install -y netbase socat e2fsprogs exfatprogs xfsprogs btrfs-progs fatresize dosfstools ntfs-3g nfs-common cifs-utils fdisk gdisk cloud-guest-utils sudo rsync procps util-linux && \ + apt-get install -y netbase socat e2fsprogs exfatprogs xfsprogs btrfs-progs fatresize dosfstools ntfs-3g nfs-common cifs-utils fdisk gdisk cloud-guest-utils sudo rsync procps util-linux nvme-cli && \ rm -rf /var/lib/apt/lists/* # controller requirements diff --git a/src/driver/index.js b/src/driver/index.js index 97fa934..d3d1c37 100644 --- a/src/driver/index.js +++ b/src/driver/index.js @@ -2369,99 +2369,116 @@ class CsiBaseDriver { // TODO: this could be made async to detach all simultaneously for (const block_device_info_i of realBlockDeviceInfos) { - if (await filesystem.deviceIsIscsi(block_device_info_i.path)) { - let parent_block_device = await filesystem.getBlockDeviceParent( - block_device_info_i.path - ); + switch (block_device_info_i.tran) { + case "iscsi": + { + if ( + await filesystem.deviceIsIscsi(block_device_info_i.path) + ) { + let parent_block_device = + await filesystem.getBlockDeviceParent( + block_device_info_i.path + ); - // figure out which iscsi session this belongs to and logout - // scan /dev/disk/by-path/ip-*? - // device = `/dev/disk/by-path/ip-${volume_context.portal}-iscsi-${volume_context.iqn}-lun-${volume_context.lun}`; - // parse output from `iscsiadm -m session -P 3` - let sessions = await iscsi.iscsiadm.getSessionsDetails(); - for (let i = 0; i < sessions.length; i++) { - let session = sessions[i]; - let is_attached_to_session = false; + // figure out which iscsi session this belongs to and logout + // scan /dev/disk/by-path/ip-*? + // device = `/dev/disk/by-path/ip-${volume_context.portal}-iscsi-${volume_context.iqn}-lun-${volume_context.lun}`; + // parse output from `iscsiadm -m session -P 3` + let sessions = await iscsi.iscsiadm.getSessionsDetails(); + for (let i = 0; i < sessions.length; i++) { + let session = sessions[i]; + let is_attached_to_session = false; - if ( - session.attached_scsi_devices && - session.attached_scsi_devices.host && - session.attached_scsi_devices.host.devices - ) { - is_attached_to_session = - session.attached_scsi_devices.host.devices.some( - (device) => { - if ( - device.attached_scsi_disk == parent_block_device.name - ) { - return true; + if ( + session.attached_scsi_devices && + session.attached_scsi_devices.host && + session.attached_scsi_devices.host.devices + ) { + is_attached_to_session = + session.attached_scsi_devices.host.devices.some( + (device) => { + if ( + device.attached_scsi_disk == + parent_block_device.name + ) { + return true; + } + return false; + } + ); + } + + if (is_attached_to_session) { + let timer_start; + let timer_max; + + timer_start = Math.round(new Date().getTime() / 1000); + timer_max = 30; + let loggedOut = false; + while (!loggedOut) { + try { + await iscsi.iscsiadm.logout(session.target, [ + session.persistent_portal, + ]); + loggedOut = true; + } catch (err) { + await GeneralUtils.sleep(2000); + let current_time = Math.round( + new Date().getTime() / 1000 + ); + if (current_time - timer_start > timer_max) { + // not throwing error for now as future invocations would not enter code path anyhow + loggedOut = true; + //throw new GrpcError( + // grpc.status.UNKNOWN, + // `hit timeout trying to logout of iscsi target: ${session.persistent_portal}` + //); + } + } + } + + timer_start = Math.round(new Date().getTime() / 1000); + timer_max = 30; + let deletedEntry = false; + while (!deletedEntry) { + try { + await iscsi.iscsiadm.deleteNodeDBEntry( + session.target, + session.persistent_portal + ); + deletedEntry = true; + } catch (err) { + await GeneralUtils.sleep(2000); + let current_time = Math.round( + new Date().getTime() / 1000 + ); + if (current_time - timer_start > timer_max) { + // not throwing error for now as future invocations would not enter code path anyhow + deletedEntry = true; + //throw new GrpcError( + // grpc.status.UNKNOWN, + // `hit timeout trying to delete iscsi node DB entry: ${session.target}, ${session.persistent_portal}` + //); + } + } } - return false; } + } + } + } + break; + case "nvme": + { + if ( + await filesystem.deviceIsNVMEoF(block_device_info_i.path) + ) { + let nqn = await nvmeof.nqnByNamespaceDeviceName( + block_device_info_i.name ); - } - - if (is_attached_to_session) { - let timer_start; - let timer_max; - - timer_start = Math.round(new Date().getTime() / 1000); - timer_max = 30; - let loggedOut = false; - while (!loggedOut) { - try { - await iscsi.iscsiadm.logout(session.target, [ - session.persistent_portal, - ]); - loggedOut = true; - } catch (err) { - await GeneralUtils.sleep(2000); - let current_time = Math.round( - new Date().getTime() / 1000 - ); - if (current_time - timer_start > timer_max) { - // not throwing error for now as future invocations would not enter code path anyhow - loggedOut = true; - //throw new GrpcError( - // grpc.status.UNKNOWN, - // `hit timeout trying to logout of iscsi target: ${session.persistent_portal}` - //); - } - } - } - - timer_start = Math.round(new Date().getTime() / 1000); - timer_max = 30; - let deletedEntry = false; - while (!deletedEntry) { - try { - await iscsi.iscsiadm.deleteNodeDBEntry( - session.target, - session.persistent_portal - ); - deletedEntry = true; - } catch (err) { - await GeneralUtils.sleep(2000); - let current_time = Math.round( - new Date().getTime() / 1000 - ); - if (current_time - timer_start > timer_max) { - // not throwing error for now as future invocations would not enter code path anyhow - deletedEntry = true; - //throw new GrpcError( - // grpc.status.UNKNOWN, - // `hit timeout trying to delete iscsi node DB entry: ${session.target}, ${session.persistent_portal}` - //); - } - } + await nvmeof.disconnectByNQN(nqn); } } - } - } else if (await filesystem.deviceIsNVMEoF(block_device_info_i.path)) { - let nqn = await nvmeof.nqnByNamespaceDeviceName( - block_device_info_i.name - ); - await nvmeof.disconnectByNQN(nqn); + break; } } }