Skip to content

Commit

Permalink
add undocumented tuning variables, they might change
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Mar 2, 2024
1 parent 854a411 commit 2228c81
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 1 addition & 7 deletions hscontrol/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions hscontrol/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type Config struct {
CLI CLIConfig

ACL ACLConfig

Tuning Tuning
}

type SqliteConfig struct {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 2228c81

Please sign in to comment.