sandbox: expose share sandbox pidns setting

So that we let callers decide if kata-agent should let all containers in
a sandbox share the same pid namespace.

This will be first used only by frakti. And kata cli can possibly use it
as well when cri-o and containerd-cri stop creating pause containers
and just pass the CreateSandbox CRI requests to kata.

Fixes: #426

Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
Peng Tao 2018-06-20 16:54:16 +08:00
parent c324b55255
commit 2b942524a2
2 changed files with 7 additions and 2 deletions

View File

@ -528,7 +528,7 @@ func (k *kataAgent) startSandbox(sandbox *Sandbox) error {
req := &grpc.CreateSandboxRequest{ req := &grpc.CreateSandboxRequest{
Hostname: hostname, Hostname: hostname,
Storages: storages, Storages: storages,
SandboxPidns: false, SandboxPidns: sandbox.sharePidNs,
} }
_, err = k.sendReq(req) _, err = k.sendReq(req)

View File

@ -358,6 +358,9 @@ type SandboxConfig struct {
Annotations map[string]string Annotations map[string]string
ShmSize uint64 ShmSize uint64
// SharePidNs sets all containers to share the same sandbox level pid namespace.
SharePidNs bool
} }
// valid checks that the sandbox configuration is valid. // valid checks that the sandbox configuration is valid.
@ -462,7 +465,8 @@ type Sandbox struct {
wg *sync.WaitGroup wg *sync.WaitGroup
shmSize uint64 shmSize uint64
sharePidNs bool
} }
// ID returns the sandbox identifier string. // ID returns the sandbox identifier string.
@ -743,6 +747,7 @@ func newSandbox(sandboxConfig SandboxConfig) (*Sandbox, error) {
annotationsLock: &sync.RWMutex{}, annotationsLock: &sync.RWMutex{},
wg: &sync.WaitGroup{}, wg: &sync.WaitGroup{},
shmSize: sandboxConfig.ShmSize, shmSize: sandboxConfig.ShmSize,
sharePidNs: sandboxConfig.SharePidNs,
} }
if err = globalSandboxList.addSandbox(s); err != nil { if err = globalSandboxList.addSandbox(s); err != nil {