Updating agent to deal with new API
This commit is contained in:
parent
f410802055
commit
c4af4b7bda
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,9 @@ func TestCatalogServices(t *testing.T) {
|
|||
Datacenter: "dc1",
|
||||
Node: "foo",
|
||||
Address: "127.0.0.1",
|
||||
ServiceName: "api",
|
||||
Service: &structs.NodeService{
|
||||
Service: "api",
|
||||
},
|
||||
}
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
|
@ -176,8 +178,10 @@ func TestCatalogServiceNodes(t *testing.T) {
|
|||
Datacenter: "dc1",
|
||||
Node: "foo",
|
||||
Address: "127.0.0.1",
|
||||
ServiceName: "api",
|
||||
ServiceTag: "a",
|
||||
Service: &structs.NodeService{
|
||||
Service: "api",
|
||||
Tag: "a",
|
||||
},
|
||||
}
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
|
@ -214,8 +218,10 @@ func TestCatalogNodeServices(t *testing.T) {
|
|||
Datacenter: "dc1",
|
||||
Node: "foo",
|
||||
Address: "127.0.0.1",
|
||||
ServiceName: "api",
|
||||
ServiceTag: "a",
|
||||
Service: &structs.NodeService{
|
||||
Service: "api",
|
||||
Tag: "a",
|
||||
},
|
||||
}
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -122,9 +122,11 @@ func TestDNS_ServiceLookup(t *testing.T) {
|
|||
Datacenter: "dc1",
|
||||
Node: "foo",
|
||||
Address: "127.0.0.1",
|
||||
ServiceName: "db",
|
||||
ServiceTag: "master",
|
||||
ServicePort: 12345,
|
||||
Service: &structs.NodeService{
|
||||
Service: "db",
|
||||
Tag: "master",
|
||||
Port: 12345,
|
||||
},
|
||||
}
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
|
@ -188,9 +190,11 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
|||
Datacenter: "dc1",
|
||||
Node: "foo",
|
||||
Address: "127.0.0.1",
|
||||
ServiceName: "db",
|
||||
ServiceTag: "master",
|
||||
ServicePort: 12345,
|
||||
Service: &structs.NodeService{
|
||||
Service: "db",
|
||||
Tag: "master",
|
||||
Port: 12345,
|
||||
},
|
||||
}
|
||||
var out struct{}
|
||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||
|
@ -201,10 +205,12 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
|||
Datacenter: "dc1",
|
||||
Node: "foo",
|
||||
Address: "127.0.0.1",
|
||||
ServiceID: "db2",
|
||||
ServiceName: "db",
|
||||
ServiceTag: "slave",
|
||||
ServicePort: 12345,
|
||||
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)
|
||||
|
@ -214,10 +220,12 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
|||
Datacenter: "dc1",
|
||||
Node: "foo",
|
||||
Address: "127.0.0.1",
|
||||
ServiceID: "db3",
|
||||
ServiceName: "db",
|
||||
ServiceTag: "slave",
|
||||
ServicePort: 12346,
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue