Skip to content

Commit 09b5bb9

Browse files
author
Julio Montes
committed
FIXME: no merge
Signed-off-by: Julio Montes <julio.montes@intel.com>
1 parent 63e1c44 commit 09b5bb9

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

virtcontainers/kata_agent.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func (k *kataAgent) exec(sandbox *Sandbox, c Container, cmd types.Cmd) (*Process
420420
}
421421

422422
return prepareAndStartShim(sandbox, k.shim, c.id, req.ExecId,
423-
k.state.URL, cmd, []ns.NSType{}, enterNSList)
423+
k.state.URL, "", cmd, []ns.NSType{}, enterNSList)
424424
}
425425

426426
func (k *kataAgent) updateInterface(ifc *vcTypes.Interface) (*vcTypes.Interface, error) {
@@ -1119,8 +1119,17 @@ func (k *kataAgent) createContainer(sandbox *Sandbox, c *Container) (p *Process,
11191119
})
11201120
}
11211121

1122+
// 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)
1123+
var consoleURL string
1124+
if sandbox.config.HypervisorConfig.UseVSock && c.GetAnnotations()[vcAnnotations.ContainerTypeKey] == string(PodSandbox) {
1125+
consoleURL, err = sandbox.hypervisor.getSandboxConsole(sandbox.id)
1126+
if err != nil {
1127+
return nil, err
1128+
}
1129+
}
1130+
11221131
return prepareAndStartShim(sandbox, k.shim, c.id, req.ExecId,
1123-
k.state.URL, c.config.Cmd, createNSList, enterNSList)
1132+
k.state.URL, consoleURL, c.config.Cmd, createNSList, enterNSList)
11241133
}
11251134

11261135
// handleEphemeralStorage handles ephemeral storages by

virtcontainers/kata_shim.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ func (s *kataShim) start(sandbox *Sandbox, params ShimParams) (int, error) {
5555

5656
if config.Debug {
5757
args = append(args, "-log", "debug")
58+
if params.ConsoleURL != "" {
59+
args = append(args, "-agent-logs-socket", params.ConsoleURL)
60+
}
5861
}
5962

6063
if config.Trace {

virtcontainers/shim.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ var consoleFileMode = os.FileMode(0660)
3838
// ShimParams is the structure providing specific parameters needed
3939
// for the execution of the shim binary.
4040
type ShimParams struct {
41-
Container string
42-
Token string
43-
URL string
44-
Console string
45-
Terminal bool
46-
Detach bool
47-
PID int
48-
CreateNS []ns.NSType
49-
EnterNS []ns.Namespace
41+
Container string
42+
Token string
43+
URL string
44+
Console string
45+
ConsoleURL string
46+
Terminal bool
47+
Detach bool
48+
PID int
49+
CreateNS []ns.NSType
50+
EnterNS []ns.Namespace
5051
}
5152

5253
// ShimConfig is the structure providing specific configuration
@@ -147,22 +148,23 @@ func stopShim(pid int) error {
147148
return nil
148149
}
149150

150-
func prepareAndStartShim(sandbox *Sandbox, shim shim, cid, token, url string, cmd types.Cmd,
151+
func prepareAndStartShim(sandbox *Sandbox, shim shim, cid, token, url, consoleURL string, cmd types.Cmd,
151152
createNSList []ns.NSType, enterNSList []ns.Namespace) (*Process, error) {
152153
process := &Process{
153154
Token: token,
154155
StartTime: time.Now().UTC(),
155156
}
156157

157158
shimParams := ShimParams{
158-
Container: cid,
159-
Token: token,
160-
URL: url,
161-
Console: cmd.Console,
162-
Terminal: cmd.Interactive,
163-
Detach: cmd.Detach,
164-
CreateNS: createNSList,
165-
EnterNS: enterNSList,
159+
Container: cid,
160+
Token: token,
161+
URL: url,
162+
Console: cmd.Console,
163+
Terminal: cmd.Interactive,
164+
Detach: cmd.Detach,
165+
CreateNS: createNSList,
166+
EnterNS: enterNSList,
167+
ConsoleURL: consoleURL,
166168
}
167169

168170
pid, err := shim.start(sandbox, shimParams)

0 commit comments

Comments
 (0)