Skip to content

Update CSI Proxy dev scripts #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ Some notes about making changes to the server module:
- Always remember to delete a file that was generated otherwise it won't be generated again even if there
are changes that should make it autogenerate.
- Autogenerated files shouldn't be edited by hand, instead if there's a special conversion from a specific
client API version to an internal server version use the `conversion.go` file
client API version to an internal server version use the `conversion.go` file.

When there are changes to the server module:

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

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

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

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

```bash
cd ~/go/src/github.com/kubernetes-csi/csi-proxy
git fetch; git pull --rebase origin $BRANCH

# terminal 1 (build and start CSI proxy)
go build -v -a -o ./bin/csi-proxy.exe ./cmd/csi-proxy
.\bin\csi-proxy.exe --v=5

# terminal 2 (run E2E tests)
go test -v .\integrationtests\ -run TestVolumeAPIs
./scripts/sync-csi-proxy.sh
```

You can also edit the files directly in the VM using vim or a similar editor.
51 changes: 0 additions & 51 deletions scripts/e2e-runner.ps1

This file was deleted.

53 changes: 0 additions & 53 deletions scripts/e2e-tests.sh

This file was deleted.

28 changes: 28 additions & 0 deletions scripts/sync-csi-proxy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# helper script, should be called by sync-csi-proxy.sh

# # debug
# Set-PSDebug -Trace 1

# stop the csiproxy service
sc.exe stop csiproxy
Start-Sleep -Seconds 1;
sc.exe delete csiproxy

# copy the binary from the user directory
Copy-Item -Path "C:\Users\$env:UserName\csi-proxy.exe" -Destination "C:\etc\kubernetes\node\bin\csi-proxy.exe"

# restart the csiproxy service
$flags = "-v=5 -windows-service -log_file=C:\etc\kubernetes\logs\csi-proxy.log -logtostderr=false"
sc.exe create csiproxy binPath= "C:\etc\kubernetes\node\bin\csi-proxy.exe $flags"
sc.exe failure csiproxy reset= 0 actions= restart/10000
sc.exe start csiproxy

# start the CSI Proxy before running tests on windows
Start-Sleep -Seconds 5;

Write-Output "Checking the status of csi-proxy"
sc.exe query csiproxy
[System.IO.Directory]::GetFiles("\\.\\pipe\\")

Write-Output "Get logs"
Get-Content C:\etc\kubernetes\logs\csi-proxy.log -Tail 20
34 changes: 34 additions & 0 deletions scripts/sync-csi-proxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#/bin/bash
#
# Installs CSI Proxy in a kubernetes node
#
# Requirements:
# - a kubernetes cluster with a Windows nodepool
#
# Steps:
# - cross compile the binary
# - copy to the VM using scp
# - restart the CSI Proxy binary process with a helper powershell script

set -ex

script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
csi_proxy_bin_path="$script_dir/../bin/csi-proxy.exe"
sync_script_ps_path="$script_dir/sync-csi-proxy.ps1"

main() {
echo "Compiling CSI Proxy"
make build

local windows_node=$(kubectl get nodes -l kubernetes.io/os=windows -o jsonpath='{.items[*].metadata.name}')
gcloud compute instances describe $windows_node > /dev/null

echo "Sync the csi-proxy.exe binary"
local current_account=$(gcloud config list account --format "value(core.account)" | sed -r 's/@\S+//g')
gcloud compute scp $csi_proxy_bin_path $sync_script_ps_path $windows_node:"C:\\Users\\${current_account}"

echo "Restart csi-proxy service"
gcloud compute ssh $windows_node --command="powershell .\sync-csi-proxy.ps1"
}

main