From 0db2d7f0ce49cb21d3270ad0075697de42e77a0b Mon Sep 17 00:00:00 2001 From: "Sredny M." Date: Mon, 23 Sep 2024 12:54:12 -0300 Subject: [PATCH] TT-13130 only mark the wg as done when the connection is stablished (#6574) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### **User description** ## Description When the gw is ran as edge we want this to wait until the connection is established with MDCB before attempting to pull policies and apis, we should only mark the connection waitgroup as done when the connection is successful not on every attempt ## Related Issue TT-13130 ## Motivation and Context ## How This Has Been Tested ## Screenshots (if appropriate) ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** Bug fix ___ ### **Description** - Fixed the logic in `rpc_client.go` to ensure the waitgroup is marked as done only when a connection is successfully established. - Removed the `Done()` call from the defer statement and added it after the connection is confirmed. ___ ### **Changes walkthrough** 📝
Relevant files
Bug fix
rpc_client.go
Fix waitgroup completion logic in connection establishment

rpc/rpc_client.go
  • Removed the Done() call from the defer statement in the Dial function.
  • Added Done() call after the connection is successfully established.
  • Ensures the waitgroup is marked as done only upon successful
    connection.
  • +2/-1     
    ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information Co-authored-by: sredny buitrago (cherry picked from commit 5c1f1498888e0275526da044423e3e5ae2370976) --- rpc/rpc_client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpc/rpc_client.go b/rpc/rpc_client.go index afc8a3c6c63..f1870ebe061 100644 --- a/rpc/rpc_client.go +++ b/rpc/rpc_client.go @@ -263,7 +263,6 @@ func Connect(connConfig Config, suppressRegister bool, dispatcherFuncs map[strin } clientSingleton.Dial = func(addr string) (conn net.Conn, err error) { - defer connectionDialingWG.Done() dialer := &net.Dialer{ Timeout: 10 * time.Second, KeepAlive: 30 * time.Second, @@ -299,6 +298,8 @@ func Connect(connConfig Config, suppressRegister bool, dispatcherFuncs map[strin conn.Write([]byte("proto2")) conn.Write([]byte{byte(len(connID))}) conn.Write([]byte(connID)) + // only mark as done is connection is established + connectionDialingWG.Done() return conn, nil }