Skip to content

Commit

Permalink
Honor CNI and bridge related fields
Browse files Browse the repository at this point in the history
Nomad agent may silently ignore cni_path and bridge setting, when it
merges configs from multiple files (or against default/dev config).

This PR ensures that the values are merged properly.
  • Loading branch information
Mahmood Ali committed Feb 28, 2020
1 parent 4b806b1 commit 56e8ee1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ type ClientConfig struct {
// available to jobs running on this node.
HostVolumes []*structs.ClientHostVolumeConfig `hcl:"host_volume"`

// ExtraKeysHCL is used by hcl to surface unexpected keys
ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`

// CNIPath is the path to search for CNI plugins, multiple paths can be
// specified colon delimited
CNIPath string `hcl:"cni_path"`
Expand All @@ -285,6 +282,9 @@ type ClientConfig struct {
// creating allocations with bridge networking mode. This range is local to
// the host
BridgeNetworkSubnet string `hcl:"bridge_network_subnet"`

// ExtraKeysHCL is used by hcl to surface unexpected keys
ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

// ClientTemplateConfig is configuration on the client specific to template
Expand Down Expand Up @@ -1480,6 +1480,16 @@ func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig {
result.HostVolumes = structs.HostVolumeSliceMerge(a.HostVolumes, b.HostVolumes)
}

if b.CNIPath != "" {
result.CNIPath = b.CNIPath
}
if b.BridgeNetworkName != "" {
result.BridgeNetworkName = b.BridgeNetworkName
}
if b.BridgeNetworkSubnet != "" {
result.BridgeNetworkSubnet = b.BridgeNetworkSubnet
}

return &result
}

Expand Down

0 comments on commit 56e8ee1

Please sign in to comment.