Skip to content

Commit 4d9f851

Browse files
authored
Merge pull request #182 from mauriciopoppe/update-csi-proxy-dev-scripts
Update CSI Proxy dev scripts
2 parents 4c23ef2 + 4f3e06a commit 4d9f851

File tree

5 files changed

+66
-120
lines changed

5 files changed

+66
-120
lines changed

docs/DEVELOPMENT.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ Some notes about making changes to the server module:
6767
- Always remember to delete a file that was generated otherwise it won't be generated again even if there
6868
are changes that should make it autogenerate.
6969
- Autogenerated files shouldn't be edited by hand, instead if there's a special conversion from a specific
70-
client API version to an internal server version use the `conversion.go` file
70+
client API version to an internal server version use the `conversion.go` file.
7171

7272
When there are changes to the server module:
7373

7474
- Delete the autogenerated files, for example when I was working on
75-
making changes to the volume API I deleted all the `_generated.go` files
75+
making changes to the volume API I deleted all the `_generated.go` files.
7676

7777
```shell
7878
find pkg/server/volume -name "*_generated.go" | xargs rm
@@ -107,20 +107,8 @@ There are a few presubmit tests that run in Github Actions, E2E tests need to ru
107107

108108
During development we need to iterate faster, I follow this workflow during development:
109109

110-
- Make changes to the codebase locally and push to the remote
111-
- RDP to the VM and open a few powershell terminals (with `start powershell`)
112-
- Pull the changes from the remote, recompile and start csi-proxy and run the E2E tests
110+
- cross compile csi-prox.exe, copy it to the Windows VM and restart csi-proxy
113111

114112
```bash
115-
cd ~/go/src/github.com/kubernetes-csi/csi-proxy
116-
git fetch; git pull --rebase origin $BRANCH
117-
118-
# terminal 1 (build and start CSI proxy)
119-
go build -v -a -o ./bin/csi-proxy.exe ./cmd/csi-proxy
120-
.\bin\csi-proxy.exe --v=5
121-
122-
# terminal 2 (run E2E tests)
123-
go test -v .\integrationtests\ -run TestVolumeAPIs
113+
./scripts/sync-csi-proxy.sh
124114
```
125-
126-
You can also edit the files directly in the VM using vim or a similar editor.

scripts/e2e-runner.ps1

Lines changed: 0 additions & 51 deletions
This file was deleted.

scripts/e2e-tests.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

scripts/sync-csi-proxy.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# helper script, should be called by sync-csi-proxy.sh
2+
3+
# # debug
4+
# Set-PSDebug -Trace 1
5+
6+
# stop the csiproxy service
7+
sc.exe stop csiproxy
8+
Start-Sleep -Seconds 1;
9+
sc.exe delete csiproxy
10+
11+
# copy the binary from the user directory
12+
Copy-Item -Path "C:\Users\$env:UserName\csi-proxy.exe" -Destination "C:\etc\kubernetes\node\bin\csi-proxy.exe"
13+
14+
# restart the csiproxy service
15+
$flags = "-v=5 -windows-service -log_file=C:\etc\kubernetes\logs\csi-proxy.log -logtostderr=false"
16+
sc.exe create csiproxy binPath= "C:\etc\kubernetes\node\bin\csi-proxy.exe $flags"
17+
sc.exe failure csiproxy reset= 0 actions= restart/10000
18+
sc.exe start csiproxy
19+
20+
# start the CSI Proxy before running tests on windows
21+
Start-Sleep -Seconds 5;
22+
23+
Write-Output "Checking the status of csi-proxy"
24+
sc.exe query csiproxy
25+
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
26+
27+
Write-Output "Get logs"
28+
Get-Content C:\etc\kubernetes\logs\csi-proxy.log -Tail 20

scripts/sync-csi-proxy.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#/bin/bash
2+
#
3+
# Installs CSI Proxy in a kubernetes node
4+
#
5+
# Requirements:
6+
# - a kubernetes cluster with a Windows nodepool
7+
#
8+
# Steps:
9+
# - cross compile the binary
10+
# - copy to the VM using scp
11+
# - restart the CSI Proxy binary process with a helper powershell script
12+
13+
set -ex
14+
15+
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
16+
csi_proxy_bin_path="$script_dir/../bin/csi-proxy.exe"
17+
sync_script_ps_path="$script_dir/sync-csi-proxy.ps1"
18+
19+
main() {
20+
echo "Compiling CSI Proxy"
21+
make build
22+
23+
local windows_node=$(kubectl get nodes -l kubernetes.io/os=windows -o jsonpath='{.items[*].metadata.name}')
24+
gcloud compute instances describe $windows_node > /dev/null
25+
26+
echo "Sync the csi-proxy.exe binary"
27+
local current_account=$(gcloud config list account --format "value(core.account)" | sed -r 's/@\S+//g')
28+
gcloud compute scp $csi_proxy_bin_path $sync_script_ps_path $windows_node:"C:\\Users\\${current_account}"
29+
30+
echo "Restart csi-proxy service"
31+
gcloud compute ssh $windows_node --command="powershell .\sync-csi-proxy.ps1"
32+
}
33+
34+
main

0 commit comments

Comments
 (0)