Fix to properly return the backend cluster on a query.
Change-Id: I18695652987db2ce8bd0004a19b7efeac53cb9b9
diff --git a/afrouter/afrouter/api.go b/afrouter/afrouter/api.go
index 8235525..7f7ba54 100644
--- a/afrouter/afrouter/api.go
+++ b/afrouter/afrouter/api.go
@@ -104,7 +104,8 @@
return b,nil
}
}
- err := errors.New(fmt.Sprintf("Backend '%s' doesn't exist", bknd))
+ err := errors.New(fmt.Sprintf("Backend '%s' doesn't exist in cluster %s",
+ bknd, c.name))
return nil, err
}
@@ -172,7 +173,6 @@
}
func (aa ArouterApi) SetConnection(ctx context.Context, in *pb.Conn) (*pb.Result, error) {
- log.Debugf("SetConnection called! %v",in);
// Navigate down tot he connection and compare IP addresses and ports if they're
// not the same then close the existing connection. If they are bothe the same
// then return an error describing the situation.
@@ -182,9 +182,12 @@
var cn * beConnection
var err error
+ log.Debugf("SetConnection called! %v",in);
+
aap := &aa
if s,err = (aap).getServer(in.Server); err != nil {
err := errors.New(fmt.Sprintf("Server '%s' doesn't exist", in.Server))
+ log.Error(err)
return &pb.Result{Success:false,Error:err.Error()}, err
}
// The cluster is usually accessed via tha router but since each
@@ -192,18 +195,22 @@
// has the cluster we're looking for rather than fully keying
// the path
if c,err = aap.getCluster(s, in.Cluster); err != nil {
+ log.Error(err)
return &pb.Result{Success:false,Error:err.Error()}, err
}
if b,err = aap.getBackend(c, in.Backend); err != nil {
+ log.Error(err)
return &pb.Result{Success:false,Error:err.Error()}, err
}
if cn,err = aap.getConnection(b, in.Connection); err != nil {
+ log.Error(err)
return &pb.Result{Success:false,Error:err.Error()}, err
}
if err = aap.updateConnection(in, cn, b); err != nil {
+ log.Error(err)
return &pb.Result{Success:false,Error:err.Error()}, err
}
diff --git a/afrouter/afrouter/binding-router.go b/afrouter/afrouter/binding-router.go
index a87481b..11e852d 100644
--- a/afrouter/afrouter/binding-router.go
+++ b/afrouter/afrouter/binding-router.go
@@ -69,7 +69,10 @@
return rtrnK,rtrnV,nil
}
-func (br BindingRouter) FindBackendCluster(string) (*backendCluster) {
+func (br BindingRouter) FindBackendCluster(becName string) (*backendCluster) {
+ if becName == br.bkndClstr.name {
+ return br.bkndClstr
+ }
return nil
}
func (br BindingRouter) ReplyHandler(v interface{}) error {
diff --git a/afrouter/afrouter/round-robin-router.go b/afrouter/afrouter/round-robin-router.go
index 4e81985..8201541 100644
--- a/afrouter/afrouter/round-robin-router.go
+++ b/afrouter/afrouter/round-robin-router.go
@@ -122,8 +122,11 @@
return rr.grpcService
}
-func (rr RoundRobinRouter) FindBackendCluster(string) (*backendCluster) {
- return rr.bkndClstr
+func (rr RoundRobinRouter) FindBackendCluster(becName string) (*backendCluster) {
+ if becName == rr.bkndClstr.name {
+ return rr.bkndClstr
+ }
+ return nil
}
func (rr RoundRobinRouter) ReplyHandler(sel interface{}) error { // This is a no-op
diff --git a/arouterd/arouterd.go b/arouterd/arouterd.go
index 0bcff08..68a7861 100644
--- a/arouterd/arouterd.go
+++ b/arouterd/arouterd.go
@@ -437,7 +437,8 @@
}
func setConnection(client pb.ConfigurationClient, cluster string, backend string, connection string, addr string, port uint64) {
- log.Debugf("Configuring backend %s : connection %s\n\n", backend, connection)
+ log.Debugf("Configuring backend %s : connection %s in cluster %s\n\n",
+ backend, connection, cluster)
cnf := &pb.Conn{Server:"grpc_command",Cluster:cluster, Backend:backend,
Connection:connection,Addr:addr,
Port:port}