From db2b447d5d2b082bf538d5caa056a22aac2a4254 Mon Sep 17 00:00:00 2001 From: Carlos Diaz-Padron Date: Mon, 28 Sep 2015 16:45:32 -0700 Subject: [PATCH 1/3] Parse Client config Options This adds Options to the agent ClientConfig and fixes the merging logic to include Options, as defined in the docs --- command/agent/agent.go | 1 + command/agent/config.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/command/agent/agent.go b/command/agent/agent.go index c05bc0ed9..38104ddcd 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -192,6 +192,7 @@ func (a *Agent) setupClient() error { conf.AllocDir = a.config.Client.AllocDir } conf.Servers = a.config.Client.Servers + conf.Options = a.config.Client.Options // Setup the node conf.Node = new(structs.Node) diff --git a/command/agent/config.go b/command/agent/config.go index c39aa0dcb..52cd7cfa3 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -137,6 +137,12 @@ type ClientConfig struct { // NodeClass is used to group the node by class NodeClass string `hcl:"node_class"` + // Options is used for configuration of nomad internals, + // like fingerprinters and drivers. The format is: + // + // namespace.option = value + Options map[string]string `hcl:"options"` + // Metadata associated with the node Meta map[string]string `hcl:"meta"` } @@ -388,6 +394,14 @@ func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig { // Add the servers result.Servers = append(result.Servers, b.Servers...) + // Add the options map values + if result.Options == nil { + result.Options = make(map[string]string) + } + for k, v := range b.Options { + result.Options[k] = v + } + // Add the meta map values if result.Meta == nil { result.Meta = make(map[string]string) From f1147f17c90739f8056028676302e7cfdfecdf34 Mon Sep 17 00:00:00 2001 From: Carlos Diaz-Padron Date: Mon, 28 Sep 2015 16:53:04 -0700 Subject: [PATCH 2/3] Add Client config options to docs --- website/source/docs/agent/config.html.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/source/docs/agent/config.html.md b/website/source/docs/agent/config.html.md index bd34a1e50..d2948c876 100644 --- a/website/source/docs/agent/config.html.md +++ b/website/source/docs/agent/config.html.md @@ -201,6 +201,8 @@ configured on server nodes. * `node_class`: A string used to logically group client nodes by class. This can be used during job placement as a filter. This option is not required and has no default. + * `options`: This is a key/value mapping of internal configuration for clients, + such as for driver configuration. * `meta`: This is a key/value mapping of metadata pairs. This is a free-form map and can contain any string values. From 222abf114e692b5d9f01c65f55f34be053ed0e54 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Fri, 2 Oct 2015 17:02:32 -0700 Subject: [PATCH 3/3] agent: test options config --- command/agent/config_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/command/agent/config_test.go b/command/agent/config_test.go index cf5cb2127..3faac3b6b 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -36,6 +36,9 @@ func TestConfig_Merge(t *testing.T) { AllocDir: "/tmp/alloc1", NodeID: "node1", NodeClass: "class1", + Options: map[string]string{ + "foo": "bar", + }, }, Server: &ServerConfig{ Enabled: false, @@ -86,7 +89,13 @@ func TestConfig_Merge(t *testing.T) { NodeID: "node2", NodeClass: "class2", Servers: []string{"server2"}, - Meta: map[string]string{"baz": "zip"}, + Meta: map[string]string{ + "baz": "zip", + }, + Options: map[string]string{ + "foo": "bar", + "baz": "zip", + }, }, Server: &ServerConfig{ Enabled: true, @@ -345,6 +354,10 @@ func TestConfig_LoadConfigString(t *testing.T) { "foo": "bar", "baz": "zip", }, + Options: map[string]string{ + "foo": "bar", + "baz": "zip", + }, }, Server: &ServerConfig{ Enabled: true, @@ -412,6 +425,10 @@ client { foo = "bar" baz = "zip" } + options { + foo = "bar" + baz = "zip" + } } server { enabled = true