Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to control remote config watch #1730

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/config-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ For more information about how to use config sources, see [Remote Config](./remo

| Config option | Required | Type | Description |
| --- | --- | --- | --- |
| `watch` | no | bool | Whether to watch config sources for changes. If this is `true` and any of the config changes (either the main agent.yaml, or remote config values), the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent. (**default:** `true`) |
| `watch` | no | bool | Whether to watch config sources for changes. If this is `true` and the main agent.yaml changes, the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent. (**default:** `true`) |
| `remoteWatch` | no | bool | Whether to watch remote config sources for changes. If this is `true` and the remote configs changes, the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent. (**default:** `true`) |
| `file` | no | [object (see below)](#file) | Configuration for other file sources |
| `zookeeper` | no | [object (see below)](#zookeeper) | Configuration for a Zookeeper remote config source |
| `etcd2` | no | [object (see below)](#etcd2) | Configuration for an Etcd 2 remote config source |
Expand Down Expand Up @@ -480,6 +481,7 @@ where applicable:
scratch:
configSources:
watch: true
remoteWatch: true
file:
pollRateSeconds: 5
zookeeper:
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func LoadConfig(ctx context.Context, configPath string) (<-chan *Config, error)

loads <- config

if configFileChanges != nil {
if configFileChanges != nil || dynamicChanges != nil {
go func() {
for {
// We can have changes either in the dynamic values or the
Expand Down
21 changes: 15 additions & 6 deletions pkg/core/config/sources/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,24 @@ import (
// SourceConfig represents configuration for various config sources that we
// support.
type SourceConfig struct {
// Whether to watch config sources for changes. If this is `true` and any
// of the config changes (either the main agent.yaml, or remote config
// values), the agent will dynamically reconfigure itself with minimal
// disruption. This is generally better than restarting the agent on
// Whether to watch config sources for changes. If this is `true` and
// the main agent.yaml changes, the agent will dynamically reconfigure
// itself with minimal disruption.
// This is generally better than restarting the agent on
// config changes since that can result in larger gaps in metric data. The
// main disadvantage of watching is slightly greater network and compute
// resource usage. This option is not itself watched for changes. If you
// change the value of this option, you must restart the agent.
Watch *bool `yaml:"watch" default:"true"`
// Whether to watch remote config sources for changes. If this is `true`
// and the remote configs changes, the agent will dynamically reconfigure
// itself with minimal disruption.
// This is generally better than restarting the agent on
// config changes since that can result in larger gaps in metric data. The
// main disadvantage of watching is slightly greater network and compute
// resource usage. This option is not itself watched for changes. If you
// change the value of this option, you must restart the agent.
RemoteWatch *bool `yaml:"remoteWatch" default:"true"`
// Configuration for other file sources
File file.Config `yaml:"file" default:"{}"`
// Configuration for a Zookeeper remote config source
Expand Down Expand Up @@ -221,7 +230,7 @@ func (dvp *DynamicValueProvider) ReadDynamicValues(configContent []byte, stop <-

cachers := make(map[string]*configSourceCacher)
for name, source := range dvp.sources {
cacher := newConfigSourceCacher(source, pathChanges, stop, *sourceConfig.Watch)
cacher := newConfigSourceCacher(source, pathChanges, stop, *sourceConfig.RemoteWatch)
cachers[name] = cacher
}

Expand All @@ -233,7 +242,7 @@ func (dvp *DynamicValueProvider) ReadDynamicValues(configContent []byte, stop <-
}

var changes chan []byte
if *sourceConfig.Watch {
if *sourceConfig.RemoteWatch {
changes = make(chan []byte)

go func() {
Expand Down
20 changes: 18 additions & 2 deletions selfdescribe.json
Original file line number Diff line number Diff line change
Expand Up @@ -57194,7 +57194,15 @@
"fields": [
{
"yamlName": "watch",
"doc": "Whether to watch config sources for changes. If this is `true` and any of the config changes (either the main agent.yaml, or remote config values), the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent.",
"doc": "Whether to watch config sources for changes. If this is `true` and the main agent.yaml changes, the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent.",
"default": true,
"required": false,
"type": "bool",
"elementKind": ""
},
{
"yamlName": "remoteWatch",
"doc": "Whether to watch remote config sources for changes. If this is `true` and the remote configs changes, the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent.",
"default": true,
"required": false,
"type": "bool",
Expand Down Expand Up @@ -58604,7 +58612,15 @@
"fields": [
{
"yamlName": "watch",
"doc": "Whether to watch config sources for changes. If this is `true` and any of the config changes (either the main agent.yaml, or remote config values), the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent.",
"doc": "Whether to watch config sources for changes. If this is `true` and the main agent.yaml changes, the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent.",
"default": true,
"required": false,
"type": "bool",
"elementKind": ""
},
{
"yamlName": "remoteWatch",
"doc": "Whether to watch remote config sources for changes. If this is `true` and the remote configs changes, the agent will dynamically reconfigure itself with minimal disruption. This is generally better than restarting the agent on config changes since that can result in larger gaps in metric data. The main disadvantage of watching is slightly greater network and compute resource usage. This option is not itself watched for changes. If you change the value of this option, you must restart the agent.",
"default": true,
"required": false,
"type": "bool",
Expand Down