Skip to content

Commit fd9cb3f

Browse files
authored
Subscriber reconnect (#4776)
* Force infra/subscriber disconnection when is already connected Signed-off-by: Bruno Ledesma <led.bruno@gmail.com> * Force infra/subscriber disconnection when is already connected Signed-off-by: Bruno Ledesma <led.bruno@gmail.com> --------- Signed-off-by: Bruno Ledesma <led.bruno@gmail.com>
1 parent 3874a5b commit fd9cb3f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

chaoscenter/graphql/server/graph/chaos_infrastructure.resolvers.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chaoscenter/subscriber/pkg/requests/webhook.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (req *subscriberRequests) AgentConnect(infraData map[string]string) {
6969
for {
7070
_, message, err := c.ReadMessage()
7171
if err != nil {
72-
logrus.WithError(err).Fatal("Failed to read message")
72+
logrus.WithError(err).Panic("Failed to read message")
7373
}
7474

7575
var r types.RawData
@@ -87,6 +87,7 @@ func (req *subscriberRequests) AgentConnect(infraData map[string]string) {
8787
}
8888
if r.Payload.Errors != nil {
8989
logrus.Error("Error response from the server : ", string(message))
90+
panicWhen("ALREADY CONNECTED", message)
9091
continue
9192
}
9293

@@ -97,6 +98,12 @@ func (req *subscriberRequests) AgentConnect(infraData map[string]string) {
9798
}
9899
}
99100

101+
func panicWhen(errorMessage string, message []byte) {
102+
if strings.Contains(string(message), errorMessage) {
103+
logrus.Panic("Server error: ", errorMessage)
104+
}
105+
}
106+
100107
func (req *subscriberRequests) RequestProcessor(infraData map[string]string, r types.RawData) error {
101108
if strings.Index("kubeobject kubeobjects", strings.ToLower(r.Payload.Data.InfraConnect.Action.RequestType)) >= 0 {
102109
KubeObjRequest := types.KubeObjRequest{

0 commit comments

Comments
 (0)