diff --git a/command/agent/catalog_endpoint.go b/command/agent/catalog_endpoint.go index f7454e12ae..2e86e362a7 100644 --- a/command/agent/catalog_endpoint.go +++ b/command/agent/catalog_endpoint.go @@ -91,7 +91,7 @@ func (s *HTTPServer) CatalogServices(resp http.ResponseWriter, req *http.Request func (s *HTTPServer) CatalogServiceNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error) { // Set default DC - args := structs.ServiceNodesRequest{ + args := structs.ServiceSpecificRequest{ Datacenter: s.agent.config.Datacenter, } @@ -125,7 +125,7 @@ func (s *HTTPServer) CatalogServiceNodes(resp http.ResponseWriter, req *http.Req func (s *HTTPServer) CatalogNodeServices(resp http.ResponseWriter, req *http.Request) (interface{}, error) { // Set default Datacenter - args := structs.NodeServicesRequest{ + args := structs.NodeSpecificRequest{ Datacenter: s.agent.config.Datacenter, } diff --git a/command/agent/catalog_endpoint_test.go b/command/agent/catalog_endpoint_test.go index 574253575e..121edd0ba5 100644 --- a/command/agent/catalog_endpoint_test.go +++ b/command/agent/catalog_endpoint_test.go @@ -136,10 +136,12 @@ func TestCatalogServices(t *testing.T) { // Register node args := &structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - ServiceName: "api", + Datacenter: "dc1", + Node: "foo", + Address: "127.0.0.1", + Service: &structs.NodeService{ + Service: "api", + }, } var out struct{} if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil { @@ -173,11 +175,13 @@ func TestCatalogServiceNodes(t *testing.T) { // Register node args := &structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - ServiceName: "api", - ServiceTag: "a", + Datacenter: "dc1", + Node: "foo", + Address: "127.0.0.1", + Service: &structs.NodeService{ + Service: "api", + Tag: "a", + }, } var out struct{} if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil { @@ -211,11 +215,13 @@ func TestCatalogNodeServices(t *testing.T) { // Register node args := &structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - ServiceName: "api", - ServiceTag: "a", + Datacenter: "dc1", + Node: "foo", + Address: "127.0.0.1", + Service: &structs.NodeService{ + Service: "api", + Tag: "a", + }, } var out struct{} if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil { diff --git a/command/agent/dns.go b/command/agent/dns.go index 01f73f08eb..a4b0486b56 100644 --- a/command/agent/dns.go +++ b/command/agent/dns.go @@ -253,7 +253,7 @@ func (d *DNSServer) nodeLookup(datacenter, node string, req, resp *dns.Msg) { } // Make an RPC request - args := structs.NodeServicesRequest{ + args := structs.NodeSpecificRequest{ Datacenter: datacenter, Node: node, } @@ -265,15 +265,15 @@ func (d *DNSServer) nodeLookup(datacenter, node string, req, resp *dns.Msg) { } // If we have no address, return not found! - if out.Address == "" { + if out.Node.Address == "" { resp.SetRcode(req, dns.RcodeNameError) return } // Parse the IP - ip := net.ParseIP(out.Address) + ip := net.ParseIP(out.Node.Address) if ip == nil { - d.logger.Printf("[ERR] dns: failed to parse IP %v for %v", out.Address, node) + d.logger.Printf("[ERR] dns: failed to parse IP %v", out.Node) resp.SetRcode(req, dns.RcodeServerFailure) return } @@ -296,7 +296,7 @@ func (d *DNSServer) nodeLookup(datacenter, node string, req, resp *dns.Msg) { // serviceLookup is used to handle a service query func (d *DNSServer) serviceLookup(datacenter, service, tag string, req, resp *dns.Msg) { // Make an RPC request - args := structs.ServiceNodesRequest{ + args := structs.ServiceSpecificRequest{ Datacenter: datacenter, ServiceName: service, ServiceTag: tag, diff --git a/command/agent/dns_test.go b/command/agent/dns_test.go index 19b893e4b7..e74babad16 100644 --- a/command/agent/dns_test.go +++ b/command/agent/dns_test.go @@ -119,12 +119,14 @@ func TestDNS_ServiceLookup(t *testing.T) { // Register node args := &structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - ServiceName: "db", - ServiceTag: "master", - ServicePort: 12345, + Datacenter: "dc1", + Node: "foo", + Address: "127.0.0.1", + Service: &structs.NodeService{ + Service: "db", + Tag: "master", + Port: 12345, + }, } var out struct{} if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil { @@ -185,12 +187,14 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) { // Register node args := &structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - ServiceName: "db", - ServiceTag: "master", - ServicePort: 12345, + Datacenter: "dc1", + Node: "foo", + Address: "127.0.0.1", + Service: &structs.NodeService{ + Service: "db", + Tag: "master", + Port: 12345, + }, } var out struct{} if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil { @@ -198,26 +202,30 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) { } args = &structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - ServiceID: "db2", - ServiceName: "db", - ServiceTag: "slave", - ServicePort: 12345, + Datacenter: "dc1", + Node: "foo", + Address: "127.0.0.1", + Service: &structs.NodeService{ + ID: "db2", + Service: "db", + Tag: "slave", + Port: 12345, + }, } if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil { t.Fatalf("err: %v", err) } args = &structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - ServiceID: "db3", - ServiceName: "db", - ServiceTag: "slave", - ServicePort: 12346, + Datacenter: "dc1", + Node: "foo", + Address: "127.0.0.1", + Service: &structs.NodeService{ + ID: "db3", + Service: "db", + Tag: "slave", + Port: 12346, + }, } if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil { t.Fatalf("err: %v", err)