Skip to content

Commit b3f1d7f

Browse files
committed
set up cli config parsing
1 parent 1bd1751 commit b3f1d7f

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

command/agent/agent.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,9 @@ func convertClientConfig(agentConfig *Config) (*clientconfig.Config, error) {
777777
if agentConfig.Client.NetworkInterface != "" {
778778
conf.NetworkInterface = agentConfig.Client.NetworkInterface
779779
}
780+
if agentConfig.Client.NodeMaxAllocs != 0 {
781+
conf.NodeMaxAllocs = &structs.NodeMaxAllocs{MaxAllocs: agentConfig.Client.NodeMaxAllocs}
782+
}
780783

781784
// handle rpc yamux configuration
782785
conf.RPCSessionConfig = yamux.DefaultConfig()

command/agent/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@ type ClientConfig struct {
414414

415415
// ExtraKeysHCL is used by hcl to surface unexpected keys
416416
ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
417+
418+
// NodeMaxAllocs sets the maximum number of allocations per node
419+
// Defaults to 0 and ignored if unset.
420+
NodeMaxAllocs int `hcl:"node_max_allocs"`
417421
}
418422

419423
func (c *ClientConfig) Copy() *ClientConfig {

command/agent/config_parse_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,10 @@ var sample0 = &Config{
693693
RPC: "host.example.com",
694694
Serf: "host.example.com",
695695
},
696-
Client: &ClientConfig{ServerJoin: &ServerJoin{}},
696+
Client: &ClientConfig{
697+
ServerJoin: &ServerJoin{},
698+
NodeMaxAllocs: 5,
699+
},
697700
Server: &ServerConfig{
698701
Enabled: true,
699702
BootstrapExpect: 3,

command/agent/testdata/sample0.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
"client_auto_join": false,
4646
"token": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
4747
},
48+
"client": {
49+
"node_max_allocs": 5
50+
},
4851
"data_dir": "/opt/data/nomad/data",
4952
"datacenter": "dc1",
5053
"enable_syslog": true,

0 commit comments

Comments
 (0)