This repository has been archived by the owner on Feb 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 192
A draft commit of Kata support #727
Open
lifupan
wants to merge
53
commits into
hyperhq:kata-support
Choose a base branch
from
lifupan:kata-support
base: kata-support
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
8aac0da
add kata-containers and the depended packages into vendor
lifupan 78de507
update the vendor to coordinate with kata
lifupan cfa4183
replace runv with kata-containers
lifupan 64c03ec
clean up the codes
07ed00b
gofmt for those codes
lifupan 8b8b045
using the sandbox api instead of vc api
lifupan b4e91ad
enable save/load sandbox
lifupan f20ea2c
Associate containers with sandbox
lifupan 73bcb9e
fix the issue of disassociating sandbox
lifupan 2e70857
update vendor kata-containers to the latest version
lifupan b03861a
kata_agent: fix connection race
bergwolf d637321
Share the same pid namespace in a sandbox
lifupan 086f31f
gofmt format the files
lifupan b90c98b
update vendor kata-containers/agent/protocols/grpc
lifupan 29b7d94
Set sandbox.sharePidNs to false temporarily
lifupan 57d713a
cleanup the sandbox after it exited
lifupan 5db41e2
virtcontainers: To start the kataBuiltInProxy to watch the vm console…
lifupan 43c5e34
don't store the containerconfig info into db
lifupan 970024d
Only keep the aufs testing case
lifupan 356dd86
replace vc.Sandbox with vc.VCSandbox
lifupan f2485ab
setup the kata-container runing env for test
lifupan d599637
container: fix the issue of missing Envs
lifupan dccecd9
fix the issue of stop sandbox
lifupan 73b8c47
cleanup the legacy var stoppedChan
lifupan 2fe3bfa
fix the issue of start container failed after restore pod
lifupan d421237
uprev vendor kata client
lifupan f75b33d
uprev vendor kata virtcontainers
lifupan b49cea7
Rename vendor Sirupsen to sirupsen according to upstream
lifupan f65fa51
uprev vendor intel/govmm/qemu
lifupan 978c818
fix the issue of pausing sandbox
lifupan 54c75d8
fix the issue of missing cmd from container image
lifupan d3ca391
pod: rollback the opertions once starting sandbox failed
lifupan 9f39555
container: fix the issue of wrong RuntimeName
lifupan 1ce4312
pod: fix the issue of missing execId for resize container tty
lifupan efce5ff
container: fix the issue of missing Env from container image
lifupan 335688f
exec: fix the issue of waitexec process
lifupan a5841be
integration: fix the wrong exitcode in execsignal testcase
lifupan 53bf002
decommission: do sanity check for pod.sandpox pointer
lifupan 51ac7fe
provision: add the rollback function for createsandbox failed
lifupan 81bc42b
container: don't specify the username in oci spec
lifupan 9f5d2d4
fix the issue of missing hostname
lifupan 9d2bee1
container: remove the unused ns from ocispec
lifupan 10c4087
sandbox: add the volume support for sandbox
lifupan 2814931
container: fix the issue of missing the entrypoint in cmd
lifupan 98ab211
CI: comment out some testcases which are not supported
lifupan b484c8b
container: fix the issue of using the wrong user
lifupan 35ab4dc
CI: fix the issue of missing 'ps' command in irssi:1 image
lifupan d6c68c3
container: fix the issue of missing some io contents
lifupan cb2dddf
exec: fix the issue of missing some io contents
lifupan fdf80d3
exec: fix the issue of wrong user
lifupan fe16d76
hack: fix the issue of irssi image missing ps cmd
lifupan 50c5dad
volume: remove the redundancy mount
lifupan 026a4d0
volume: fix the issue of missing readonly option
lifupan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,10 @@ import ( | |
dockertypes "github.com/docker/engine-api/types" | ||
|
||
"github.com/hyperhq/hyperd/utils" | ||
"github.com/hyperhq/runv/hypervisor" | ||
vc "github.com/kata-containers/runtime/virtcontainers" | ||
) | ||
|
||
type sandboxOp func(sb *hypervisor.Vm) error | ||
type sandboxOp func(sb *vc.Sandbox) error | ||
type stateValidator func(state PodState) bool | ||
|
||
func (p *XPod) DelayDeleteOn() bool { | ||
|
@@ -37,9 +37,9 @@ func (p *XPod) Stop(graceful int) error { | |
|
||
func (p *XPod) ForceQuit() { | ||
err := p.protectedSandboxOperation( | ||
func(sb *hypervisor.Vm) error { | ||
sb.Kill() | ||
return nil | ||
func(sb *vc.Sandbox) error { | ||
_, err := vc.StopSandbox(sb.ID()) | ||
return err | ||
}, | ||
time.Second*5, | ||
"kill pod") | ||
|
@@ -118,8 +118,8 @@ func (p *XPod) Pause() error { | |
p.statusLock.Unlock() | ||
|
||
err := p.protectedSandboxOperation( | ||
func(sb *hypervisor.Vm) error { | ||
return sb.Pause(true) | ||
func(sb *vc.Sandbox) error { | ||
return sb.Pause() | ||
}, | ||
time.Second*5, | ||
"pause pod") | ||
|
@@ -148,8 +148,8 @@ func (p *XPod) UnPause() error { | |
p.statusLock.Unlock() | ||
|
||
err := p.protectedSandboxOperation( | ||
func(sb *hypervisor.Vm) error { | ||
return sb.Pause(false) | ||
func(sb *vc.Sandbox) error { | ||
return sb.Pause() | ||
}, | ||
time.Second*5, | ||
"resume pod") | ||
|
@@ -176,8 +176,8 @@ func (p *XPod) KillContainer(id string, sig int64) error { | |
} | ||
c.setKill() | ||
return p.protectedSandboxOperation( | ||
func(sb *hypervisor.Vm) error { | ||
return sb.KillContainer(id, syscall.Signal(sig)) | ||
func(sb *vc.Sandbox) error { | ||
return vc.KillContainer(sb.ID(), id, syscall.Signal(sig), true) | ||
}, | ||
time.Second*5, | ||
fmt.Sprintf("Kill container %s with %d", id, sig)) | ||
|
@@ -307,7 +307,7 @@ func (p *XPod) RemoveContainer(id string) error { | |
// protectedSandboxOperation() protect the hypervisor operations, which may | ||
// panic or hang too long time. | ||
func (p *XPod) protectedSandboxOperation(op sandboxOp, timeout time.Duration, comment string) error { | ||
dangerousOp := func(sb *hypervisor.Vm, errChan chan<- error) { | ||
dangerousOp := func(sb *vc.Sandbox, errChan chan<- error) { | ||
defer func() { | ||
err := recover() | ||
if err != nil { | ||
|
@@ -393,13 +393,13 @@ func (p *XPod) doStopPod(graceful int) error { | |
} | ||
|
||
p.Log(INFO, "stop container success, shutdown sandbox") | ||
result := p.sandbox.Shutdown() | ||
if result.IsSuccess() { | ||
_, err = vc.StopSandbox(p.sandbox.ID()) | ||
if err == nil { | ||
p.Log(INFO, "pod is stopped") | ||
return nil | ||
} | ||
|
||
err = fmt.Errorf("failed to shuting down: %s", result.Message()) | ||
err = fmt.Errorf("failed to shuting down: %s", err) | ||
p.Log(ERROR, err) | ||
return err | ||
} | ||
|
@@ -448,13 +448,20 @@ func (p *XPod) stopContainers(cList []string, graceful int) error { | |
} | ||
future.Add(c.Id(), func() error { | ||
var toc <-chan time.Time | ||
var retch = make(chan int32) | ||
|
||
if int64(graceful) < 0 { | ||
toc = make(chan time.Time) | ||
} else { | ||
toc = time.After(waitTime) | ||
} | ||
|
||
forceKill := graceful == 0 | ||
resChan := p.sandbox.WaitProcess(true, []string{c.Id()}, -1) | ||
go func(retch chan int32, c *Container) { | ||
ret, _ := p.sandbox.WaitProcess(c.Id(), c.Id()) | ||
retch <- ret | ||
}(retch, c) | ||
|
||
c.Log(DEBUG, "now, stop container") | ||
err := c.terminate(forceKill) | ||
// TODO filter container/process can't find error | ||
|
@@ -464,20 +471,11 @@ func (p *XPod) stopContainers(cList []string, graceful int) error { | |
return err | ||
} | ||
} | ||
if resChan == nil { | ||
err := fmt.Errorf("cannot wait container %s", c.Id()) | ||
p.Log(ERROR, err) | ||
return err | ||
} | ||
|
||
for { | ||
select { | ||
case ex, ok := <-resChan: | ||
if !ok { | ||
err := fmt.Errorf("chan broken while waiting container: %s", c.Id()) | ||
p.Log(WARNING, err) | ||
return err | ||
} | ||
p.Log(DEBUG, "container %s stopped (%v)", ex.Id, ex.Code) | ||
case ret := <-retch: | ||
p.Log(DEBUG, "container %s stopped (%d)", c.Id(), ret) | ||
return nil | ||
case <-toc: | ||
if forceKill { | ||
|
@@ -493,6 +491,7 @@ func (p *XPod) stopContainers(cList []string, graceful int) error { | |
} | ||
} | ||
return nil | ||
|
||
}) | ||
} | ||
|
||
|
@@ -532,7 +531,8 @@ func (p *XPod) waitVMStop() { | |
} | ||
p.statusLock.RUnlock() | ||
|
||
_, _ = <-p.sandbox.WaitVm(-1) | ||
monitor, _ := p.sandbox.Monitor() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check for error? |
||
_ = <-monitor | ||
p.Log(INFO, "got vm exit event") | ||
p.cleanup() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should call
sb.SignalProcess()
instead. Whenever we have a sandbox pointer, we should be calling sb operations directly instead of the vc APIs.