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

Commit

Permalink
agent: fix agent debug console
Browse files Browse the repository at this point in the history
We should not let shim or proxy read guest console socket if
agent debug console is set. Otherwise when we connect to it with
socat, it reads nothing since all output is read by the shim.

Fixes: #1700
Signed-off-by: Peng Tao <[email protected]>
  • Loading branch information
bergwolf committed May 18, 2019
1 parent 90539ac commit 7381cd5
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,10 @@ func (k *kataAgent) startProxy(sandbox *Sandbox) error {
agentURL: agentURL,
consoleURL: consoleURL,
logger: k.Logger().WithField("sandbox", sandbox.id),
debug: sandbox.config.ProxyConfig.Debug,
// Disable debug so proxy doesn't read console if we want to
// debug the agent console ourselves.
debug: sandbox.config.ProxyConfig.Debug &&
!k.hasAgentDebugConsole(sandbox),
}

// Start the proxy here
Expand Down Expand Up @@ -1111,6 +1114,16 @@ func (k *kataAgent) buildContainerRootfs(sandbox *Sandbox, c *Container, rootPat
return nil, nil
}

func (k *kataAgent) hasAgentDebugConsole(sandbox *Sandbox) bool {
for _, p := range sandbox.config.HypervisorConfig.KernelParams {
if p.Key == "agent.debug_console" {
k.Logger().Info("agent has debug console")
return true
}
}
return false
}

func (k *kataAgent) createContainer(sandbox *Sandbox, c *Container) (p *Process, err error) {
span, _ := k.trace("createContainer")
defer span.Finish()
Expand Down Expand Up @@ -1230,8 +1243,11 @@ func (k *kataAgent) createContainer(sandbox *Sandbox, c *Container) (p *Process,
}

// Ask to the shim to print the agent logs, if it's the process who monitors the sandbox and use_vsock is true (no proxy)
// Don't read the console socket if agent debug console is enabled.
var consoleURL string
if sandbox.config.HypervisorConfig.UseVSock && c.GetAnnotations()[vcAnnotations.ContainerTypeKey] == string(PodSandbox) {
if sandbox.config.HypervisorConfig.UseVSock &&
c.GetAnnotations()[vcAnnotations.ContainerTypeKey] == string(PodSandbox) &&
!k.hasAgentDebugConsole(sandbox) {
consoleURL, err = sandbox.hypervisor.getSandboxConsole(sandbox.id)
if err != nil {
return nil, err
Expand Down

0 comments on commit 7381cd5

Please sign in to comment.