diff --git a/hscontrol/poll.go b/hscontrol/poll.go index dbea5bcff8f..f1002fcb48d 100644 --- a/hscontrol/poll.go +++ b/hscontrol/poll.go @@ -18,7 +18,6 @@ import ( "github.com/rs/zerolog/log" xslices "golang.org/x/exp/slices" "gorm.io/gorm" - "tailscale.com/envknob" "tailscale.com/tailcfg" ) @@ -65,12 +64,7 @@ func (h *Headscale) newMapSession( // Use a buffered channel in case a node is not fully ready // to receive a message to make sure we dont block the entire // notifier. - // 12 is arbitrarily chosen. - chanSize := 3000 - if size, ok := envknob.LookupInt("HEADSCALE_TUNING_POLL_QUEUE_SIZE"); ok { - chanSize = size - } - updateChan := make(chan types.StateUpdate, chanSize) + updateChan := make(chan types.StateUpdate, h.cfg.Tuning.NodeMapSessionBufferedChanSize) return &mapSession{ h: h, diff --git a/hscontrol/types/config.go b/hscontrol/types/config.go index 022d12799ac..4e4b9a61fea 100644 --- a/hscontrol/types/config.go +++ b/hscontrol/types/config.go @@ -69,6 +69,8 @@ type Config struct { CLI CLIConfig ACL ACLConfig + + Tuning Tuning } type SqliteConfig struct { @@ -161,6 +163,11 @@ type LogConfig struct { Level zerolog.Level } +type Tuning struct { + BatchChangeDelay time.Duration + NodeMapSessionBufferedChanSize int +} + func LoadConfig(path string, isFile bool) error { if isFile { viper.SetConfigFile(path) @@ -220,6 +227,9 @@ func LoadConfig(path string, isFile bool) error { viper.SetDefault("node_update_check_interval", "10s") + viper.SetDefault("tuning.batch_change_delay", "800ms") + viper.SetDefault("tuning.node_mapsession_buffered_chan_size", 30) + if IsCLIConfigured() { return nil } @@ -719,6 +729,12 @@ func GetHeadscaleConfig() (*Config, error) { }, Log: GetLogConfig(), + + // TODO(kradalby): Document these settings when more stable + Tuning: Tuning{ + BatchChangeDelay: viper.GetDuration("tuning.batch_change_delay"), + NodeMapSessionBufferedChanSize: viper.GetInt("tuning.node_mapsession_buffered_chan_size"), + }, }, nil }