Skip to content

Commit

Permalink
confighub registration retries
Browse files Browse the repository at this point in the history
  • Loading branch information
dvush committed Oct 30, 2024
1 parent 4e3439e commit 3c59df5
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,27 @@ func (prx *Proxy) TLSConfig() *tls.Config {
}

func (prx *Proxy) RegisterSecrets() error {
// TODO: add retries
return prx.ConfigHub.RegisterCredentials(ConfighubOrderflowProxyCredentials{
TLSCert: string(prx.PublicCertPEM),
EcdsaPubkeyAddress: prx.OrderflowSigner.Address(),
})
const maxRetries = 10
const timeBetweenRetries = time.Second * 10

retry := 0
for {
err := prx.ConfigHub.RegisterCredentials(ConfighubOrderflowProxyCredentials{
TLSCert: string(prx.PublicCertPEM),
EcdsaPubkeyAddress: prx.OrderflowSigner.Address(),
})
if err == nil {
prx.Log.Info("Credentials registered on config hub")
return nil
}

retry += 1
if retry >= maxRetries {
return err
}
prx.Log.Error("Fail to register credentials", slog.Any("error", err))
time.Sleep(timeBetweenRetries)
}
}

// RequestNewPeers updates currently available peers from the builder config hub
Expand Down

0 comments on commit 3c59df5

Please sign in to comment.