From ceb1a5163159a69561cd6c40269f9c876bab32d5 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Mon, 14 Oct 2024 19:00:17 +0300 Subject: [PATCH] Merging to release-5.6: TT-13130 updated version of gorpc library and prevent panic on start edge (#6629) (#6638) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### **User description** TT-13130 updated version of gorpc library and prevent panic on start edge (#6629) ### **User description**
TT-13130
Summary Tyk Cloud: Panic appears when a user tried to deploy GW before Control Plane is in deployed state
Type Bug Bug
Status In Dev
Points N/A
Labels Re_open
--- ## Description Moved the logic of waitgroup to be handled internally in the gorpc library. GW only have to wait until done() ## 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, Enhancement ___ ### **Description** - Refactored the connection dialing logic in `rpc_client.go` to remove manual `sync.WaitGroup` handling, leveraging the internal wait group management provided by the `gorpc` library. - Updated the `gorpc` library to a newer version in `go.mod` and `go.sum`, ensuring compatibility and leveraging improvements. ___ ### **Changes walkthrough** 📝
Relevant files
Enhancement
rpc_client.go
Refactor connection dialing wait group handling                   

rpc/rpc_client.go
  • Removed manual handling of sync.WaitGroup for connection dialing.
  • Utilized clientSingleton.ConnectionDialingWG for managing connection
    readiness.
  • +1/-7     
    Dependencies
    go.mod
    Update gorpc library version in go.mod                                     

    go.mod - Updated `gorpc` library version to latest.
    +1/-1     
    go.sum
    Update go.sum for new gorpc version                                           

    go.sum - Updated checksums for new `gorpc` library version.
    +8/-2     
    ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information --------- Co-authored-by: sredny buitrago ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Refactored the connection dialing logic in `rpc_client.go` to remove manual `sync.WaitGroup` handling, leveraging the internal wait group management provided by the `gorpc` library. - Updated the `gorpc` library to a newer version in `go.mod` and `go.sum`, ensuring compatibility and leveraging improvements. ___ ### **Changes walkthrough** 📝
    Relevant files
    Enhancement
    rpc_client.go
    Refactor connection dialing wait group handling                   

    rpc/rpc_client.go
  • Removed manual handling of sync.WaitGroup for connection dialing.
  • Utilized clientSingleton.ConnectionDialingWG for managing connection
    readiness.
  • +1/-8     
    Dependencies
    go.mod
    Update gorpc library version in go.mod                                     

    go.mod - Updated `gorpc` library version to the latest.
    +1/-1     
    go.sum
    Update go.sum for new gorpc version                                           

    go.sum - Updated checksums for new `gorpc` library version.
    +2/-2     
    ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information --------- Co-authored-by: Sredny M Co-authored-by: sredny buitrago --- go.mod | 2 +- go.sum | 4 ++-- rpc/rpc_client.go | 9 +-------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 75fd6407821..c91cccf3ee3 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/TykTechnologies/drl v0.0.0-20231218155806-88e4363884a2 github.com/TykTechnologies/goautosocket v0.0.0-20190430121222-97bfa5e7e481 github.com/TykTechnologies/gojsonschema v0.0.0-20170222154038-dcb3e4bb7990 - github.com/TykTechnologies/gorpc v0.0.0-20210624160652-fe65bda0ccb9 + github.com/TykTechnologies/gorpc v0.0.0-20241011145745-39f660923858 github.com/TykTechnologies/goverify v0.0.0-20220808203004-1486f89e7708 github.com/TykTechnologies/graphql-go-tools v1.6.2-0.20240926103032-6eca9f4b5e30 github.com/TykTechnologies/graphql-translator v0.0.0-20240319092712-4ba87e4c06ff diff --git a/go.sum b/go.sum index f3ad398b005..8b6a7799ed7 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,8 @@ github.com/TykTechnologies/goautosocket v0.0.0-20190430121222-97bfa5e7e481 h1:fP github.com/TykTechnologies/goautosocket v0.0.0-20190430121222-97bfa5e7e481/go.mod h1:CtF8OunV123VfKa8Z9kKcIPHgcd67hSAwFMLlS7FvS4= github.com/TykTechnologies/gojsonschema v0.0.0-20170222154038-dcb3e4bb7990 h1:CJRTgg13M3vJG9S7k7kpnvDRMGMywm5OsN6eUE8VwJE= github.com/TykTechnologies/gojsonschema v0.0.0-20170222154038-dcb3e4bb7990/go.mod h1:SQT0NBrY4/pMikBgwFIrWCjcHBxg015Y8is0kAnMtug= -github.com/TykTechnologies/gorpc v0.0.0-20210624160652-fe65bda0ccb9 h1:fbxHiuw/244CQ4TEirzgL/CIMXDUx2szZn8cuuMlCy0= -github.com/TykTechnologies/gorpc v0.0.0-20210624160652-fe65bda0ccb9/go.mod h1:v6v7Mlj08+EmEcXOfpuTxGt2qYU9yhqqtv4QF9Wf50E= +github.com/TykTechnologies/gorpc v0.0.0-20241011145745-39f660923858 h1:W9bBHH3zj81xt15lnVWQfLAdAip46eL7Iyhr8yjp/0M= +github.com/TykTechnologies/gorpc v0.0.0-20241011145745-39f660923858/go.mod h1:v6v7Mlj08+EmEcXOfpuTxGt2qYU9yhqqtv4QF9Wf50E= github.com/TykTechnologies/goverify v0.0.0-20220808203004-1486f89e7708 h1:cmXjlMzcexhc/Cg+QB/c2CPUVs1ux9xn6162qaf/LC4= github.com/TykTechnologies/goverify v0.0.0-20220808203004-1486f89e7708/go.mod h1:mkS8jKcz8otdfEXhJs1QQ/DKoIY1NFFsRPKS0RwQENI= github.com/TykTechnologies/graphql-go-tools v1.6.2-0.20240926103032-6eca9f4b5e30 h1:SxmD3nMD7AyhJGcOBG4QHwslMFvwLM0e3jH1enmWxZk= diff --git a/rpc/rpc_client.go b/rpc/rpc_client.go index f1870ebe061..153a14f20b3 100644 --- a/rpc/rpc_client.go +++ b/rpc/rpc_client.go @@ -258,10 +258,6 @@ func Connect(connConfig Config, suppressRegister bool, dispatcherFuncs map[strin clientSingleton.Conns = 5 } - for i := 0; i < clientSingleton.Conns; i++ { - connectionDialingWG.Add(1) - } - clientSingleton.Dial = func(addr string) (conn net.Conn, err error) { dialer := &net.Dialer{ Timeout: 10 * time.Second, @@ -298,8 +294,6 @@ 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 } @@ -311,9 +305,8 @@ func Connect(connConfig Config, suppressRegister bool, dispatcherFuncs map[strin if funcClientSingleton == nil { funcClientSingleton = dispatcher.NewFuncClient(clientSingleton) } - // wait until all the pool connections are dialed so we can call login - connectionDialingWG.Wait() + clientSingleton.ConnectionDialingWG.Wait() handleLogin() if !suppressRegister { register()