diff --git a/client/allocrunner/alloc_runner_hooks.go b/client/allocrunner/alloc_runner_hooks.go index 7f3c536fe..2517ee3ae 100644 --- a/client/allocrunner/alloc_runner_hooks.go +++ b/client/allocrunner/alloc_runner_hooks.go @@ -4,7 +4,6 @@ import ( "fmt" "time" - "github.com/davecgh/go-spew/spew" multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/nomad/client/allocrunner/interfaces" clientconfig "github.com/hashicorp/nomad/client/config" @@ -113,8 +112,6 @@ func (ar *allocRunner) initRunnerHooks(config *clientconfig.Config) error { // create network configurator nc := newNetworkConfigurator(ar.Alloc(), config) - spew.Dump(config.BridgeNetworkName) - spew.Dump(config.BridgeNetworkAllocSubnet) // Create the alloc directory hook. This is run first to ensure the // directory path exists for other hooks. diff --git a/client/allocrunner/networking_bridge_linux.go b/client/allocrunner/networking_bridge_linux.go index 05126314b..ea3e69c1c 100644 --- a/client/allocrunner/networking_bridge_linux.go +++ b/client/allocrunner/networking_bridge_linux.go @@ -7,7 +7,6 @@ import ( "path/filepath" "github.com/containernetworking/cni/libcni" - "github.com/davecgh/go-spew/spew" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/plugins/drivers" ) @@ -75,8 +74,6 @@ func (b *bridgeNetworkConfigurator) Setup(alloc *structs.Allocation, spec *drive return err } - spew.Dump(netconf) - result, err := b.cniConfig.AddNetworkList(b.ctx, netconf, b.runtimeConf(alloc, spec)) if result != nil { result.Print() diff --git a/client/client.go b/client/client.go index 636ed9417..f99c2f330 100644 --- a/client/client.go +++ b/client/client.go @@ -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) @@ -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 } diff --git a/client/cni_autofetch.go b/client/cni_autofetch.go deleted file mode 100644 index 668e0ce16..000000000 --- a/client/cni_autofetch.go +++ /dev/null @@ -1,48 +0,0 @@ -package client - -import ( - "fmt" - "path/filepath" - "runtime" - - getter "github.com/hashicorp/go-getter" - hclog "github.com/hashicorp/go-hclog" -) - -const ( - nomadCNIBinDir = "cnibin" -) - -var ( - - // checksums are copied from https://github.com/containernetworking/plugins/releases - defaultCNIGetterChecksums = map[string]string{ - "linux-amd64": "sha256:e9bfc78acd3ae71be77eb8f3e890cc9078a33cc3797703b8ff2fc3077a232252", - "linux-arm": "sha256:ae6ddbd87c05a79aceb92e1c8c32d11e302f6fc55045f87f6a3ea7e0268b2fda", - "linux-arm64": "sha256:acde854e3def3c776c532ae521c19d8784534918cc56449ff16945a2909bff6d", - "windows-amd64": "sha256:a8a24e9cf93f4db92321afca3fe53bd3ccdf2b7117c403c55a5bac162d8d79cc", - } - defaultCNIPluginVersion = "0.8.1" - defaultCNIGetterSrc = fmt.Sprintf("https://github.com/containernetworking/plugins/releases/download/v%s/cni-plugins-%s-%s-v%s.tgz?checksum=%s", - defaultCNIPluginVersion, runtime.GOOS, runtime.GOARCH, defaultCNIPluginVersion, - defaultCNIGetterChecksums[runtime.GOOS+"-"+runtime.GOARCH]) -) - -// FetchCNIPlugins downloads the standard set of CNI plugins to the client's -// data directory and returns the path to be used when setting up the CNI_PATH -// environment variable. If an error occures during download, it is logged and -// an empty path is returned -func FetchCNIPlugins(logger hclog.Logger, src string, dataDir string) string { - if src == "" { - src = defaultCNIGetterSrc - } - - logger.Info("downloading CNI plugins", "url", src) - dst := filepath.Join(dataDir, nomadCNIBinDir) - if err := getter.Get(dst, src); err != nil { - logger.Warn("failed to fetch CNI plugins", "url", src, "error", err) - return "" - } - - return dst -} diff --git a/client/config/config.go b/client/config/config.go index 06bc96d4b..9bac1803a 100644 --- a/client/config/config.go +++ b/client/config/config.go @@ -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 { @@ -280,7 +268,6 @@ func DefaultConfig() *Config { DisableRemoteExec: false, BackwardsCompatibleMetrics: false, RPCHoldTimeout: 5 * time.Second, - AutoFetchCNI: false, } } diff --git a/command/agent/agent.go b/command/agent/agent.go index 0b8ce9269..f0f2cebf5 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -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 @@ -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 } diff --git a/command/agent/config.go b/command/agent/config.go index 2f8048553..fe3f74c4b 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -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 @@ -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 }