Skip to content

Commit

Permalink
Do not check the network if the context is canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
aleskandro committed Sep 3, 2024
1 parent a47c4e5 commit 5d3d679
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5d3d679

Please sign in to comment.