mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-19 15:58:25 +00:00
Merge pull request #1597 from devimc/topic/virtcontainers/ShimPrintsAgentLogs
virtcontainers: Use shim to print the agent logs if there is no proxy
This commit is contained in:
@@ -498,7 +498,7 @@ func (k *kataAgent) exec(sandbox *Sandbox, c Container, cmd types.Cmd) (*Process
|
|||||||
}
|
}
|
||||||
|
|
||||||
return prepareAndStartShim(sandbox, k.shim, c.id, req.ExecId,
|
return prepareAndStartShim(sandbox, k.shim, c.id, req.ExecId,
|
||||||
k.state.URL, cmd, []ns.NSType{}, enterNSList)
|
k.state.URL, "", cmd, []ns.NSType{}, enterNSList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) updateInterface(ifc *vcTypes.Interface) (*vcTypes.Interface, error) {
|
func (k *kataAgent) updateInterface(ifc *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
@@ -1214,8 +1214,17 @@ 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)
|
||||||
|
var consoleURL string
|
||||||
|
if sandbox.config.HypervisorConfig.UseVSock && c.GetAnnotations()[vcAnnotations.ContainerTypeKey] == string(PodSandbox) {
|
||||||
|
consoleURL, err = sandbox.hypervisor.getSandboxConsole(sandbox.id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return prepareAndStartShim(sandbox, k.shim, c.id, req.ExecId,
|
return prepareAndStartShim(sandbox, k.shim, c.id, req.ExecId,
|
||||||
k.state.URL, c.config.Cmd, createNSList, enterNSList)
|
k.state.URL, consoleURL, c.config.Cmd, createNSList, enterNSList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleEphemeralStorage handles ephemeral storages by
|
// handleEphemeralStorage handles ephemeral storages by
|
||||||
|
@@ -48,6 +48,9 @@ func (s *kataShim) start(sandbox *Sandbox, params ShimParams) (int, error) {
|
|||||||
|
|
||||||
if config.Debug {
|
if config.Debug {
|
||||||
args = append(args, "-log", "debug")
|
args = append(args, "-log", "debug")
|
||||||
|
if params.ConsoleURL != "" {
|
||||||
|
args = append(args, "-agent-logs-socket", params.ConsoleURL)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Trace {
|
if config.Trace {
|
||||||
|
@@ -38,15 +38,16 @@ var consoleFileMode = os.FileMode(0660)
|
|||||||
// ShimParams is the structure providing specific parameters needed
|
// ShimParams is the structure providing specific parameters needed
|
||||||
// for the execution of the shim binary.
|
// for the execution of the shim binary.
|
||||||
type ShimParams struct {
|
type ShimParams struct {
|
||||||
Container string
|
Container string
|
||||||
Token string
|
Token string
|
||||||
URL string
|
URL string
|
||||||
Console string
|
Console string
|
||||||
Terminal bool
|
ConsoleURL string
|
||||||
Detach bool
|
Terminal bool
|
||||||
PID int
|
Detach bool
|
||||||
CreateNS []ns.NSType
|
PID int
|
||||||
EnterNS []ns.Namespace
|
CreateNS []ns.NSType
|
||||||
|
EnterNS []ns.Namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShimConfig is the structure providing specific configuration
|
// ShimConfig is the structure providing specific configuration
|
||||||
@@ -147,7 +148,7 @@ func stopShim(pid int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareAndStartShim(sandbox *Sandbox, shim shim, cid, token, url string, cmd types.Cmd,
|
func prepareAndStartShim(sandbox *Sandbox, shim shim, cid, token, url, consoleURL string, cmd types.Cmd,
|
||||||
createNSList []ns.NSType, enterNSList []ns.Namespace) (*Process, error) {
|
createNSList []ns.NSType, enterNSList []ns.Namespace) (*Process, error) {
|
||||||
process := &Process{
|
process := &Process{
|
||||||
Token: token,
|
Token: token,
|
||||||
@@ -155,14 +156,15 @@ func prepareAndStartShim(sandbox *Sandbox, shim shim, cid, token, url string, cm
|
|||||||
}
|
}
|
||||||
|
|
||||||
shimParams := ShimParams{
|
shimParams := ShimParams{
|
||||||
Container: cid,
|
Container: cid,
|
||||||
Token: token,
|
Token: token,
|
||||||
URL: url,
|
URL: url,
|
||||||
Console: cmd.Console,
|
Console: cmd.Console,
|
||||||
Terminal: cmd.Interactive,
|
Terminal: cmd.Interactive,
|
||||||
Detach: cmd.Detach,
|
Detach: cmd.Detach,
|
||||||
CreateNS: createNSList,
|
CreateNS: createNSList,
|
||||||
EnterNS: enterNSList,
|
EnterNS: enterNSList,
|
||||||
|
ConsoleURL: consoleURL,
|
||||||
}
|
}
|
||||||
|
|
||||||
pid, err := shim.start(sandbox, shimParams)
|
pid, err := shim.start(sandbox, shimParams)
|
||||||
|
Reference in New Issue
Block a user