Skip to content

Commit

Permalink
Follow-up fixes to consul connect envoy command
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris S. Kim committed Mar 6, 2023
1 parent bf501a3 commit dc7f05b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions command/connect/envoy/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strings"
"time"

"github.com/hashicorp/consul/api"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-version"
"github.com/mitchellh/cli"
Expand All @@ -22,6 +21,7 @@ import (
"github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/agent/xds"
"github.com/hashicorp/consul/agent/xds/accesslogs"
"github.com/hashicorp/consul/api"
proxyCmd "github.com/hashicorp/consul/command/connect/proxy"
"github.com/hashicorp/consul/command/flags"
"github.com/hashicorp/consul/envoyextensions/xdscommon"
Expand Down Expand Up @@ -810,8 +810,7 @@ func (c *cmd) xdsAddress() (GRPC, error) {
port, protocol, err := c.lookupXDSPort()
if err != nil {
if strings.Contains(err.Error(), "Permission denied") {
// Token did not have agent:read. Log and proceed with defaults.
c.UI.Info(fmt.Sprintf("Could not query /v1/agent/self for xDS ports: %s", err))
// Token did not have agent:read. Suppress and proceed with defaults.
} else {
// If not a permission denied error, gRPC is explicitly disabled
// or something went fatally wrong.
Expand All @@ -822,7 +821,7 @@ func (c *cmd) xdsAddress() (GRPC, error) {
// This is the dev mode default and recommended production setting if
// enabled.
port = 8502
c.UI.Info("-grpc-addr not provided and unable to discover a gRPC address for xDS. Defaulting to localhost:8502")
c.UI.Warn("-grpc-addr not provided and unable to discover a gRPC address for xDS. Defaulting to localhost:8502")
}
addr = fmt.Sprintf("%vlocalhost:%v", protocol, port)
}
Expand Down Expand Up @@ -887,7 +886,7 @@ func (c *cmd) lookupXDSPort() (int, string, error) {

var resp response
if err := mapstructure.Decode(self, &resp); err == nil {
if resp.XDS.Ports.TLS < 0 && resp.XDS.Ports.Plaintext < 0 {
if resp.XDS.Ports.TLS <= 0 && resp.XDS.Ports.Plaintext <= 0 {
return 0, "", fmt.Errorf("agent has grpc disabled")
}
if resp.XDS.Ports.TLS > 0 {
Expand Down

0 comments on commit dc7f05b

Please sign in to comment.