Skip to content

Commit

Permalink
Revert CNI auto-download (#6095)
Browse files Browse the repository at this point in the history
Revert CNI auto-download
  • Loading branch information
nickethier committed Aug 8, 2019
2 parents 8c301f0 + 144fb1b commit ab1aa05
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 116 deletions.
41 changes: 0 additions & 41 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,6 @@ func NewClient(cfg *config.Config, consulCatalog consul.CatalogAPI, consulServic
c.configCopy = c.config.Copy()
c.configLock.Unlock()

// Auto download CNI binaries and configure CNI_PATH if requested.
if c.config.AutoFetchCNI {
if cniPath := FetchCNIPlugins(c.logger, c.config.AutoFetchCNIURL, c.config.AutoFetchCNIDir); cniPath != "" {
if c.config.CNIPath == "" {
c.config.CNIPath = cniPath
} else {
c.config.CNIPath = c.config.CNIPath + ":" + cniPath
}
c.logger.Debug("using new CNI Path", "cni_path", c.config.CNIPath)
}
}

fingerprintManager := NewFingerprintManager(
c.configCopy.PluginSingletonLoader, c.GetConfig, c.configCopy.Node,
c.shutdownCh, c.updateNodeFromFingerprint, c.logger)
Expand Down Expand Up @@ -568,35 +556,6 @@ func (c *Client) init() error {
}

c.logger.Info("using alloc directory", "alloc_dir", c.config.AllocDir)

// Ensure the cnibin dir exists if we have one
if c.config.AutoFetchCNIDir != "" {
if err := os.MkdirAll(c.config.AutoFetchCNIDir, 0755); err != nil {
return fmt.Errorf("failed to create directory for AutoFetchCNIDir: %s", err)
}
} else {
// Otherwise make a temp directory to use.
p, err := ioutil.TempDir("", "NomadClient")
if err != nil {
return fmt.Errorf("failed creating temporary directory for the AutoFetchCNIDir: %v", err)
}

p, err = filepath.EvalSymlinks(p)
if err != nil {
return fmt.Errorf("failed to find temporary directory for the AutoFetchCNIDir: %v", err)
}

// Change the permissions to have the execute bit
if err := os.Chmod(p, 0755); err != nil {
return fmt.Errorf("failed to change directory permissions for the AutoFetchCNIdir: %v", err)
}

c.config.AutoFetchCNIDir = p
}

if c.config.AutoFetchCNI {
c.logger.Info("using cni directory for plugin downloads", "cni_dir", c.config.AutoFetchCNIDir)
}
return nil
}

Expand Down
48 changes: 0 additions & 48 deletions client/cni_autofetch.go

This file was deleted.

13 changes: 0 additions & 13 deletions client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,6 @@ type Config struct {
// for allocations in bridge networking mode. Subnet must be in CIDR
// notation
BridgeNetworkAllocSubnet string

// AutoFetchCNI is a toggle to enable auto downloading of the CNI standard
// plugins managed by the CNI team. This defaults to false
AutoFetchCNI bool

// AutoFetchCNIURL is the go-getter URL to use when auto downloading CNI
// plugins
AutoFetchCNIURL string

// AutoFetchCNIDir is the destination dir to use when auto doanloading CNI plugins.
// This directory will be appended to the CNIPath so it is searched last
AutoFetchCNIDir string
}

func (c *Config) Copy() *Config {
Expand Down Expand Up @@ -280,7 +268,6 @@ func DefaultConfig() *Config {
DisableRemoteExec: false,
BackwardsCompatibleMetrics: false,
RPCHoldTimeout: 5 * time.Second,
AutoFetchCNI: false,
}
}

Expand Down
3 changes: 0 additions & 3 deletions command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ func convertClientConfig(agentConfig *Config) (*clientconfig.Config, error) {
if agentConfig.DataDir != "" {
conf.StateDir = filepath.Join(agentConfig.DataDir, "client")
conf.AllocDir = filepath.Join(agentConfig.DataDir, "alloc")
conf.AutoFetchCNIDir = filepath.Join(agentConfig.DataDir, "cnibin")
}
if agentConfig.Client.StateDir != "" {
conf.StateDir = agentConfig.Client.StateDir
Expand Down Expand Up @@ -543,8 +542,6 @@ func convertClientConfig(agentConfig *Config) (*clientconfig.Config, error) {
conf.CNIPath = agentConfig.Client.CNIPath
conf.BridgeNetworkName = agentConfig.Client.BridgeNetworkName
conf.BridgeNetworkAllocSubnet = agentConfig.Client.BridgeNetworkSubnet
conf.AutoFetchCNI = agentConfig.Client.AutoFetchCNIPlugins
conf.AutoFetchCNIURL = agentConfig.Client.AutoFetchCNIPluginsURL

return conf, nil
}
Expand Down
11 changes: 0 additions & 11 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,6 @@ type ClientConfig struct {
// creating allocations with bridge networking mode. This range is local to
// the host
BridgeNetworkSubnet string `hcl:"bridge_network_subnet"`

// AutoFetchCNIPlugins toggles if the Nomad client should attempt to
// automatically download a standard set of CNI plugins, typically from
// the community repo https://github.com/containernetworking/plugins/releases
AutoFetchCNIPlugins bool `hcl:"auto_fetch_cni_plugins"`

// AutoFetchCNIPluginsURL sets the source URL to be used if automatically
// downloading CNI plugins. If not set will use a known working version from
// the community repo https://github.com/containernetworking/plugins/releases
AutoFetchCNIPluginsURL string `hcl:"auto_fetch_cni_plugins_url"`
}

// ACLConfig is configuration specific to the ACL system
Expand Down Expand Up @@ -684,7 +674,6 @@ func DevConfig() *Config {
conf.Telemetry.PrometheusMetrics = true
conf.Telemetry.PublishAllocationMetrics = true
conf.Telemetry.PublishNodeMetrics = true
conf.Client.AutoFetchCNIPlugins = true

return conf
}
Expand Down

0 comments on commit ab1aa05

Please sign in to comment.