Handle OOM event.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-06-23 00:29:30 +00:00
parent f33514afdb
commit a2f6f7f128
3 changed files with 30 additions and 7 deletions

View File

@@ -100,13 +100,11 @@ func TestHandleEvent(t *testing.T) {
containerdErr: fmt.Errorf("random error"),
expected: &testMetadata,
},
"should not update state for non-exited events": {
"should not update state for irrelevant events": {
event: &task.Event{
ID: testID,
Type: task.Event_OOM,
Pid: testPid,
ExitStatus: 1,
ExitedAt: testExitedAt,
ID: testID,
Type: task.Event_PAUSED,
Pid: testPid,
},
metadata: &testMetadata,
containerdContainer: &testContainerdContainer,
@@ -123,6 +121,22 @@ func TestHandleEvent(t *testing.T) {
containerdContainer: &testContainerdContainer,
expected: &testFinishedMetadata,
},
"should update exit reason when container is oom killed": {
event: &task.Event{
ID: testID,
Type: task.Event_OOM,
},
metadata: &testMetadata,
expected: &metadata.ContainerMetadata{
ID: testID,
Name: "test-name",
SandboxID: "test-sandbox-id",
Pid: testPid,
CreatedAt: testCreatedAt,
StartedAt: testStartedAt,
Reason: oomExitReason,
},
},
} {
t.Logf("TestCase %q", desc)
c := newTestCRIContainerdService()