Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Commit

Permalink
Add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham2892 committed Apr 18, 2019
1 parent 800ac16 commit bd661d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion agent/acs/handler/acs_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (acsSession *session) Start() error {
if shouldReconnectWithoutBackoff(acsError) {
// If ACS closed the connection, there's no need to backoff,
// reconnect immediately
seelog.Info("ACS Websocket connection closed for a valid reason")
seelog.Infof("ACS Websocket connection closed for a valid reason: %v", acsError)
acsSession.backoff.Reset()
sendEmptyMessageOnChannel(connectToACS)
} else {
Expand All @@ -219,6 +219,7 @@ func (acsSession *session) Start() error {
// If the context was not cancelled and we've waited for the
// wait duration without any errors, send the message to the channel
// to reconnect to ACS
seelog.Info("Done waiting; reconnecting to ACS")
sendEmptyMessageOnChannel(connectToACS)
} else {
// Wait was interrupted. We expect the session to close as canceling
Expand Down Expand Up @@ -308,6 +309,7 @@ func (acsSession *session) startACSSession(client wsclient.ClientServer) error {
seelog.Errorf("Error connecting to ACS: %v", err)
return err
}

seelog.Info("Connected to ACS endpoint")
// Start inactivity timer for closing the connection
timer := newDisconnectionTimer(client, acsSession.heartbeatTimeout(), acsSession.heartbeatJitter())
Expand Down Expand Up @@ -337,11 +339,13 @@ func (acsSession *session) startACSSession(client wsclient.ClientServer) error {
case <-acsSession.ctx.Done():
// Stop receiving and sending messages from and to ACS when
// the context received from the main function is canceled
seelog.Infof("ACS session context cancelled.")
return acsSession.ctx.Err()
case err := <-serveErr:
// Stop receiving and sending messages from and to ACS when
// client.Serve returns an error. This can happen when the
// the connection is closed by ACS or the agent
seelog.Errorf("Error serving to ACS Webserver: %v", err)
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions agent/acs/handler/acs_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func TestHandlerReconnectsOnConnectErrors(t *testing.T) {
// test to time out as the context is never cancelled
mockWsClient.EXPECT().Connect().Do(func() {
cancel()
}).MinTimes(1),
}).Return(nil).MinTimes(1),
)
acsSession := session{
containerInstanceARN: "myArn",
Expand Down Expand Up @@ -717,7 +717,7 @@ func TestHandlerReconnectsOnDiscoverPollEndpointError(t *testing.T) {
mockWsClient.EXPECT().Connect().Do(func() {
// Serve() cancels the context
cancel()
}).MinTimes(1)
}).Return(nil).MinTimes(1)

gomock.InOrder(
// DiscoverPollEndpoint returns an error on its first invocation
Expand Down

0 comments on commit bd661d0

Please sign in to comment.