Skip to content

Commit 52667b6

Browse files
committed
Script to prepare the VM to do SSH
1 parent 7fc93a3 commit 52667b6

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

scripts/bump-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#/bin/bash
1+
#!/bin/bash
22

33
# bump-version.sh
44
# Bumps an API version from an old version to a new one

scripts/run-integration.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#/bin/bash
1+
#!/bin/bash
2+
23
#
34
# Runs the integration tests
45
#
@@ -11,10 +12,10 @@
1112
# - restart the CSI Proxy binary process with a helper powershell script
1213
# - run the integration tests
1314

14-
set -ex
15+
set -euxo pipefail
1516

16-
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
17-
source $script_dir/utils.sh
17+
pkgdir=${GOPATH}/src/github.com/kubernetes-csi/csi-proxy
18+
source $pkgdir/scripts/utils.sh
1819

1920
main() {
2021
compile_csi_proxy

scripts/sync-csi-proxy.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#/bin/bash
1+
#!/bin/bash
2+
23
#
34
# Installs CSI Proxy in a kubernetes node
45
#
@@ -10,10 +11,10 @@
1011
# - copy to the VM using scp
1112
# - restart the CSI Proxy binary process with a helper powershell script
1213

13-
set -ex
14+
set -euxo pipefail
1415

15-
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
16-
source $script_dir/utils.sh
16+
pkgdir=${GOPATH}/src/github.com/kubernetes-csi/csi-proxy
17+
source $pkgdir/scripts/utils.sh
1718

1819
main() {
1920
compile_csi_proxy

scripts/utils.psm1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function Restart-CSIProxy {
22
# stop the csiproxy service
3+
Get-Process csi-proxy | Stop-Process -Force
34
sc.exe stop csiproxy
45
Start-Sleep -Seconds 1;
56
sc.exe delete csiproxy
@@ -10,7 +11,7 @@ function Restart-CSIProxy {
1011

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

scripts/utils.sh

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
#/bin/bash
1+
#!/bin/bash
2+
23
# Importing this library shouldn't have side effects
34

4-
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
pkgdir=${GOPATH}/src/github.com/kubernetes-csi/csi-proxy
56

6-
# current_account is the current Google SDK Account
7-
current_account=$(gcloud config list account --format "value(core.account)" | sed -r 's/@\S+//g')
7+
# current_account is the current user
8+
# in CI, the value is `prow`
9+
current_account=$USER
810
# windows_node is the id of the GCE Windows instance
911
windows_node=$(kubectl get nodes -l kubernetes.io/os=windows -o jsonpath='{.items[*].metadata.name}')
1012

11-
if ! [ -z $GCP_ZONE ]; then
12-
export CLOUDSDK_COMPUTE_ZONE=$GCP_ZONE
13+
# set the default zone for the gcloud sdk
14+
if ! [ -z "${GCP_ZONE:-}" ]; then
15+
export CLOUDSDK_COMPUTE_ZONE="$GCP_ZONE"
1316
fi
1417

1518
sync_file_to_vm() {
@@ -18,41 +21,42 @@ sync_file_to_vm() {
1821

1922
compile_csi_proxy() {
2023
echo "Compiling CSI Proxy"
21-
make build
24+
make -C $pkgdir build
2225
}
2326

2427
compile_csi_proxy_integration_tests() {
2528
echo "Compiling CSI Proxy integration tests"
26-
GOOS=windows GOARCH=amd64 go test -c ./integrationtests -o bin/integrationtests.test.exe
29+
GOOS=windows GOARCH=amd64 go test -c $pkgdir/integrationtests -o $pkgdir/bin/integrationtests.test.exe
2730
}
2831

2932
sync_csi_proxy() {
3033
echo "Sync the csi-proxy.exe binary"
31-
local csi_proxy_bin_path="$script_dir/../bin/csi-proxy.exe"
34+
local csi_proxy_bin_path="$pkgdir/bin/csi-proxy.exe"
3235
sync_file_to_vm $csi_proxy_bin_path
3336
}
3437

3538
sync_csi_proxy_integration_tests() {
3639
echo "Sync the integrationtests.exe binary"
37-
local integration_bin_path="$script_dir/../bin/integrationtests.test.exe"
40+
local integration_bin_path="$pkgdir/bin/integrationtests.test.exe"
3841
sync_file_to_vm $integration_bin_path
3942
}
4043

4144
sync_powershell_utils() {
42-
local utils_psm1="$script_dir/utils.psm1"
45+
local utils_psm1="$pkgdir/scripts/utils.psm1"
4346
sync_file_to_vm $utils_psm1
4447
}
4548

4649
restart_csi_proxy() {
4750
echo "Restart csi-proxy service"
48-
gcloud compute ssh $windows_node --command='powershell -c "& { Import-Module .\utils.psm1; Restart-CSIProxy }"'
51+
gcloud compute ssh $windows_node --command='powershell -c "& { $ErrorActionPreference = \"Stop\"; Import-Module (Resolve-Path(\"utils.psm1\")); Restart-CSIProxy; }"'
4952
}
5053

5154
run_csi_proxy_integration_tests() {
5255
echo "Run integration tests"
5356
local ps1=$(cat << 'EOF'
5457
"& {
55-
Import-Module .\\utils.psm1;
58+
$ErrorActionPreference = \"Stop\";
59+
Import-Module (Resolve-Path(\"utils.psm1\"));
5660
Run-CSIProxyIntegrationTests -test_args \"--test.v --test.run TestAPIGroups\";
5761
Run-CSIProxyIntegrationTests -test_args \"--test.v --test.run TestFilesystemAPIGroup\";
5862
Run-CSIProxyIntegrationTests -test_args \"--test.v --test.run TestDiskAPIGroup\";

0 commit comments

Comments
 (0)