Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Move INI config parsing to common agent config util #264

Closed
wants to merge 4 commits into from

Conversation

sunhay
Copy link
Member

@sunhay sunhay commented Mar 7, 2019

There's actually more deletions then additions but the Gopkg.* changes add noise as well as moving INI configurations to separate test resource files.

This PR is dependent on: DataDog/datadog-agent#3132

Will bump datadog-agent version when thats merged.

@DataDog/burrito


func TestGetProxySettings(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole set of INI proxy tests was modified - namely there is no default proxy port anymore.

Both the trace and core agents operate without a default proxy port - not sure why we were so behind/different. I'll investigate a bit more and ask the core-agent team if our implementation has been wrong.

@sunhay sunhay requested a review from sfluor March 7, 2019 03:37

[[constraint]]
name = "github.com/DataDog/gopsutil"
revision = "c8f74f1344dd41bc49ec4d3c2377c526aaedfd20"

[[constraint]]
name = "github.com/gogo/protobuf"
revision = "d76fbc1373015ced59b43ac267f28d546b955683"
version = "~1.0.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required due to a change in datadog-agent. We'll have to test this well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way to pin this to a hard version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config/config.go Outdated Show resolved Hide resolved
if strings.HasSuffix(path, ".yaml") { // If they set a config file directly, let's try to honor that
config.Datadog.SetConfigFile(path)
}
func (a *AgentConfig) loadProcessConfig(iniPath, yamlPath string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this takes care of loading the ini config aswell should we rename the file ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to merge this all into config.go after the environment piece is done to reduce noise :)

if strings.HasSuffix(path, ".yaml") { // If they set a config file directly, let's try to honor that
config.Datadog.SetConfigFile(path)
}
func (a *AgentConfig) loadProcessConfig(iniPath, yamlPath string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a check to make sure iniPath and yamlPath are not both set, since this will behave unexpectedly in case they are. Or even accept one string and infer the type based on the extension?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior will change to prefer the YAML if both exist, similar to how the main + trace agents operate. We're going to list this as a breaking change in our release notes.

@@ -75,19 +77,33 @@ func (a *AgentConfig) loadNetworkYamlConfig(path string) error {
// Pull additional parameters from the global config file.
a.LogLevel = config.Datadog.GetString("log_level")
a.StatsdPort = config.Datadog.GetInt("dogstatsd_port")
if config.Datadog.IsSet("bind_host") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this move from somewhere, or was it left out before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was left out before. Noticed it when moving things over

@@ -169,48 +142,60 @@ func TestGetHostname(t *testing.T) {
}

func TestDDAgentMultiAPIKeys(t *testing.T) {
// if no endpoint is given but api_keys are there, match the first api_key
// with the default endpoint
config.Datadog = config.NewConfig("datadog", "DD", strings.NewReplacer(".", "_"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to do this given that NewAgentConfig will set the global config.Datadog ? Same comment on all of these tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really just want it reset after the last test, but is more of a best practice to add it to each test to ensure state is reset.

config.Datadog.AddConfigPath(yamlPath)
// If they set a config file directly, let's try to honor that
if strings.HasSuffix(yamlPath, ".yaml") {
config.Datadog.SetConfigFile(yamlPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yml is sometimes used as an extension. I see similar code was elsewhere in the agent config parsing, so I guess we're intentionally only looking for yaml

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, our yaml config example is generated with the .yaml suffix. I don't think we've run into any cases where a customer has provided .yml or another flavor

@sunhay
Copy link
Member Author

sunhay commented Mar 26, 2019

Closing this as we no longer need it (agent 5 is no longer being built anymore for updated versions)

@sunhay sunhay closed this Mar 26, 2019
@sunhay sunhay deleted the sunhay/remove-ini-config-parsing branch May 28, 2019 20:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants