Skip to content

Commit

Permalink
proxy: Reset the token status when a shim quits
Browse files Browse the repository at this point in the history
We close the shim connection when something bad happens:
  - We receive an error trying to write to the socket (most likely
  because the shim died or exited).
  - We have an other kind of unrecoverable error for that client (we
  don't have one right now but we will in the near future)

We now want to progress a bit on the recovery side of things. If the
shim dies, we want to allow it to reconnect and re-claim the session.
This commit does just that.

This is tested by a subsequent unit test: TestShimSendStdinAfterExeccmd

Updates: clearcontainers#4

Signed-off-by: Damien Lespiau <[email protected]>
  • Loading branch information
Damien Lespiau committed May 5, 2017
1 parent d4804a7 commit 26392a7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,17 @@ func (proxy *proxy) serveNewClient(proto *protocol, newConn net.Conn) {
newClient.infof(1, "error serving client: %v", err)
}

// The client was a shim with a session still alive. This means DisconnectShim
// hasn't been called and we're closing the connection because of an error
// (either us or the shim has closed the connection). We want to keep the
// session alive and hope a shim will reconnect claiming the same token.
if newClient.session != nil {
proxy.Lock()
info := proxy.tokenToVM[newClient.token]
info.state = tokenStateAllocated
proxy.Unlock()
}

newConn.Close()
newClient.info(1, "connection closed")
}
Expand Down

0 comments on commit 26392a7

Please sign in to comment.