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

Commit

Permalink
agent: use hypervisor pid as backup proxy pid for non-kata proxy cases
Browse files Browse the repository at this point in the history
Then we can check hypervisor liveness in those cases to avoid long
timeout when connecting to the agent when hypervisor is dead.

For kata-agent, we still use the kata-proxy pid for the same purpose.

Signed-off-by: Peng Tao <[email protected]>
  • Loading branch information
bergwolf committed Jul 23, 2019
1 parent 835b6e9 commit 67c401c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
17 changes: 9 additions & 8 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ func (k *kataAgent) startProxy(sandbox *Sandbox) error {

proxyParams := proxyParams{
id: sandbox.id,
hid: sandbox.hypervisor.pid(),
path: sandbox.config.ProxyConfig.Path,
agentURL: agentURL,
consoleURL: consoleURL,
Expand Down Expand Up @@ -1600,7 +1601,14 @@ func (k *kataAgent) connect() error {
return nil
}

k.Logger().WithField("url", k.state.URL).Info("New client")
if k.state.ProxyPid > 0 {
// check that proxy is running before talk with it avoiding long timeouts
if err := syscall.Kill(k.state.ProxyPid, syscall.Signal(0)); err != nil {
return errors.New("Proxy is not running")
}
}

k.Logger().WithField("url", k.state.URL).WithField("proxy", k.state.ProxyPid).Info("New client")
client, err := kataclient.NewAgentClient(k.ctx, k.state.URL, k.proxyBuiltIn)
if err != nil {
k.dead = true
Expand Down Expand Up @@ -1792,13 +1800,6 @@ func (k *kataAgent) sendReq(request interface{}) (interface{}, error) {
span.SetTag("request", request)
defer span.Finish()

if k.state.ProxyPid > 0 {
// check that proxy is running before talk with it avoiding long timeouts
if err := syscall.Kill(k.state.ProxyPid, syscall.Signal(0)); err != nil {
return nil, fmt.Errorf("Proxy is not running: %v", err)
}
}

if err := k.connect(); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/kata_builtin_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (p *kataBuiltInProxy) start(params proxyParams) (int, string, error) {
}
}

return -1, params.agentURL, nil
return params.hid, params.agentURL, nil
}

// stop is the proxy stop implementation for kata builtin proxy.
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/no_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (p *noProxy) start(params proxyParams) (int, string, error) {
return -1, "", fmt.Errorf("AgentURL cannot be empty")
}

return 0, params.agentURL, nil
return params.hid, params.agentURL, nil
}

// stop is noProxy stop implementation for proxy interface.
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/noop_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var noopProxyURL = "noopProxyURL"
// register is the proxy start implementation for testing purpose.
// It does nothing.
func (p *noopProxy) start(params proxyParams) (int, string, error) {
return 0, noopProxyURL, nil
return params.hid, noopProxyURL, nil
}

// stop is the proxy stop implementation for testing purpose.
Expand Down
1 change: 1 addition & 0 deletions virtcontainers/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type proxyParams struct {
agentURL string
consoleURL string
logger *logrus.Entry
hid int
debug bool
}

Expand Down

0 comments on commit 67c401c

Please sign in to comment.