From 29d201defd7a62d85b820b6840186799bbfb810d Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Tue, 1 Aug 2023 12:50:08 +0200 Subject: [PATCH 1/2] `slack-vitess-r14.0.5`: allow conn overrides in consul topo Signed-off-by: Tim Vaillancourt --- go/vt/topo/consultopo/server.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/go/vt/topo/consultopo/server.go b/go/vt/topo/consultopo/server.go index 8ba22bbf6d0..9f8ed9b3ad1 100644 --- a/go/vt/topo/consultopo/server.go +++ b/go/vt/topo/consultopo/server.go @@ -30,13 +30,13 @@ import ( "github.com/hashicorp/consul/api" - "vitess.io/vitess/go/vt/vterrors" - "vitess.io/vitess/go/vt/log" "vitess.io/vitess/go/vt/topo" + "vitess.io/vitess/go/vt/vterrors" ) var ( + consulConfig = api.DefaultConfig() consulAuthClientStaticFile = flag.String("consul_auth_static_file", "", "JSON File to read the topos/tokens from.") // serfHealth is the default check from consul consulLockSessionChecks = flag.String("topo_consul_lock_session_checks", "serfHealth", "List of checks for consul session.") @@ -44,6 +44,12 @@ var ( consulLockDelay = flag.Duration("topo_consul_lock_delay", 15*time.Second, "LockDelay for consul session.") ) +func init() { + flag.IntVar(&consulConfig.Transport.MaxConnsPerHost, "topo_consul_max_conns_per_host", consulConfig.Transport.MaxConnsPerHost, "Maximum number of consul connections per host.") + flag.IntVar(&consulConfig.Transport.MaxIdleConns, "topo_consul_max_idle_conns", consulConfig.Transport.MaxIdleConns, "Maximum number of idle consul connections.") + flag.DurationVar(&consulConfig.Transport.IdleConnTimeout, "topo_consul_idle_conn_timeout", consulConfig.Transport.IdleConnTimeout, "Maximum amount of time to pool idle connections.") +} + // ClientAuthCred credential to use for consul clusters type ClientAuthCred struct { // ACLToken when provided, the client will use this token when making requests to the Consul server. @@ -120,7 +126,7 @@ func NewServer(cell, serverAddr, root string) (*Server, error) { if err != nil { return nil, err } - cfg := api.DefaultConfig() + cfg := consulConfig cfg.Address = serverAddr if creds != nil { if creds[cell] != nil { From 0e823b0d33af68c17acb6b5fc6ac5a4fe8c2d4e9 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Tue, 1 Aug 2023 17:09:16 +0200 Subject: [PATCH 2/2] fix e2e test Signed-off-by: Tim Vaillancourt --- go/flags/endtoend/vtgate.txt | 6 ++++++ go/flags/endtoend/vttablet.txt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/go/flags/endtoend/vtgate.txt b/go/flags/endtoend/vtgate.txt index 42c2c2c1539..027fc7e723b 100644 --- a/go/flags/endtoend/vtgate.txt +++ b/go/flags/endtoend/vtgate.txt @@ -335,12 +335,18 @@ Usage of vtgate: wait till connected for specified tablet types during Gateway initialization --tablet_url_template string format string describing debug tablet url formatting. See the Go code for getTabletDebugURL() how to customize this. (default http://{{.GetTabletHostPort}}) + --topo_consul_idle_conn_timeout duration + Maximum amount of time to pool idle connections. (default 1m30s) --topo_consul_lock_delay duration LockDelay for consul session. (default 15s) --topo_consul_lock_session_checks string List of checks for consul session. (default serfHealth) --topo_consul_lock_session_ttl string TTL for consul session. + --topo_consul_max_conns_per_host int + Maximum number of consul connections per host. + --topo_consul_max_idle_conns int + Maximum number of idle consul connections. (default 100) --topo_consul_watch_poll_duration duration time of the long poll for watch queries. (default 30s) --topo_etcd_lease_ttl int diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index b07769420b4..ac7b5b79eed 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -847,12 +847,18 @@ Usage of vttablet: Comma separated VTTablet types to be considered by the throttler. default: 'replica'. example: 'replica,rdonly'. 'replica' aways implicitly included (default replica) --throttle_threshold duration Replication lag threshold for default lag throttling (default 1s) + --topo_consul_idle_conn_timeout duration + Maximum amount of time to pool idle connections. (default 1m30s) --topo_consul_lock_delay duration LockDelay for consul session. (default 15s) --topo_consul_lock_session_checks string List of checks for consul session. (default serfHealth) --topo_consul_lock_session_ttl string TTL for consul session. + --topo_consul_max_conns_per_host int + Maximum number of consul connections per host. + --topo_consul_max_idle_conns int + Maximum number of idle consul connections. (default 100) --topo_consul_watch_poll_duration duration time of the long poll for watch queries. (default 30s) --topo_etcd_lease_ttl int