From 09b8a06f45458ab5c83cf75ff2a3929886f120aa Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Mon, 7 Aug 2023 12:56:01 +0200 Subject: [PATCH] `slack-vitess-r14.0.5`: allow conn overrides in consul topo (#111) * `slack-vitess-r14.0.5`: allow conn overrides in consul topo Signed-off-by: Tim Vaillancourt * fix e2e test Signed-off-by: Tim Vaillancourt --------- Signed-off-by: Tim Vaillancourt --- go/flags/endtoend/vtgate.txt | 3 +++ go/flags/endtoend/vttablet.txt | 3 +++ go/vt/topo/consultopo/server.go | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/go/flags/endtoend/vtgate.txt b/go/flags/endtoend/vtgate.txt index cbbe3215fa9..9652433bf11 100644 --- a/go/flags/endtoend/vtgate.txt +++ b/go/flags/endtoend/vtgate.txt @@ -165,9 +165,12 @@ Usage of vtgate: --tablet_refresh_known_tablets Whether to reload the tablet's address/port map from topo in case they change. (default true) --tablet_types_to_wait strings Wait till connected for specified tablet types during Gateway initialization. Should be provided as a comma-separated set of tablet types. --tablet_url_template string Format string describing debug tablet url formatting. See getTabletDebugURL() for 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 Lease TTL for locks and leader election. The client will use KeepAlive to keep the lease going. (default 30) --topo_etcd_tls_ca string path to the ca to use to validate the server cert when connecting to the etcd topo server diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index ce219da65c0..0dc87f7d96c 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -302,9 +302,12 @@ Usage of vttablet: --throttle_metrics_threshold float Override default throttle threshold, respective to -throttle_metrics_query (default 1.7976931348623157e+308) --throttle_tablet_types string 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 Lease TTL for locks and leader election. The client will use KeepAlive to keep the lease going. (default 30) --topo_etcd_tls_ca string path to the ca to use to validate the server cert when connecting to the etcd topo server diff --git a/go/vt/topo/consultopo/server.go b/go/vt/topo/consultopo/server.go index 3e9192b0e46..0eeb24728fa 100644 --- a/go/vt/topo/consultopo/server.go +++ b/go/vt/topo/consultopo/server.go @@ -38,6 +38,7 @@ import ( var ( consulAuthClientStaticFile string + consulConfig = api.DefaultConfig() // serfHealth is the default check from consul consulLockSessionChecks = "serfHealth" consulLockSessionTTL string @@ -53,6 +54,9 @@ func registerServerFlags(fs *pflag.FlagSet) { fs.StringVar(&consulLockSessionChecks, "topo_consul_lock_session_checks", consulLockSessionChecks, "List of checks for consul session.") fs.StringVar(&consulLockSessionTTL, "topo_consul_lock_session_ttl", consulLockSessionTTL, "TTL for consul session.") fs.DurationVar(&consulLockDelay, "topo_consul_lock_delay", consulLockDelay, "LockDelay for consul session.") + fs.IntVar(&consulConfig.Transport.MaxConnsPerHost, "topo_consul_max_conns_per_host", consulConfig.Transport.MaxConnsPerHost, "Maximum number of consul connections per host.") + fs.IntVar(&consulConfig.Transport.MaxIdleConns, "topo_consul_max_idle_conns", consulConfig.Transport.MaxIdleConns, "Maximum number of idle consul connections.") + fs.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 @@ -131,7 +135,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 {