-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Support env overrides for all inputs of the same type #6334
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,8 @@ bind-address = ":2010" | |
[[udp]] | ||
bind-address = ":4444" | ||
|
||
[[udp]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be possible to set the second UDP listener with environment variables without needing an empty section here? I think that most people who would use environment variables to configure InfluxDB probably wouldn't use a configuration file, otherwise they would just use the configuration file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Environment variable overrides are applied by walking through the config struct to look for matching environment variable names. Since only one listener is added to the config for each section by default, multiple listeners are not possible with environment variables alone. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allowing configuration of multiple listeners through env var overrides would require more substantial changes to |
||
|
||
[monitoring] | ||
enabled = true | ||
|
||
|
@@ -154,6 +156,10 @@ enabled = true | |
t.Fatalf("failed to set env var: %v", err) | ||
} | ||
|
||
if err := os.Setenv("INFLUXDB_UDP_0_BIND_ADDRESS", ":5555"); err != nil { | ||
t.Fatalf("failed to set env var: %v", err) | ||
} | ||
|
||
if err := os.Setenv("INFLUXDB_GRAPHITE_1_PROTOCOL", "udp"); err != nil { | ||
t.Fatalf("failed to set env var: %v", err) | ||
} | ||
|
@@ -170,10 +176,14 @@ enabled = true | |
t.Fatalf("failed to apply env overrides: %v", err) | ||
} | ||
|
||
if c.UDPInputs[0].BindAddress != ":4444" { | ||
if c.UDPInputs[0].BindAddress != ":5555" { | ||
t.Fatalf("unexpected udp bind address: %s", c.UDPInputs[0].BindAddress) | ||
} | ||
|
||
if c.UDPInputs[1].BindAddress != ":1234" { | ||
t.Fatalf("unexpected udp bind address: %s", c.UDPInputs[1].BindAddress) | ||
} | ||
|
||
if c.GraphiteInputs[1].Protocol != "udp" { | ||
t.Fatalf("unexpected graphite protocol: %s", c.GraphiteInputs[1].Protocol) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code specifically seems to be wrong. This code is confusing so I'm not certain, but I think this would allow me to say
INFLUXDB_0_BIND_ADDRESS
to set all of the bind addresses in every section where that applies. If I'm reading this right, the unit test you have should work with the original code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit test doesn't work with the current code because inputs which allow multiple listeners don't get matched to environment variables like
INFLUXDB_UDP_BIND_ADDRESS
, onlyINFLUXDB_UDP_[i]_BIND_ADDRESS
. This change allows both to be used to override the bind address for a section and only applies to sections which allow multiple instances, which are all input sections (UDP, graphite, etc).Not sure how this would match a
INFLUXDB_0_BIND_ADDRESS
env var to all bind addresses. Maybe I'm missing something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think I misunderstood the
f.Index(i)
code. I thought that was an integer index that got returned.