outpost: add additional checks for websocket connection
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		@ -116,6 +116,11 @@ func (ac *APIController) startWSHandler() {
 | 
				
			|||||||
	logger := ac.logger.WithField("loop", "ws-handler")
 | 
						logger := ac.logger.WithField("loop", "ws-handler")
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
		var wsMsg websocketMessage
 | 
							var wsMsg websocketMessage
 | 
				
			||||||
 | 
							if ac.wsConn == nil {
 | 
				
			||||||
 | 
								go ac.reconnectWS()
 | 
				
			||||||
 | 
								time.Sleep(time.Second * 5)
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		err := ac.wsConn.ReadJSON(&wsMsg)
 | 
							err := ac.wsConn.ReadJSON(&wsMsg)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			ConnectionStatus.With(prometheus.Labels{
 | 
								ConnectionStatus.With(prometheus.Labels{
 | 
				
			||||||
@ -163,6 +168,11 @@ func (ac *APIController) startWSHealth() {
 | 
				
			|||||||
				"uuid":      ac.instanceUUID.String(),
 | 
									"uuid":      ac.instanceUUID.String(),
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if ac.wsConn == nil {
 | 
				
			||||||
 | 
								go ac.reconnectWS()
 | 
				
			||||||
 | 
								time.Sleep(time.Second * 5)
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		err := ac.wsConn.WriteJSON(aliveMsg)
 | 
							err := ac.wsConn.WriteJSON(aliveMsg)
 | 
				
			||||||
		ac.logger.WithField("loop", "ws-health").Trace("hello'd")
 | 
							ac.logger.WithField("loop", "ws-health").Trace("hello'd")
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
@ -158,7 +158,7 @@ class TestProviderProxyConnect(ChannelsLiveServerTestCase):
 | 
				
			|||||||
            sleep(0.5)
 | 
					            sleep(0.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        state = outpost.state
 | 
					        state = outpost.state
 | 
				
			||||||
        self.assertEqual(len(state), 1)
 | 
					        self.assertTrue(len(state) >= 1)
 | 
				
			||||||
        self.assertEqual(state[0].version, __version__)
 | 
					        self.assertEqual(state[0].version, __version__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Make sure to delete the outpost to remove the container
 | 
					        # Make sure to delete the outpost to remove the container
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user