Skip to content

Commit 5135fb8

Browse files
For RECEPTOR_KUBE_SUPPORT_RECONNECT, Update auto/default to true (#940)
1 parent cae6862 commit 5135fb8

File tree

8 files changed

+210
-108
lines changed

8 files changed

+210
-108
lines changed

pkg/workceptor/kubernetes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,8 @@ func (kw *kubeUnit) runWorkUsingLogger() {
760760
func shouldUseReconnect() bool {
761761
// Support for streaming from pod with timestamps using reconnect method is in all current versions
762762
// Can override the detection by setting the RECEPTOR_KUBE_SUPPORT_RECONNECT
763-
// accepted values: "enabled", "disabled", "auto" with "disabled" being the default
764-
// all invalid value will assume to be "disabled"
763+
// accepted values: "enabled", "disabled", "auto". The default is "enabled"
764+
// all invalid values will assume to be "disabled"
765765

766766
env, ok := os.LookupEnv("RECEPTOR_KUBE_SUPPORT_RECONNECT")
767767
if ok {
@@ -771,13 +771,13 @@ func shouldUseReconnect() bool {
771771
case "disabled":
772772
return false
773773
case "auto":
774-
// continue
774+
return true
775775
default:
776776
return false
777777
}
778778
}
779779

780-
return false
780+
return true
781781
}
782782

783783
func parseTime(s string) *time.Time {

pkg/workceptor/kubernetes_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestShouldUseReconnect(t *testing.T) {
1818
{
1919
name: "Positive (undefined) test",
2020
envValue: "",
21-
want: false,
21+
want: true,
2222
},
2323
{
2424
name: "Enabled test",
@@ -33,7 +33,7 @@ func TestShouldUseReconnect(t *testing.T) {
3333
{
3434
name: "Auto test",
3535
envValue: "auto",
36-
want: false,
36+
want: true,
3737
},
3838
{
3939
name: "Default test",

tests/functional/cli/cli_test.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ func TestListeners(t *testing.T) {
5959
defer cmd.Process.Wait()
6060
defer cmd.Process.Kill()
6161

62-
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
63-
success, err := utils.CheckUntilTimeoutWithErr(ctx, 10*time.Millisecond, func() (bool, error) {
62+
ctx1, cancel1 := context.WithTimeout(context.Background(), 2*time.Second)
63+
defer cancel1()
64+
65+
success, err := utils.CheckUntilTimeoutWithErr(ctx1, 10*time.Millisecond, func() (bool, error) {
6466
return ConfirmListening(cmd.Process.Pid, listenProto)
6567
})
6668
if err != nil {
@@ -116,8 +118,10 @@ func TestSSLListeners(t *testing.T) {
116118
return err == nil
117119
}
118120

119-
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
120-
success := utils.CheckUntilTimeout(ctx, 10*time.Millisecond, checkFunc)
121+
ctx1, cancel1 := context.WithTimeout(context.Background(), 2*time.Second)
122+
defer cancel1()
123+
124+
success := utils.CheckUntilTimeout(ctx1, 10*time.Millisecond, checkFunc)
121125
if !success {
122126
t.Fatalf("Timed out while waiting for tls backend to start:\n%s", receptorStdOut.String())
123127
}
@@ -190,8 +194,10 @@ func TestCostMap(t *testing.T) {
190194
defer cmd.Process.Wait()
191195
defer cmd.Process.Kill()
192196

193-
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
194-
success, err := utils.CheckUntilTimeoutWithErr(ctx, 10*time.Millisecond, func() (bool, error) {
197+
ctx1, cancel1 := context.WithTimeout(context.Background(), 2*time.Second)
198+
defer cancel1()
199+
200+
success, err := utils.CheckUntilTimeoutWithErr(ctx1, 10*time.Millisecond, func() (bool, error) {
195201
return ConfirmListening(cmd.Process.Pid, listenProto)
196202
})
197203
if err != nil {
@@ -238,8 +244,10 @@ func TestCosts(t *testing.T) {
238244
defer cmd.Process.Wait()
239245
defer cmd.Process.Kill()
240246

241-
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
242-
success, err := utils.CheckUntilTimeoutWithErr(ctx, 10*time.Millisecond, func() (bool, error) {
247+
ctx1, cancel1 := context.WithTimeout(context.Background(), 2*time.Second)
248+
defer cancel1()
249+
250+
success, err := utils.CheckUntilTimeoutWithErr(ctx1, 10*time.Millisecond, func() (bool, error) {
243251
return ConfirmListening(cmd.Process.Pid, listenProto)
244252
})
245253
if err != nil {

tests/functional/mesh/firewall_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ func TestFirewall(t *testing.T) {
5555
t.Fatal(err)
5656
}
5757

58-
ctx, _ := context.WithTimeout(context.Background(), 20*time.Second)
59-
err = m.WaitForReady(ctx)
58+
ctx1, cancel1 := context.WithTimeout(context.Background(), 20*time.Second)
59+
defer cancel1()
60+
61+
err = m.WaitForReady(ctx1)
6062
if err != nil {
6163
t.Fatal(err)
6264
}

tests/functional/mesh/mesh_test.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ func TestMeshStartup(t *testing.T) {
4646
t.Fatal(err)
4747
}
4848

49-
ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
50-
err = m.WaitForReady(ctx)
49+
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
50+
defer cancel1()
51+
52+
err = m.WaitForReady(ctx1)
5153
if err != nil {
5254
t.Fatal(err)
5355
}
@@ -109,8 +111,10 @@ func TestTraceroute(t *testing.T) {
109111
t.Fatal(err)
110112
}
111113

112-
ctx, _ := context.WithTimeout(context.Background(), 60*time.Second)
113-
err = m.WaitForReady(ctx)
114+
ctx1, cancel1 := context.WithTimeout(context.Background(), 60*time.Second)
115+
defer cancel1()
116+
117+
err = m.WaitForReady(ctx1)
114118
if err != nil {
115119
t.Fatal(err)
116120
}
@@ -212,8 +216,9 @@ func TestMeshShutdown(t *testing.T) {
212216
t.Fatal(err)
213217
}
214218

215-
ctx, _ := context.WithTimeout(context.Background(), 60*time.Second)
216-
err = m.WaitForReady(ctx)
219+
ctx1, cancel1 := context.WithTimeout(context.Background(), 60*time.Second)
220+
defer cancel1()
221+
err = m.WaitForReady(ctx1)
217222

218223
if err != nil {
219224
t.Fatal(err)
@@ -288,8 +293,10 @@ func TestCosts(t *testing.T) {
288293
defer m.WaitForShutdown()
289294
defer m.Destroy()
290295

291-
ctx, _ := context.WithTimeout(context.Background(), 60*time.Second)
292-
err = m.WaitForReady(ctx)
296+
ctx1, cancel1 := context.WithTimeout(context.Background(), 60*time.Second)
297+
defer cancel1()
298+
299+
err = m.WaitForReady(ctx1)
293300
if err != nil {
294301
t.Fatal(err)
295302
}
@@ -351,9 +358,11 @@ func TestDuplicateNodes(t *testing.T) {
351358
t.Fatal(err)
352359
}
353360

354-
ctx, _ := context.WithTimeout(context.Background(), 1*time.Minute)
361+
ctx1, cancel1 := context.WithTimeout(context.Background(), 1*time.Minute)
362+
defer cancel1()
363+
355364
sleepInterval := 100 * time.Millisecond
356-
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
365+
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
357366
return strings.Contains(m.LogWriter.String(), "connected using a node ID we are already connected to")
358367
}) {
359368
t.Fatal("duplicate nodes were not expected to exist together")

tests/functional/mesh/tls_test.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ func TestTCPSSLConnections(t *testing.T) {
103103
defer m.WaitForShutdown()
104104
defer m.Destroy()
105105

106-
ctx, _ := context.WithTimeout(context.Background(), 20*time.Second)
107-
err = m.WaitForReady(ctx)
106+
ctx1, cancel1 := context.WithTimeout(context.Background(), 20*time.Second)
107+
defer cancel1()
108+
109+
err = m.WaitForReady(ctx1)
108110
if err != nil {
109111
t.Fatal(err)
110112
}
@@ -187,9 +189,11 @@ func TestTCPSSLClientAuthFailNoKey(t *testing.T) {
187189
defer m.WaitForShutdown()
188190
defer m.Destroy()
189191

190-
ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
192+
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
193+
defer cancel1()
194+
191195
sleepInterval := 100 * time.Millisecond
192-
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
196+
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
193197
linuxTLSError := strings.Contains(m.LogWriter.String(), "certificate signed by unknown authority")
194198
macTLSError := strings.Contains(m.LogWriter.String(), "certificate is not trusted")
195199

@@ -265,9 +269,11 @@ func TestTCPSSLClientAuthFailBadKey(t *testing.T) {
265269
defer m.WaitForShutdown()
266270
defer m.Destroy()
267271

268-
ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
272+
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
273+
defer cancel1()
274+
269275
sleepInterval := 100 * time.Millisecond
270-
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
276+
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
271277
linuxTLSError := strings.Contains(m.LogWriter.String(), "certificate signed by unknown authority")
272278
macTLSError := strings.Contains(m.LogWriter.String(), "certificate is not trusted")
273279

@@ -330,9 +336,11 @@ func TestTCPSSLServerAuthFailNoKey(t *testing.T) {
330336
defer m.WaitForShutdown()
331337
defer m.Destroy()
332338

333-
ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
339+
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
340+
defer cancel1()
341+
334342
sleepInterval := 100 * time.Millisecond
335-
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
343+
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
336344
return strings.Contains(m.LogWriter.String(), "first record does not look like a TLS handshake")
337345
}) {
338346
t.Fatal("Expected connection to fail but it succeeded")
@@ -402,9 +410,11 @@ func TestTCPSSLServerAuthFailBadKey(t *testing.T) {
402410
defer m.WaitForShutdown()
403411
defer m.Destroy()
404412

405-
ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
413+
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
414+
defer cancel1()
415+
406416
sleepInterval := 100 * time.Millisecond
407-
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
417+
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
408418
linuxTLSError := strings.Contains(m.LogWriter.String(), "certificate signed by unknown authority")
409419
macTLSError := strings.Contains(m.LogWriter.String(), "certificate is not trusted")
410420

0 commit comments

Comments
 (0)