Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Use channel to pass the stop info instead of polling for container stop#570

Merged
Random-Liu merged 1 commit intocontainerd:masterfrom
miaoyq:fixes-569
Jan 25, 2018
Merged

Use channel to pass the stop info instead of polling for container stop#570
Random-Liu merged 1 commit intocontainerd:masterfrom
miaoyq:fixes-569

Conversation

@miaoyq
Copy link
Copy Markdown
Member

@miaoyq miaoyq commented Jan 24, 2018

Fixes #569

/cc @Random-Liu @yanxuean

Signed-off-by: Yanqiang Miao [email protected]

@miaoyq
Copy link
Copy Markdown
Member Author

miaoyq commented Jan 24, 2018

/assign @Random-Liu

@miaoyq miaoyq force-pushed the fixes-569 branch 3 times, most recently from c31b3f2 to 11b1ddb Compare January 24, 2018 14:27
@Random-Liu
Copy link
Copy Markdown
Member

Random-Liu commented Jan 24, 2018

We need to handle cri-containerd restart.

We should change containerstore.WithStatus to stop the channel if FinishedAt in the initial status is set.

Comment thread pkg/store/container/container.go Outdated
}

// Stop close stopCh of the container.
func (c *Container) Stop() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Instead of adding a function to Container, can we make a type of stopCh and add function to it instead?

In this way, it can be reused in Sandbox after my change is in.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will do.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

@Random-Liu Random-Liu added this to the v1.0.0-rc.0 milestone Jan 24, 2018
Comment thread pkg/server/container_stop.go Outdated
case <-ticker.C:
continue
// Poll once before waiting for stopCheckPollInterval.
container, err := c.containerStore.Get(id)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we pass container containerstore.Container to the waitContainerStop function to avoid this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yean, it's better, will do.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Comment thread pkg/server/events.go Outdated
return
}

cntr.Stop()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should be better to do this after cntr.Status.UpdateSync.
We can ensure that the whole container is over for the user who watch the channel.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should do this also with "case *eventtypes.TaskOOM"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't do for TaskOOM. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should be better to do this after cntr.Status.UpdateSync.
We can ensure that the whole container is over for the user who watch the channel.

Agree.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Have changed it yesterday, :-)

Comment thread pkg/server/container_stop.go Outdated
@@ -138,33 +134,25 @@ func (c *criContainerdService) stopContainer(ctx context.Context, container cont

// waitContainerStop polls container state until timeout exceeds or container is stopped.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove "poll"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

@miaoyq miaoyq force-pushed the fixes-569 branch 2 times, most recently from bee9025 to e1e84d7 Compare January 25, 2018 02:28
@miaoyq
Copy link
Copy Markdown
Member Author

miaoyq commented Jan 25, 2018

@Random-Liu @yanxuean Have addressed all comments, PTAL.

@miaoyq
Copy link
Copy Markdown
Member Author

miaoyq commented Jan 25, 2018

Ooh, missed the test cases, will fix it.

@miaoyq
Copy link
Copy Markdown
Member Author

miaoyq commented Jan 25, 2018

Ooh, missed the test cases, will fix it.

Fixed.

Comment thread pkg/store/container/container.go Outdated
return c.Status.Delete()
}

// StopCh is used to pass the stop information of a container.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

s/pass/propagate/g

And please also change the other places.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done.

Comment thread pkg/store/container/container.go Outdated

cio "github.com/containerd/cri-containerd/pkg/server/io"
"github.com/containerd/cri-containerd/pkg/store"
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move this to the group above.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done.

@Random-Liu
Copy link
Copy Markdown
Member

LGTM with 2 nits.

@Random-Liu
Copy link
Copy Markdown
Member

/lgtm

Copy link
Copy Markdown
Member

@abhi abhi left a comment

Choose a reason for hiding this comment

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

LGTM

@Random-Liu Random-Liu merged commit 11042a4 into containerd:master Jan 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants