summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/grpc/installappclient/client.go
diff options
context:
space:
mode:
authorRajamohan Raj <rajamohan.raj@intel.com>2020-08-19 00:32:30 +0000
committerRajamohan Raj <rajamohan.raj@intel.com>2020-08-27 22:14:23 +0000
commit49c839f48994a394ed5004e4e4446b46833c7014 (patch)
treeb0e09cbcfb3f232ad6c037ecc4a05d76605ca8ca /src/orchestrator/pkg/grpc/installappclient/client.go
parent9c942a11c14836630ba528b75bdcb2790045b91f (diff)
Remove the need for rysnc registration in orchestrator
Removed dependency of rsync registration from orchestrator.RSYNC shall have a function NewRsyncInfo to initiate a new rsync independent of the orchestrator and make gRPC calls. Issue-ID: MULTICLOUD-1196 Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com> Change-Id: I16bbac6a6865cf3c4ee7b763dac72abe2ed1ad0a
Diffstat (limited to 'src/orchestrator/pkg/grpc/installappclient/client.go')
-rw-r--r--src/orchestrator/pkg/grpc/installappclient/client.go50
1 files changed, 34 insertions, 16 deletions
diff --git a/src/orchestrator/pkg/grpc/installappclient/client.go b/src/orchestrator/pkg/grpc/installappclient/client.go
index 0e9141a6..7292ddd5 100644
--- a/src/orchestrator/pkg/grpc/installappclient/client.go
+++ b/src/orchestrator/pkg/grpc/installappclient/client.go
@@ -15,39 +15,57 @@ package installappclient
import (
"context"
+ "sync"
"time"
log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/rpc"
- "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/controller"
installpb "github.com/onap/multicloud-k8s/src/rsync/pkg/grpc/installapp"
pkgerrors "github.com/pkg/errors"
)
const rsyncName = "rsync"
+/*
+RsyncInfo consists of rsyncName, hostName and portNumber.
+*/
+type RsyncInfo struct {
+ RsyncName string
+ hostName string
+ portNumber int
+}
+
+var rsyncInfo RsyncInfo
+var mutex = &sync.Mutex{}
+
// InitRsyncClient initializes connctions to the Resource Synchronizer service
func initRsyncClient() bool {
- client := controller.NewControllerClient()
-
- vals, _ := client.GetControllers()
- found := false
- for _, v := range vals {
- if v.Metadata.Name == rsyncName {
- log.Info("Initializing RPC connection to resource synchronizer", log.Fields{
- "Controller": v.Metadata.Name,
- })
- rpc.UpdateRpcConn(v.Metadata.Name, v.Spec.Host, v.Spec.Port)
- found = true
- break
- }
+ if (RsyncInfo{}) == rsyncInfo {
+ mutex.Lock()
+ defer mutex.Unlock()
+ log.Error("RsyncInfo not set. InitRsyncClient failed", log.Fields{
+ "Rsyncname": rsyncInfo.RsyncName,
+ "Hostname": rsyncInfo.hostName,
+ "PortNumber": rsyncInfo.portNumber,
+ })
+ return false
}
- return found
+ rpc.UpdateRpcConn(rsyncInfo.RsyncName, rsyncInfo.hostName, rsyncInfo.portNumber)
+ return true
+}
+
+// NewRsyncInfo shall return a newly created RsyncInfo object
+func NewRsyncInfo(rName, h string, pN int) RsyncInfo {
+ mutex.Lock()
+ defer mutex.Unlock()
+ rsyncInfo = RsyncInfo{RsyncName: rName, hostName: h, portNumber: pN}
+ return rsyncInfo
+
}
// InvokeInstallApp will make the grpc call to the resource synchronizer
// or rsync controller.
-// rsync will deply the resources in the app context to the clusters as
+// rsync will deploy the resources in the app context to the clusters as
// prepared in the app context.
func InvokeInstallApp(appContextId string) error {
var err error