-
Notifications
You must be signed in to change notification settings - Fork 70
list: Don't fail if rootfs doesn't exist #907
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,6 +430,70 @@ func TestListGetContainers(t *testing.T) { | |
assert.Equal(state, []fullContainerState(nil)) | ||
} | ||
|
||
func TestListGetContainersMissingRootfs(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
tmpdir, err := ioutil.TempDir(testDir, "") | ||
assert.NoError(err) | ||
defer os.RemoveAll(tmpdir) | ||
|
||
pod := &vcMock.Pod{ | ||
MockID: testPodID, | ||
} | ||
|
||
rootfs := filepath.Join(tmpdir, "rootfs") | ||
|
||
container := vc.ContainerStatus{ | ||
ID: pod.ID(), | ||
State: vc.State{ | ||
State: vc.StateRunning, | ||
}, | ||
PID: 1, | ||
|
||
// rootfs specified, but it doesn't exist | ||
RootFs: rootfs, | ||
} | ||
|
||
testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) { | ||
return []vc.PodStatus{ | ||
{ | ||
ID: pod.ID(), | ||
ContainersStatus: []vc.ContainerStatus{ | ||
container, | ||
}, | ||
}, | ||
}, nil | ||
} | ||
|
||
defer func() { | ||
testingImpl.ListPodFunc = nil | ||
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. dump question why this is need? 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. This resets the virtcontainers mock handler for By resetting the handler to |
||
}() | ||
|
||
app := cli.NewApp() | ||
ctx := cli.NewContext(app, nil, nil) | ||
app.Name = "foo" | ||
|
||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) | ||
|
||
assert.NoError(err) | ||
|
||
ctx.App.Metadata = map[string]interface{}{ | ||
"runtimeConfig": runtimeConfig, | ||
} | ||
|
||
states, err := getContainers(ctx) | ||
assert.NoError(err) | ||
|
||
assert.True(len(states) == 1) | ||
|
||
state := states[0] | ||
|
||
assert.Equal(state.Rootfs, container.RootFs) | ||
|
||
// since rootfs doesn't exist | ||
assert.Equal(state.Owner, "?") | ||
} | ||
|
||
func TestListGetContainersPodWithoutContainers(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
|
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.
This is an error that started to happen recently, I think we should be able always know the owner , so being this a not usual case can you log a warning and probably and log the error to probably know if the file did not exist ?
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.
Yeah, I'm having second thoughts about whether we should do this now we've confirmed the CI failure (clearcontainers/jenkins#32) is Fedora only.
What do you think @sameo, @grahamwhaley ? FTR,
runc
is "semi-lenient": it does not validate whether the container rootfs exists as it doesn't really need to care about that:Nominally, we do care because we use the container rootfs ownership to show who owns the container. However, we should really be employing a strategy similar to
runc
which sets the container ownership to the owner of the container directory belowrunc
's state directory. Butcc-runtime
cannot do that as it doesn't know where the virtcontainers root directory is (implementation detail).As such, this is all slightly academic as
cc-runtime list
will always show the owner UID0
currently.The advantage of not failing on rootfs lookup is that
list
will show atleast partial information. Maybe we should hold off deciding until we understand the F26 failure further.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.
sure, mark it as WIP until we get some further info then OK?
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.
wfm...