windows hostpath
This commit is contained in:
		
							parent
							
								
									8014fed9c0
								
							
						
					
					
						commit
						c6f9fd9a6e
					
				|  | @ -309,24 +309,31 @@ jobs: | ||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         config: |         os: [Linux, Windows] | ||||||
|           - local-hostpath/basic.yaml |         include: | ||||||
|  |         - os: Linux | ||||||
|  |           template: "./ci/configs/local-hostpath/basic.yaml" | ||||||
|  |           run: | | ||||||
|  |             # run tests | ||||||
|  |             ci/bin/run.sh | ||||||
|  |         - os: Windows | ||||||
|  |           template: ".\\ci\\configs\\local-hostpath/basic.yaml" | ||||||
|  |           run: | | ||||||
|  |             # run tests | ||||||
|  |             ci\bin\run.ps1 | ||||||
|     runs-on: |     runs-on: | ||||||
|       - self-hosted |       - self-hosted | ||||||
|       - Linux |       - ${{ matrix.os }} | ||||||
|       - X64 |       - X64 | ||||||
|       - csi-sanity-zfs-local |  | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v2 |       - uses: actions/checkout@v2 | ||||||
|       - uses: actions/download-artifact@v2 |       - uses: actions/download-artifact@v2 | ||||||
|         with: |         with: | ||||||
|           name: node-modules-linux-amd64 |           name: node-modules-linux-amd64 | ||||||
|       - name: csi-sanity |       - name: csi-sanity | ||||||
|         run: | |         run: ${{ matrix.run }} | ||||||
|           # run tests |  | ||||||
|           ci/bin/run.sh |  | ||||||
|         env: |         env: | ||||||
|           TEMPLATE_CONFIG_FILE: "./ci/configs/${{ matrix.config }}" |           TEMPLATE_CONFIG_FILE: "${{ matrix.template }}" | ||||||
|           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" |           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" | ||||||
| 
 | 
 | ||||||
|   csi-sanity-windows-node: |   csi-sanity-windows-node: | ||||||
|  | @ -356,6 +363,7 @@ jobs: | ||||||
|           SERVER_HOST: ${{ secrets.SANITY_ZFS_GENERIC_HOST }} |           SERVER_HOST: ${{ secrets.SANITY_ZFS_GENERIC_HOST }} | ||||||
|           SERVER_USERNAME: ${{ secrets.SANITY_ZFS_GENERIC_USERNAME }} |           SERVER_USERNAME: ${{ secrets.SANITY_ZFS_GENERIC_USERNAME }} | ||||||
|           SERVER_PASSWORD: ${{ secrets.SANITY_ZFS_GENERIC_PASSWORD }} |           SERVER_PASSWORD: ${{ secrets.SANITY_ZFS_GENERIC_PASSWORD }} | ||||||
|  |           CSI_SANITY_FOCUS: "Node Service" | ||||||
| 
 | 
 | ||||||
|   build-docker-linux: |   build-docker-linux: | ||||||
|     needs: |     needs: | ||||||
|  |  | ||||||
|  | @ -10,39 +10,48 @@ $exit_code = 0 | ||||||
| $tmpdir = New-Item -ItemType Directory -Path ([System.IO.Path]::GetTempPath()) -Name ([System.IO.Path]::GetRandomFileName()) | $tmpdir = New-Item -ItemType Directory -Path ([System.IO.Path]::GetTempPath()) -Name ([System.IO.Path]::GetRandomFileName()) | ||||||
| $env:CSI_SANITY_TEMP_DIR = $tmpdir.FullName | $env:CSI_SANITY_TEMP_DIR = $tmpdir.FullName | ||||||
| 
 | 
 | ||||||
| if (! $env:CSI_SANITY_FOCUS) { |  | ||||||
|   $env:CSI_SANITY_FOCUS = "Node Service" |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| if (! $env:CSI_SANITY_SKIP) { |  | ||||||
|   $env:CSI_SANITY_SKIP = "" |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| # cleanse endpoint to something csi-sanity plays nicely with | # cleanse endpoint to something csi-sanity plays nicely with | ||||||
| $endpoint = ${env:CSI_ENDPOINT} | $endpoint = ${env:CSI_ENDPOINT} | ||||||
| $endpoint = $endpoint.replace("C:\", "/") | $endpoint = $endpoint.replace("C:\", "/") | ||||||
| $endpoint = $endpoint.replace("\", "/") | $endpoint = $endpoint.replace("\", "/") | ||||||
| 
 | 
 | ||||||
|  | if (! $env:CSI_SANITY_FAILFAST) { | ||||||
|  |   $env:CSI_SANITY_FAILFAST = "false" | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | $failfast = "" | ||||||
|  | 
 | ||||||
|  | if ($env:CSI_SANITY_FAILFAST -eq "true") { | ||||||
|  |   $failfast = "-ginkgo.failFast" | ||||||
|  | } | ||||||
|  | 
 | ||||||
| Write-Output "launching csi-sanity" | Write-Output "launching csi-sanity" | ||||||
| Write-Output "connecting to: ${endpoint}" | Write-Output "connecting to: ${endpoint}" | ||||||
|  | Write-Output "failfast: ${env:CSI_SANITY_FAILFAST}" | ||||||
| Write-Output "skip: ${env:CSI_SANITY_SKIP}" | Write-Output "skip: ${env:CSI_SANITY_SKIP}" | ||||||
| Write-Output "focus: ${env:CSI_SANITY_FOCUS}" | Write-Output "focus: ${env:CSI_SANITY_FOCUS}" | ||||||
| 
 | 
 | ||||||
|  | $skip = '"' + ${env:CSI_SANITY_SKIP} + '"' | ||||||
|  | $focus = '"' + ${env:CSI_SANITY_FOCUS} + '"' | ||||||
|  | 
 | ||||||
| csi-sanity.exe -"csi.endpoint" "unix://${endpoint}" ` | csi-sanity.exe -"csi.endpoint" "unix://${endpoint}" ` | ||||||
|   -"ginkgo.failFast" ` |   $failfast ` | ||||||
|   -"csi.mountdir" "${env:CSI_SANITY_TEMP_DIR}\mnt" ` |   -"csi.mountdir" "${env:CSI_SANITY_TEMP_DIR}\mnt" ` | ||||||
|   -"csi.stagingdir" "${env:CSI_SANITY_TEMP_DIR}\stage" ` |   -"csi.stagingdir" "${env:CSI_SANITY_TEMP_DIR}\stage" ` | ||||||
|   -"csi.testvolumeexpandsize" 2147483648 ` |   -"csi.testvolumeexpandsize" 2147483648 ` | ||||||
|   -"csi.testvolumesize" 1073741824 ` |   -"csi.testvolumesize" 1073741824 ` | ||||||
|   -"ginkgo.focus" "${env:CSI_SANITY_FOCUS}" |   -"ginkgo.skip" $skip ` | ||||||
|  |   -"ginkgo.focus" $focus | ||||||
| 
 | 
 | ||||||
| # does not work the same as linux for some reason | # does not work the same as linux for some reason | ||||||
| #-"ginkgo.skip" "${env:CSI_SANITY_SKIP}" ` | # -"ginkgo.skip" "'" + ${env:CSI_SANITY_SKIP} + "'" ` | ||||||
| 
 | 
 | ||||||
| if (-not $?) { | if (-not $?) { | ||||||
|   $exit_code = $LASTEXITCODE |   $exit_code = $LASTEXITCODE | ||||||
|   Write-Output "csi-sanity exit code: ${exit_code}" |   Write-Output "csi-sanity exit code: ${exit_code}" | ||||||
|  |   if ($exit_code -gt 0) { | ||||||
|     $exit_code = 1 |     $exit_code = 1 | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # remove tmp dir | # remove tmp dir | ||||||
|  |  | ||||||
|  | @ -503,7 +503,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver { | ||||||
|     //let volume_content_source_volume_id;
 |     //let volume_content_source_volume_id;
 | ||||||
| 
 | 
 | ||||||
|     // create target dir
 |     // create target dir
 | ||||||
|     await driver.createDir(target_path); |     await driver.createDir(volume_path); | ||||||
| 
 | 
 | ||||||
|     // create dataset
 |     // create dataset
 | ||||||
|     if (volume_content_source) { |     if (volume_content_source) { | ||||||
|  |  | ||||||
|  | @ -1222,10 +1222,10 @@ class CsiBaseDriver { | ||||||
|         break; |         break; | ||||||
|       case NODE_OS_DRIVER_WINDOWS: |       case NODE_OS_DRIVER_WINDOWS: | ||||||
|         // sanity check node_attach_driver
 |         // sanity check node_attach_driver
 | ||||||
|         if (!["smb", "iscsi"].includes(node_attach_driver)) { |         if (!["smb", "iscsi", "hostpath"].includes(node_attach_driver)) { | ||||||
|           throw new GrpcError( |           throw new GrpcError( | ||||||
|             grpc.status.UNIMPLEMENTED, |             grpc.status.UNIMPLEMENTED, | ||||||
|             `csi-proxy does not work with node_attach_driver: ${node_attach_driver}` |             `windows does not work with node_attach_driver: ${node_attach_driver}` | ||||||
|           ); |           ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -1233,7 +1233,7 @@ class CsiBaseDriver { | ||||||
|         if (fs_type && !["ntfs", "cifs"].includes(fs_type)) { |         if (fs_type && !["ntfs", "cifs"].includes(fs_type)) { | ||||||
|           throw new GrpcError( |           throw new GrpcError( | ||||||
|             grpc.status.UNIMPLEMENTED, |             grpc.status.UNIMPLEMENTED, | ||||||
|             `csi-proxy does not work with fs_type: ${fs_type}` |             `windows does not work with fs_type: ${fs_type}` | ||||||
|           ); |           ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -1592,6 +1592,39 @@ class CsiBaseDriver { | ||||||
|                 ); |                 ); | ||||||
|             } |             } | ||||||
|             break; |             break; | ||||||
|  |           case "hostpath": | ||||||
|  |             try { | ||||||
|  |               fs.statSync(win_staging_target_path); | ||||||
|  |               result = true; | ||||||
|  |             } catch (err) { | ||||||
|  |               if (err.code === "ENOENT") { | ||||||
|  |                 result = false; | ||||||
|  |               } else { | ||||||
|  |                 throw err; | ||||||
|  |               } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // if exists already delete if folder, return if symlink
 | ||||||
|  |             if (result) { | ||||||
|  |               result = fs.lstatSync(win_staging_target_path); | ||||||
|  |               // remove pre-created dir by CO
 | ||||||
|  |               if (!result.isSymbolicLink()) { | ||||||
|  |                 fs.rmdirSync(win_staging_target_path); | ||||||
|  |               } else { | ||||||
|  |                 // assume symlink points to the correct location
 | ||||||
|  |                 return {}; | ||||||
|  |               } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // create symlink
 | ||||||
|  |             fs.symlinkSync( | ||||||
|  |               filesystem.covertUnixSeparatorToWindowsSeparator( | ||||||
|  |                 volume_context.path | ||||||
|  |               ), | ||||||
|  |               win_staging_target_path | ||||||
|  |             ); | ||||||
|  |             return {}; | ||||||
|  |             break; | ||||||
|           default: |           default: | ||||||
|             throw new GrpcError( |             throw new GrpcError( | ||||||
|               grpc.status.INVALID_ARGUMENT, |               grpc.status.INVALID_ARGUMENT, | ||||||
|  | @ -2254,6 +2287,9 @@ class CsiBaseDriver { | ||||||
|               // delete target/target portal/etc
 |               // delete target/target portal/etc
 | ||||||
|               // do NOT do this now as removing the portal will remove all targets associated with it
 |               // do NOT do this now as removing the portal will remove all targets associated with it
 | ||||||
|               break; |               break; | ||||||
|  |             case "hostpath": | ||||||
|  |               // allow below code to remove symlink
 | ||||||
|  |               break; | ||||||
|             case "bypass": |             case "bypass": | ||||||
|               break; |               break; | ||||||
|             default: |             default: | ||||||
|  | @ -2560,7 +2596,7 @@ class CsiBaseDriver { | ||||||
|           case "smb": |           case "smb": | ||||||
|           //case "lustre":
 |           //case "lustre":
 | ||||||
|           //case "oneclient":
 |           //case "oneclient":
 | ||||||
|           //case "hostpath":
 |           case "hostpath": | ||||||
|           case "iscsi": |           case "iscsi": | ||||||
|             //case "zfs-local":
 |             //case "zfs-local":
 | ||||||
|             // ensure appropriate directories/files
 |             // ensure appropriate directories/files
 | ||||||
|  | @ -2956,7 +2992,7 @@ class CsiBaseDriver { | ||||||
| 
 | 
 | ||||||
|         let node_attach_driver; |         let node_attach_driver; | ||||||
| 
 | 
 | ||||||
|         let target = await wutils.GetRealTarget(win_volume_path); |         let target = await wutils.GetRealTarget(win_volume_path) || ""; | ||||||
|         if (target.startsWith("\\\\")) { |         if (target.startsWith("\\\\")) { | ||||||
|           node_attach_driver = "smb"; |           node_attach_driver = "smb"; | ||||||
|         } |         } | ||||||
|  | @ -2987,6 +3023,7 @@ class CsiBaseDriver { | ||||||
|             ]; |             ]; | ||||||
|             break; |             break; | ||||||
|           case "bypass": |           case "bypass": | ||||||
|  |             res.usage = [{ total: 0, unit: "BYTES" }]; | ||||||
|             break; |             break; | ||||||
|           default: |           default: | ||||||
|             throw new GrpcError( |             throw new GrpcError( | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue