Skip to content

Commit

Permalink
Merge pull request #7898 from hashicorp/bug/update-gateways-on-config…
Browse files Browse the repository at this point in the history
…-entry-delete

Remove error from GatewayServices RPC when a service is not a gateway
  • Loading branch information
crhino authored and hashicorp-ci committed May 18, 2020
1 parent 4c9efd5 commit 6969d08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 8 additions & 1 deletion agent/consul/internal_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,15 @@ func (m *Internal) GatewayServices(args *structs.ServiceSpecificRequest, reply *
}
}

// We log a warning here to indicate that there is a potential
// misconfiguration. We explicitly do NOT return an error because this
// can occur in the course of normal operation by deleting a
// configuration entry or starting the proxy before registering the
// config entry.
if !found {
return fmt.Errorf("service %q is not a configured terminating-gateway or ingress-gateway", args.ServiceName)
m.logger.Warn("no terminating-gateway or ingress-gateway associated with this gateway",
"gateway", args.ServiceName,
)
}

index, services, err = state.GatewayServices(ws, args.ServiceName, &args.EnterpriseMeta)
Expand Down
7 changes: 5 additions & 2 deletions agent/consul/internal_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,11 @@ func TestInternal_GatewayServices_BothGateways(t *testing.T) {
}
var resp structs.IndexedGatewayServices
err := msgpackrpc.CallWithCodec(codec, "Internal.GatewayServices", &req, &resp)
assert.Error(t, err)
assert.Contains(t, err.Error(), `service "api" is not a configured terminating-gateway or ingress-gateway`)
assert.NoError(t, err)
assert.Empty(t, resp.Services)
// Ensure that the index is not zero so that a blocking query still gets the
// latest GatewayServices index
assert.NotEqual(t, 0, resp.Index)
}

func TestInternal_GatewayServices_ACLFiltering(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion agent/proxycfg/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (m *Manager) ensureProxyServiceLocked(ns *structs.NodeService, token string
}

// Set the necessary dependencies
state.logger = m.Logger
state.logger = m.Logger.With("service_id", sid.String())
state.cache = m.Cache
state.source = m.Source
state.dnsConfig = m.DNSConfig
Expand Down

0 comments on commit 6969d08

Please sign in to comment.