Skip to content

Commit 116d3f6

Browse files
committed
chore: add retries to agent remote to make more reliable
Signed-off-by: Sergei Lukianov <me@slukjanov.name>
1 parent f2420d5 commit 116d3f6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/agent/agent.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,9 +1004,23 @@ func RunRemotely(ctx context.Context, getClient func() (*gnmi.Client, error), op
10041004

10051005
slog.Debug("SSH port forwarding finished")
10061006
})
1007+
1008+
// just give a tunnel chance to establish before creating the client
1009+
time.Sleep(1 * time.Second)
10071010
}
10081011

1009-
gnmiClient, err := getClient()
1012+
var gnmiClient *gnmi.Client
1013+
for attempt := range 5 {
1014+
if attempt > 0 {
1015+
slog.Debug("Failed to create gNMI client, retrying", "err", err.Error())
1016+
time.Sleep(1 * time.Second)
1017+
}
1018+
1019+
gnmiClient, err = getClient()
1020+
if err == nil {
1021+
break
1022+
}
1023+
}
10101024
if err != nil {
10111025
return fmt.Errorf("creating gNMI client: %w", err)
10121026
}

0 commit comments

Comments
 (0)