From ea7b430a700a12cbde9e78acb3a993ad4257b12c Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Thu, 23 Apr 2020 12:46:35 -0700 Subject: Add gRPC framework to orchestrator Adds proto and generated go files for a healtcheck, contextupdate and installapp rpc services. Adds framework for orchestrator as an rpc client to connect to configured controllers. Issue-ID: MULTICLOUD-1019 Signed-off-by: Eric Multanen Change-Id: Ie66865789fe2146258c91e168cfb8d5933905814 --- src/orchestrator/pkg/module/controller.go | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/orchestrator/pkg/module/controller.go') diff --git a/src/orchestrator/pkg/module/controller.go b/src/orchestrator/pkg/module/controller.go index 976b8988..6827af87 100644 --- a/src/orchestrator/pkg/module/controller.go +++ b/src/orchestrator/pkg/module/controller.go @@ -20,7 +20,8 @@ import ( "encoding/json" "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db" - + log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils" + rpc "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/rpc" pkgerrors "github.com/pkg/errors" ) @@ -66,6 +67,7 @@ type ControllerManager interface { CreateController(ms Controller, mayExist bool) (Controller, error) GetController(name string) (Controller, error) GetControllers() ([]Controller, error) + InitControllers() DeleteController(name string) error } @@ -104,6 +106,9 @@ func (mc *ControllerClient) CreateController(m Controller, mayExist bool) (Contr return Controller{}, pkgerrors.Wrap(err, "Creating DB Entry") } + // send message to create/update the rpc connection + rpc.UpdateRpcConn(m.Metadata.Name, m.Spec.Host, m.Spec.Port) + return m, nil } @@ -152,15 +157,6 @@ func (mc *ControllerClient) GetControllers() ([]Controller, error) { return []Controller{}, pkgerrors.Wrap(err, "Unmarshaling Value") } - // run healthcheck - /* - err = mc.HealthCheck(microserv.Name) - if err != nil { - log.Warn("HealthCheck Failed", log.Fields{ - "Controller": microserv.Name, - }) - } - */ resp = append(resp, microserv) } @@ -178,5 +174,20 @@ func (mc *ControllerClient) DeleteController(name string) error { if err != nil { return pkgerrors.Wrap(err, "Delete Controller Entry;") } + + // send message to close rpc connection + rpc.RemoveRpcConn(name) + return nil } + +// InitControllers initializes connctions for controllers in the DB +func (mc *ControllerClient) InitControllers() { + vals, _ := mc.GetControllers() + for _, v := range vals { + log.Info("Initializing RPC connection for controller", log.Fields{ + "Controller": v.Metadata.Name, + }) + rpc.UpdateRpcConn(v.Metadata.Name, v.Spec.Host, v.Spec.Port) + } +} -- cgit 1.2.3-korg