Skip to content

Commit

Permalink
Add a retry when sig connects to sciond.
Browse files Browse the repository at this point in the history
Some tests start sig in the same time as sciond and so are flaky.
  • Loading branch information
jiceatscion committed Jan 14, 2025
1 parent f49d3cd commit 3916456
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions gateway/cmd/gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
_ "net/http/pprof"
"net/netip"
"time"

"github.com/go-chi/chi/v5"
"github.com/go-chi/cors"
Expand Down Expand Up @@ -63,9 +64,21 @@ func realMain(ctx context.Context) error {
defer daemon.Close()
localIA, err := daemon.LocalIA(ctx)
if err != nil {
return serrors.Wrap("retrieving local ISD-AS", err)
}
// May be we were too early. Wait and retry the whole shebang.
log.Info("Retying daemon connection")
time.Sleep(2 * time.Second)
daemon.Close()
daemon, err = daemonService.Connect(ctx)
if err != nil {
return serrors.Wrap("connecting to daemon", err)
}

localIA, err = daemon.LocalIA(ctx)
if err != nil {
return serrors.Wrap("retrieving local ISD-AS", err)
}
log.Info("This time it worked")
}
controlAddress, err := net.ResolveUDPAddr("udp", globalCfg.Gateway.CtrlAddr)
if err != nil {
return serrors.Wrap("parsing control address", err)
Expand Down

0 comments on commit 3916456

Please sign in to comment.