mirror of https://github.com/hashicorp/consul
logs for debugging
parent
cbfeb6c8af
commit
cef8e3d27b
|
@ -561,6 +561,8 @@ func (c *Catalog) ListServices(args *structs.DCSpecificRequest, reply *structs.I
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Println("in list services")
|
||||
|
||||
// Supporting querying by PeerName in this API would require modifying the return type or the ACL
|
||||
// filtering logic so that it can be made aware that the data queried is coming from a peer.
|
||||
// Currently the ACL filter will receive plain name strings with no awareness of the peer name,
|
||||
|
@ -594,8 +596,10 @@ func (c *Catalog) ListServices(args *structs.DCSpecificRequest, reply *structs.I
|
|||
var err error
|
||||
var serviceNodes structs.ServiceNodes
|
||||
if len(args.NodeMetaFilters) > 0 {
|
||||
fmt.Println("in node meta filters > 0")
|
||||
reply.Index, serviceNodes, err = state.ServicesByNodeMeta(ws, args.NodeMetaFilters, &args.EnterpriseMeta, args.PeerName)
|
||||
} else {
|
||||
fmt.Println("in node meta filters == 0")
|
||||
reply.Index, serviceNodes, err = state.Services(ws, &args.EnterpriseMeta, args.PeerName)
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -1311,6 +1311,7 @@ func (s *Store) ServicesByNodeMeta(ws memdb.WatchSet, filters map[string]string,
|
|||
EnterpriseMeta: *entMeta,
|
||||
PeerName: peerName,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("failed nodes lookup: %s", err)
|
||||
}
|
||||
|
@ -1327,10 +1328,11 @@ func (s *Store) ServicesByNodeMeta(ws memdb.WatchSet, filters map[string]string,
|
|||
var result structs.ServiceNodes
|
||||
for node := nodes.Next(); node != nil; node = nodes.Next() {
|
||||
n := node.(*structs.Node)
|
||||
fmt.Println("fetched nodes = ", n.Node)
|
||||
if len(filters) > 1 && !structs.SatisfiesMetaFilters(n.Meta, filters) {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Println("after filter > 1 continue")
|
||||
// List all the services on the node
|
||||
services, err := catalogServiceListByNode(tx, n.Node, entMeta, n.PeerName, false)
|
||||
if err != nil {
|
||||
|
@ -1339,6 +1341,7 @@ func (s *Store) ServicesByNodeMeta(ws memdb.WatchSet, filters map[string]string,
|
|||
ws.AddWithLimit(watchLimit, services.WatchCh(), allServicesCh)
|
||||
|
||||
for service := services.Next(); service != nil; service = services.Next() {
|
||||
fmt.Println("got services", service.(*structs.ServiceNode).ServiceID)
|
||||
result = append(result, service.(*structs.ServiceNode))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue