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) {
|
func (s *HTTPServer) CatalogServiceNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||||
// Set default DC
|
// Set default DC
|
||||||
args := structs.ServiceNodesRequest{
|
args := structs.ServiceSpecificRequest{
|
||||||
Datacenter: s.agent.config.Datacenter,
|
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) {
|
func (s *HTTPServer) CatalogNodeServices(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||||
// Set default Datacenter
|
// Set default Datacenter
|
||||||
args := structs.NodeServicesRequest{
|
args := structs.NodeSpecificRequest{
|
||||||
Datacenter: s.agent.config.Datacenter,
|
Datacenter: s.agent.config.Datacenter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,9 @@ func TestCatalogServices(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
ServiceName: "api",
|
Service: &structs.NodeService{
|
||||||
|
Service: "api",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
var out struct{}
|
var out struct{}
|
||||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||||
|
@ -176,8 +178,10 @@ func TestCatalogServiceNodes(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
ServiceName: "api",
|
Service: &structs.NodeService{
|
||||||
ServiceTag: "a",
|
Service: "api",
|
||||||
|
Tag: "a",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
var out struct{}
|
var out struct{}
|
||||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||||
|
@ -214,8 +218,10 @@ func TestCatalogNodeServices(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
ServiceName: "api",
|
Service: &structs.NodeService{
|
||||||
ServiceTag: "a",
|
Service: "api",
|
||||||
|
Tag: "a",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
var out struct{}
|
var out struct{}
|
||||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
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
|
// Make an RPC request
|
||||||
args := structs.NodeServicesRequest{
|
args := structs.NodeSpecificRequest{
|
||||||
Datacenter: datacenter,
|
Datacenter: datacenter,
|
||||||
Node: node,
|
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 we have no address, return not found!
|
||||||
if out.Address == "" {
|
if out.Node.Address == "" {
|
||||||
resp.SetRcode(req, dns.RcodeNameError)
|
resp.SetRcode(req, dns.RcodeNameError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the IP
|
// Parse the IP
|
||||||
ip := net.ParseIP(out.Address)
|
ip := net.ParseIP(out.Node.Address)
|
||||||
if ip == nil {
|
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)
|
resp.SetRcode(req, dns.RcodeServerFailure)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ func (d *DNSServer) nodeLookup(datacenter, node string, req, resp *dns.Msg) {
|
||||||
// serviceLookup is used to handle a service query
|
// serviceLookup is used to handle a service query
|
||||||
func (d *DNSServer) serviceLookup(datacenter, service, tag string, req, resp *dns.Msg) {
|
func (d *DNSServer) serviceLookup(datacenter, service, tag string, req, resp *dns.Msg) {
|
||||||
// Make an RPC request
|
// Make an RPC request
|
||||||
args := structs.ServiceNodesRequest{
|
args := structs.ServiceSpecificRequest{
|
||||||
Datacenter: datacenter,
|
Datacenter: datacenter,
|
||||||
ServiceName: service,
|
ServiceName: service,
|
||||||
ServiceTag: tag,
|
ServiceTag: tag,
|
||||||
|
|
|
@ -122,9 +122,11 @@ func TestDNS_ServiceLookup(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
ServiceName: "db",
|
Service: &structs.NodeService{
|
||||||
ServiceTag: "master",
|
Service: "db",
|
||||||
ServicePort: 12345,
|
Tag: "master",
|
||||||
|
Port: 12345,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
var out struct{}
|
var out struct{}
|
||||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||||
|
@ -188,9 +190,11 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
ServiceName: "db",
|
Service: &structs.NodeService{
|
||||||
ServiceTag: "master",
|
Service: "db",
|
||||||
ServicePort: 12345,
|
Tag: "master",
|
||||||
|
Port: 12345,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
var out struct{}
|
var out struct{}
|
||||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||||
|
@ -201,10 +205,12 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
ServiceID: "db2",
|
Service: &structs.NodeService{
|
||||||
ServiceName: "db",
|
ID: "db2",
|
||||||
ServiceTag: "slave",
|
Service: "db",
|
||||||
ServicePort: 12345,
|
Tag: "slave",
|
||||||
|
Port: 12345,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
|
@ -214,10 +220,12 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
ServiceID: "db3",
|
Service: &structs.NodeService{
|
||||||
ServiceName: "db",
|
ID: "db3",
|
||||||
ServiceTag: "slave",
|
Service: "db",
|
||||||
ServicePort: 12346,
|
Tag: "slave",
|
||||||
|
Port: 12346,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
if err := srv.agent.RPC("Catalog.Register", args, &out); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue