From 3c59df588f89d5db6ae2ea373e7d101a468f346d Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Wed, 30 Oct 2024 14:56:56 +0100 Subject: [PATCH] confighub registration retries --- proxy/proxy.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 4090c6f..0eb88e4 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -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