-
Notifications
You must be signed in to change notification settings - Fork 15
Make the shim wait for the process to be started before forwarding stdin and signals #49
Make the shim wait for the process to be started before forwarding stdin and signals #49
Conversation
862b9b1 to
af0fec4
Compare
1 similar comment
vm.go
Outdated
|
|
||
| var waitForExecTimeout = 30 * time.Second | ||
|
|
||
| // WaitForExec will wait until the process inside the VM is fully started. If |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/WaitForExec/WaitForProcess/
|
One comment about function comment not in sync with the function name, but other than that LGTM. |
af0fec4 to
5eb191d
Compare
|
argh, I can't merge it because the LGTM isn't at the start of the line. Grmbl (against tooling getting in the way, of course). |
vm.go
Outdated
| return nil | ||
| } | ||
|
|
||
| var waitForExecTimeout = 30 * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const? Also, should this name refer to the process (waitForProcessTimeout)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't make this one const, I override the timeout in tests. But sure will rename it.
| // smallWaitForShimTimeout overrides the default timeout for the tests | ||
| const smallWaitForShimTimeout = 20 * time.Millisecond | ||
| // smallWaitTimeout overrides the default timeout for the tests | ||
| const smallWaitTimeout = 20 * time.Millisecond |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice :)
vm.go
Outdated
| // timeout. | ||
| func (session *ioSession) WaitForProcess(shouldReset bool) error { | ||
| session.vm.infof(1, "session", | ||
| "waiting for runtime to execute the process for token %s (timeout %s)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that %s correct? Even if it is, it might look less odd if the format was specified as %v.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup that's correct (It'll call String() on any type that satisfies the Stringer interface).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went digging a bit in the go source code. %s and %v will end up doing the same thing when the argument implements the stringer interface:
- https://golang.org/src/fmt/print.go?s=5540:5590#L593
- then both will do p.fmt.fmt_s() in https://golang.org/src/fmt/print.go?s=5540:5590#L424
5eb191d to
1124a6f
Compare
|
PR updated:
|
| if newClient.session != nil { | ||
| proxy.Lock() | ||
| info := proxy.tokenToVM[newClient.token] | ||
| info.state = tokenStateAllocated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this session being kept round forever. If the shim disconnects, we should wait for a reconnection for a specific time, after which we should discard the session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vm.go
Outdated
| // tokens. Starpod isn't handled as it's not currently use to start processes | ||
| // and indicated as deprecated in the hyperstart API. | ||
| func (vm *vm) relocateHyperCommand(hyper *api.Hyper) error { | ||
| // RelocateHyperCommand will return the Session of the process in question if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The comment should refer to relocateHyperCommand.
|
PR updated:
|
ba3b9b5 to
b9948be
Compare
That's useful only in tests really at this point as the shim is written in C. But one never knows! Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
|
This needs to be rebased on top of the logrus port before merging. |
Turns out it's really useful to know when we are hitting timeouts when debugging! Updates: clearcontainers#37 Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
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 <damien.lespiau@intel.com>
As we don't queue any data in the proxy today, we need the process inside the VM to exist before we can send stdin data to it. Updates: clearcontainers#39 Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Just like:
commit 3d897a7
Author: Damien Lespiau <damien.lespiau@intel.com>
Date: Fri May 5 15:57:01 2017 +0100
proxy: Don't forward stdin data until the process is started
but for signals.
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
b9948be to
70af5ec
Compare
|
And now rebased on top of the logrus changes. |
|
@amshinde mind having another look at this one? |
A somewhat long-winded PR that should remove the need to start the shim as stopped. We finish the work to started to synchronise runtime, shim and the process inside the VM without queuing data. It can be a bit fiddly so the code is somewhat heavily documented and tested.