Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: return pid with 0 rather than -1 #2269

Merged
merged 1 commit into from
Sep 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cri/v1alpha1/cri_utils.go
Original file line number Diff line number Diff line change
@@ -790,8 +790,8 @@ func filterCRIContainers(containers []*runtime.Container, filter *runtime.Contai
// containerNetns returns the network namespace of the given container.
func containerNetns(container *mgr.Container) string {
pid := container.State.Pid
if pid == -1 {
// Pouch reports pid -1 for an exited container.
if pid == 0 {
// Pouch reports pid 0 for an exited container.
return ""
}

4 changes: 2 additions & 2 deletions cri/v1alpha1/cri_utils_test.go
Original file line number Diff line number Diff line change
@@ -1220,11 +1220,11 @@ func Test_containerNetns(t *testing.T) {
want: fmt.Sprintf("/proc/%v/ns/net", 1001),
},
{
name: "Pid EQ -1 Test",
name: "Pid EQ 0 Test",
args: args{
container: &mgr.Container{
State: &apitypes.ContainerState{
Pid: int64(-1),
Pid: int64(0),
},
},
},
4 changes: 2 additions & 2 deletions cri/v1alpha2/cri_utils.go
Original file line number Diff line number Diff line change
@@ -817,8 +817,8 @@ func filterCRIContainers(containers []*runtime.Container, filter *runtime.Contai
// containerNetns returns the network namespace of the given container.
func containerNetns(container *mgr.Container) string {
pid := container.State.Pid
if pid == -1 {
// Pouch reports pid -1 for an exited container.
if pid == 0 {
// Pouch reports pid 0 for an exited container.
return ""
}

4 changes: 2 additions & 2 deletions cri/v1alpha2/cri_utils_test.go
Original file line number Diff line number Diff line change
@@ -1207,11 +1207,11 @@ func Test_containerNetns(t *testing.T) {
want: fmt.Sprintf("/proc/%v/ns/net", 1001),
},
{
name: "Pid EQ -1 Test",
name: "Pid EQ 0 Test",
args: args{
container: &mgr.Container{
State: &apitypes.ContainerState{
Pid: int64(-1),
Pid: int64(0),
},
},
},
2 changes: 1 addition & 1 deletion daemon/mgr/container_state.go
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ func (c *Container) SetStatusRunning(pid int64) {
// When a container's status turns to StatusStopped, the following fields need updated:
// Status -> StatusStopped
// FinishedAt -> time.Now()
// Pid -> -1
// Pid -> 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good catch.

// ExitCode -> input param
// Error -> input param
func (c *Container) SetStatusStopped(exitCode int64, errMsg string) {