Skip to content

Commit

Permalink
Subscriber reconnect (#4776)
Browse files Browse the repository at this point in the history
* Force infra/subscriber disconnection when is already connected

Signed-off-by: Bruno Ledesma <[email protected]>

* Force infra/subscriber disconnection when is already connected

Signed-off-by: Bruno Ledesma <[email protected]>

---------

Signed-off-by: Bruno Ledesma <[email protected]>
  • Loading branch information
ledbruno authored Aug 14, 2024
1 parent 3874a5b commit fd9cb3f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion chaoscenter/subscriber/pkg/requests/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (req *subscriberRequests) AgentConnect(infraData map[string]string) {
for {
_, message, err := c.ReadMessage()
if err != nil {
logrus.WithError(err).Fatal("Failed to read message")
logrus.WithError(err).Panic("Failed to read message")
}

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

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

func panicWhen(errorMessage string, message []byte) {
if strings.Contains(string(message), errorMessage) {
logrus.Panic("Server error: ", errorMessage)
}
}

func (req *subscriberRequests) RequestProcessor(infraData map[string]string, r types.RawData) error {
if strings.Index("kubeobject kubeobjects", strings.ToLower(r.Payload.Data.InfraConnect.Action.RequestType)) >= 0 {
KubeObjRequest := types.KubeObjRequest{
Expand Down

0 comments on commit fd9cb3f

Please sign in to comment.