From 5d3d67952a4987eb250c2502e266803f41c1f773 Mon Sep 17 00:00:00 2001 From: aleskandro Date: Tue, 3 Sep 2024 09:11:49 -0400 Subject: [PATCH] Do not check the network if the context is canceled --- pkg/syncer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/syncer.go b/pkg/syncer.go index bf0d721..fb44646 100644 --- a/pkg/syncer.go +++ b/pkg/syncer.go @@ -189,11 +189,14 @@ func (n *NetworkConnectionReconciler) updateNow() { func checkNetwork(ctx context.Context) error { // Wait for the network to be fully connected for i := 0; i < 10; i++ { + if ctx.Err() != nil { + return ctx.Err() + } // Check if a web request to google is successful client := &http.Client{ Timeout: 5 * time.Second, } - req, err := http.NewRequestWithContext(ctx, "GET", "http://www.google.com", nil) + req, err := http.NewRequestWithContext(ctx, "GET", "https://www.google.com", nil) if err != nil { log.Println("Fatal error", err) return err