@@ -24,6 +24,7 @@ import (
24
24
"os"
25
25
"path/filepath"
26
26
"strings"
27
+ "time"
27
28
28
29
apierrors "k8s.io/apimachinery/pkg/api/errors"
29
30
@@ -187,9 +188,22 @@ func DeployAppToWorkloadClusterAndWaitForDeploymentReady(ctx context.Context, wo
187
188
188
189
func DownloadFromAppInWorkloadCluster (ctx context.Context , workloadKubeconfigPath string , appName string , port int , path string ) (string , error ) {
189
190
runArgs := []string {
190
- "-i" , "--restart=Never" , "dummy" , "--image=dockerqa/curl:ubuntu-trusty" , "--command" , "--" , "curl" , "--silent" , fmt .Sprintf ("%s:%d%s" , appName , port , path ),
191
+ // Required by below: container name is runArg zero.
192
+ "dummy" , "-i" , "--restart=Never" , "--image=dockerqa/curl:ubuntu-trusty" , "--command" , "--" , "curl" , "--silent" , "--show-error" , fmt .Sprintf ("%s:%d%s" , appName , port , path ),
191
193
}
192
- return KubectlExec (ctx , "run" , workloadKubeconfigPath , runArgs ... )
194
+ var result , err = KubectlExec (ctx , "run" , workloadKubeconfigPath , runArgs ... )
195
+ if err != nil {
196
+ return result , err
197
+ }
198
+ if result == "" {
199
+ // A single retry to accommodate occasional cases where an empty string is returned, ostensibly
200
+ // because the service isn't fully ready. Subsequent requests have always worked.
201
+ fmt .Println ("Retrying html download" )
202
+ time .Sleep (5 * time .Second )
203
+ runArgs [0 ] = "dummy2" // Assumed: container name is runArg zero.
204
+ result , err = KubectlExec (ctx , "run" , workloadKubeconfigPath , runArgs ... )
205
+ }
206
+ return result , err
193
207
}
194
208
195
209
func DownloadMetricsFromCAPCManager (ctx context.Context , bootstrapKubeconfigPath string ) (string , error ) {
@@ -245,12 +259,6 @@ func DestroyOneMachine(clusterName string, machineType string) {
245
259
}
246
260
247
261
Byf ("Destroying machine %s" , vmToDestroy .Name )
248
- stopParams := client .VirtualMachine .NewStopVirtualMachineParams (vmToDestroy .Id )
249
- stopParams .SetForced (true )
250
- _ , err = client .VirtualMachine .StopVirtualMachine (stopParams )
251
- if err != nil {
252
- Fail ("Failed to stop machine: " + err .Error ())
253
- }
254
262
destroyParams := client .VirtualMachine .NewDestroyVirtualMachineParams (vmToDestroy .Id )
255
263
destroyParams .SetExpunge (true )
256
264
_ , err = client .VirtualMachine .DestroyVirtualMachine (destroyParams )
0 commit comments