Added Error field in Payload and Subscriber restart on connection failure (#1958)
This PR has the following commits: - Added Error check for graphql cluster-connect errors - Restart Subscriber on Connection Failure Signed-off-by: Soumya Ghosh Dastidar <gdsoumya@gmail.com>
This commit is contained in:
parent
2b379a9849
commit
d74c1d3898
|
|
@ -100,6 +100,7 @@ func (r *subscriptionResolver) ClusterConnect(ctx context.Context, clusterInfo m
|
|||
clusterAction := make(chan *model.ClusterAction, 1)
|
||||
verifiedCluster, err := cluster.VerifyCluster(clusterInfo)
|
||||
if err != nil {
|
||||
log.Print("VALIDATION FAILED : ", clusterInfo.ClusterID)
|
||||
return clusterAction, err
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +111,6 @@ func (r *subscriptionResolver) ClusterConnect(ctx context.Context, clusterInfo m
|
|||
}
|
||||
store.ConnectedCluster[clusterInfo.ClusterID] = clusterAction
|
||||
store.Mutex.Unlock()
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
verifiedCluster.IsActive = false
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ func ClusterConnect(clusterData map[string]string) {
|
|||
for {
|
||||
_, message, err := c.ReadMessage()
|
||||
if err != nil {
|
||||
log.Println("read:", err)
|
||||
return
|
||||
log.Fatal("SUBSCRIPTION ERROR : ", err)
|
||||
}
|
||||
var r types.RawData
|
||||
err = json.Unmarshal(message, &r)
|
||||
|
|
@ -69,6 +68,10 @@ func ClusterConnect(clusterData map[string]string) {
|
|||
if r.Type != "data" {
|
||||
continue
|
||||
}
|
||||
if r.Payload.Errors != nil {
|
||||
log.Fatal("ERROR: ", string(message))
|
||||
}
|
||||
|
||||
if strings.ToLower(r.Payload.Data.ClusterConnect.Action.RequestType) == "logs" {
|
||||
podRequest := types.PodLogRequest{
|
||||
RequestID: r.Payload.Data.ClusterConnect.ProjectID,
|
||||
|
|
@ -80,7 +83,7 @@ func ClusterConnect(clusterData map[string]string) {
|
|||
// send pod logs
|
||||
logrus.Print("LOG REQUEST ", podRequest)
|
||||
SendPodLogs(clusterData, podRequest)
|
||||
} else {
|
||||
} else if strings.Index("create update delete get", strings.ToLower(r.Payload.Data.ClusterConnect.Action.RequestType)) >= 0 {
|
||||
logrus.Print("WORKFLOW REQUEST ", r.Payload.Data.ClusterConnect.Action)
|
||||
_, err = operations.ClusterOperations(r.Payload.Data.ClusterConnect.Action.K8SManifest, r.Payload.Data.ClusterConnect.Action.RequestType)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ type RawData struct {
|
|||
}
|
||||
|
||||
type Payload struct {
|
||||
Data Data `json:"data"`
|
||||
Errors interface{} `json:"errors"`
|
||||
Data Data `json:"data"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
|
|
|
|||
Loading…
Reference in New Issue