Skip to content

Commit

Permalink
chore: skip orchestrator info requests if service uri not set by orch…
Browse files Browse the repository at this point in the history
…estrator (#3149)

* skip orchestrator info request if orch has no service uri set

* refactor: minor comment improvements

This commit makes minor updates to comments for better clarity and consistency. No
functional code changes are included.

* refactor: simplify orch discovery skip logic

This commit refactors the orchestration skip logic by replacing the use of a new
data channel with a direct error throw.

---------

Co-authored-by: Rick Staa <[email protected]>
Co-authored-by: Rafał Leszko <[email protected]>
  • Loading branch information
3 people authored Feb 10, 2025
1 parent e7c416a commit b675d4a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions discovery/db_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (dbo *DBOrchestratorPoolCache) cacheOrchestratorStake() error {
}

resc, errc := make(chan *common.DBOrch, len(orchs)), make(chan error, len(orchs))
timeout := getOrchestratorTimeoutLoop //needs to be same or longer than GRPCConnectTimeout in server/rpc.go
timeout := getOrchestratorTimeoutLoop // Needs to be same or longer than GRPCConnectTimeout in server/rpc.go
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

Expand Down Expand Up @@ -266,7 +266,7 @@ func (dbo *DBOrchestratorPoolCache) cacheDBOrchs() error {
}

resc, errc := make(chan *common.DBOrch, len(orchs)), make(chan error, len(orchs))
timeout := getOrchestratorTimeoutLoop //needs to be same or longer than GRPCConnectTimeout in server/rpc.go
timeout := getOrchestratorTimeoutLoop // Needs to be same or longer than GRPCConnectTimeout in server/rpc.go
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

Expand All @@ -276,7 +276,11 @@ func (dbo *DBOrchestratorPoolCache) cacheDBOrchs() error {
errc <- err
return
}

// Do not connect if URI host is not set
if uri.Host == "" {
errc <- fmt.Errorf("skipping orch=%v, URI not set", dbOrch.EthereumAddr)
return
}
info, err := serverGetOrchInfo(ctx, dbo.bcast, uri, nil)
if err != nil {
errc <- err
Expand Down Expand Up @@ -328,7 +332,7 @@ func (dbo *DBOrchestratorPoolCache) cacheDBOrchs() error {
case err := <-errc:
glog.Errorln(err)
case <-ctx.Done():
glog.Info("Done fetching orch info for orchestrators, context timeout")
glog.Infof("Done fetching orch info for orchestrators, context timeout (fetched: %v out of %v)", i, numOrchs)
return nil
}
}
Expand Down

0 comments on commit b675d4a

Please sign in to comment.