Skip to content

Commit 66049b3

Browse files
authored
[test] Fix RPC retries & improve logging (#18210)
* [test] Fix RPC retries & improve logging * Fix panic
1 parent b797ea6 commit 66049b3

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

test/pkg/integration/integration.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,32 +206,30 @@ type RpcClient struct {
206206

207207
func (r *RpcClient) Call(serviceMethod string, args any, reply any) error {
208208
var err error
209-
var new *RpcClient
209+
cl := r
210210
for i := 0; i < connectFailureMaxTries; i++ {
211-
if r != nil {
212-
if err = r.client.Call(serviceMethod, args, reply); err != nil {
213-
log.Warnf("rpc call %s failed (attempt %d): %v", serviceMethod, i, err)
214-
if i == connectFailureMaxTries-1 {
215-
return err
216-
}
217-
218-
time.Sleep(10 * time.Second)
219-
r.Close()
220-
new, _, err = Instrument(r.component, r.agentName, r.namespace, r.kubeconfig, r.kclient, r.opts...)
221-
if err != nil {
222-
time.Sleep(10 * time.Second)
223-
continue
224-
}
225-
r = new
226-
}
227-
} else {
228-
new, _, err = Instrument(r.component, r.agentName, r.namespace, r.kubeconfig, r.kclient, r.opts...)
211+
if cl == nil {
212+
cl, _, err = Instrument(r.component, r.agentName, r.namespace, r.kubeconfig, r.kclient, r.opts...)
229213
if err != nil {
214+
log.Warnf("failed to re-instrument (attempt %d): %v", i, err)
230215
time.Sleep(10 * time.Second)
231216
continue
232217
}
233-
r = new
234218
}
219+
220+
err = cl.client.Call(serviceMethod, args, reply)
221+
if err == nil {
222+
return nil
223+
}
224+
225+
log.Warnf("rpc call %s failed (attempt %d): %v", serviceMethod, i, err)
226+
if i == connectFailureMaxTries-1 {
227+
return err
228+
}
229+
230+
time.Sleep(10 * time.Second)
231+
cl.Close()
232+
cl = nil // Try to Instrument again next attempt
235233
}
236234
return err
237235
}
@@ -446,7 +444,10 @@ L:
446444
func shutdownAgent(podExec *PodExec, kubeconfig string, podName string, namespace string, containerName string) error {
447445
cmd := []string{"curl", "localhost:8080/shutdown"}
448446
_, _, _, err := podExec.ExecCmd(cmd, podName, namespace, containerName)
449-
return err
447+
if err != nil {
448+
return fmt.Errorf("curl failed: %v", err)
449+
}
450+
return nil
450451
}
451452

452453
func getFreePort() (int, error) {

test/tests/components/ws-daemon/cpu_burst_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"sigs.k8s.io/e2e-framework/pkg/envconf"
1515
"sigs.k8s.io/e2e-framework/pkg/features"
1616

17-
"github.com/gitpod-io/gitpod/common-go/log"
1817
csapi "github.com/gitpod-io/gitpod/content-service/api"
1918
daemon "github.com/gitpod-io/gitpod/test/pkg/agent/daemon/api"
2019
wsapi "github.com/gitpod-io/gitpod/test/pkg/agent/workspace/api"
@@ -140,7 +139,7 @@ func TestCpuBurst(t *testing.T) {
140139
}, &cpuResp)
141140

142141
if err != nil && err.Error() != "unexpected EOF" {
143-
log.WithError(err).Error("could not perform cpu burn")
142+
t.Logf("error performing cpu burn: %q", err)
144143
}
145144
}()
146145

0 commit comments

Comments
 (0)