Skip to content

Commit

Permalink
Disable xds check on bootstrap mode and change check to warn only.
Browse files Browse the repository at this point in the history
  • Loading branch information
hashi-derek committed Jan 6, 2023
1 parent f27c077 commit 0bdd70b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
8 changes: 6 additions & 2 deletions command/connect/envoy/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,12 @@ func (c *cmd) templateArgs() (*BootstrapTplArgs, error) {
return nil, err
}

if err := checkDial(xdsAddr, c.dialFunc); err != nil {
return nil, fmt.Errorf("error dialing xDS address: %w", err)
// Bootstrapping should not attempt to dial the address, since the template
// may be generated and passed to another host (Nomad is one example).
if !c.bootstrap {
if err := checkDial(xdsAddr, c.dialFunc); err != nil {
c.UI.Warn("There was an error dialing the xDS address: " + err.Error())
}
}

adminAddr, adminPort, err := net.SplitHostPort(c.adminBind)
Expand Down
22 changes: 2 additions & 20 deletions command/connect/envoy/envoy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"strconv"
"strings"
"testing"
"time"

"github.com/hashicorp/consul/agent/xds/proxysupport"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -120,9 +119,8 @@ type generateConfigTestCase struct {
Files map[string]string
ProxyConfig map[string]interface{}
NamespacesEnabled bool
XDSPorts agent.GRPCPorts // used to mock an agent's configured gRPC ports. Plaintext defaults to 8502 and TLS defaults to 8503.
AgentSelf110 bool // fake the agent API from versions v1.10 and earlier
DialFunc func(network, address string) (net.Conn, error) // defaults to a no-op function. Overwrite to test error handling.
XDSPorts agent.GRPCPorts // used to mock an agent's configured gRPC ports. Plaintext defaults to 8502 and TLS defaults to 8503.
AgentSelf110 bool // fake the agent API from versions v1.10 and earlier
WantArgs BootstrapTplArgs
WantErr string
}
Expand Down Expand Up @@ -153,14 +151,6 @@ func TestGenerateConfig(t *testing.T) {
},
WantErr: "agent has grpc disabled",
},
{
Name: "connection not available",
Flags: []string{"-proxy-id", "test-proxy"},
DialFunc: func(network, address string) (net.Conn, error) {
return net.DialTimeout(network, address, time.Second)
},
WantErr: "connection refused",
},
{
Name: "defaults",
Flags: []string{"-proxy-id", "test-proxy"},
Expand Down Expand Up @@ -1125,14 +1115,6 @@ func TestGenerateConfig(t *testing.T) {
// explicitly set the client to one which can connect to the httptest.Server
c.client = client

if tc.DialFunc != nil {
c.dialFunc = tc.DialFunc
} else {
c.dialFunc = func(_, _ string) (net.Conn, error) {
return nil, nil
}
}

// Run the command
myFlags := copyAndReplaceAll(tc.Flags, "@@TEMPDIR@@", testDirPrefix)
args := append([]string{"-bootstrap"}, myFlags...)
Expand Down

0 comments on commit 0bdd70b

Please sign in to comment.