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

Use agent bundle-relative Collectd ConfigDir default #263

Merged
merged 1 commit into from
Apr 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions internal/extension/smartagentextension/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package smartagentextension

import (
"fmt"
"path/filepath"
"reflect"
"strings"

Expand Down Expand Up @@ -48,6 +49,15 @@ func customUnmarshaller(componentViperSection *viper.Viper, intoCfg interface{})
allSettings := componentViperSection.AllSettings()
extensionCfg := intoCfg.(*Config)

configDirSet := false
if collectd, ok := allSettings["collectd"]; ok {
if collectdBlock, ok := collectd.(map[string]interface{}); ok {
if _, ok := collectdBlock["configdir"]; ok {
configDirSet = true
}
}
}

config, err := smartAgentConfigFromSettingsMap(allSettings)
if err != nil {
return err
Expand All @@ -58,6 +68,10 @@ func customUnmarshaller(componentViperSection *viper.Viper, intoCfg interface{})
}
config.Collectd.BundleDir = config.BundleDir

if !configDirSet {
config.Collectd.ConfigDir = filepath.Join(config.Collectd.BundleDir, "run", "collectd")
}

extensionCfg.Config = *config
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions internal/extension/smartagentextension/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package smartagentextension

import (
"path"
"path/filepath"
"testing"
"time"

Expand Down Expand Up @@ -95,7 +96,7 @@ func TestLoadConfig(t *testing.T) {
cfg.Collectd.ReadThreads = 1
cfg.Collectd.WriteThreads = 4
cfg.Collectd.WriteQueueLimitHigh = 5
cfg.Collectd.ConfigDir = "/etc/"
cfg.Collectd.ConfigDir = "/var/run/signalfx-agent/collectd"
cfg.Collectd.BundleDir = "/opt/"
return &cfg
}(), partialSettingsConfig)
Expand Down Expand Up @@ -191,7 +192,7 @@ func defaultConfig() Config {
IntervalSeconds: 10,
WriteServerIPAddr: "127.9.8.7",
WriteServerPort: 0,
ConfigDir: "/var/run/signalfx-agent/collectd",
ConfigDir: filepath.Join(bundleDir, "run", "collectd"),
BundleDir: bundleDir,
HasGenericJMXMonitor: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extensions:
readThreads: 1
writeThreads: 4
writeQueueLimitHigh: 5
configDir: /etc/
configDir: /var/run/signalfx-agent/collectd

receivers:
nop:
Expand Down