Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
proxy: Maintain communication state with a heartbeat
Browse files Browse the repository at this point in the history
We are trying to disable the feature keepalive introduced by Yamux
both on the client (kata-proxy) and server (kata-agent) sides. The
reason being we don't want to get Yamux errors in case we pause the
VM. The proxy side has already been disabled and we are about to
disable it on the agent side too. Problem is, we sometimes run into
a weird issue where the communication between the proxy and the agent
hangs.

It's related to the emulated serial port created by Qemu which is not
getting out of its sleeping loop for some cases. This issue is still
under investigation, but a simple fix is to actually write more data
to the serial port to wake it up. This workaround is needed since
disabling Yamux keepalive solves several issues, particularly one
related to our long running soak tests.

That's why this commit enables a simple "keepalive" feature, except
it does not check for any error. The idea being to simply sending
something out through this serial port.

Fixes #70

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
  • Loading branch information
Sebastien Boeuf committed Jul 17, 2018
1 parent 7e2a93d commit 063d58f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions proxy.go
Expand Up @@ -47,15 +47,39 @@ var sandboxID string

var proxyLog = logrus.New()

// This function is meant to run in a go routine since it will send ping
// commands every second. It behaves as a heartbeat to maintain a proper
// communication state with the Yamux server in the agent.
func heartBeat(session *yamux.Session) {
if session == nil {
return
}

for {
if session.IsClosed() {
break
}

session.Ping()

// 1 Hz heartbeat
time.Sleep(time.Second)
}
}

func serve(servConn io.ReadWriteCloser, proto, addr string, results chan error) (net.Listener, error) {
sessionConfig := yamux.DefaultConfig()
// Disable keepAlive since we don't know how much time a container can be paused
sessionConfig.EnableKeepAlive = false
sessionConfig.ConnectionWriteTimeout = time.Second
session, err := yamux.Client(servConn, sessionConfig)
if err != nil {
return nil, err
}

// Start the heartbeat in a separate go routine
go heartBeat(session)

// serving connection
l, err := net.Listen(proto, addr)
if err != nil {
Expand Down

0 comments on commit 063d58f

Please sign in to comment.