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

Some cleanup after switching to new client. #137

Merged
merged 1 commit into from
Aug 18, 2017

Conversation

Random-Liu
Copy link
Member

Some cleanup after switching to new containerd client.

Signed-off-by: Lantao Liu lantaol@google.com

defer cancel()

resCh := make(chan execResult, 1)
go func() {
Copy link
Member

Choose a reason for hiding this comment

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

Will this go routine be stuck if the process.Start(ctx) errors out ? Because there will be no listener on the channel.

Copy link
Member

Choose a reason for hiding this comment

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

actually it won't since its buffered channel

Copy link
Member Author

Choose a reason for hiding this comment

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

If Start fails, we'll go to defer to delete the container, and then Wait will return. :)

However, this is not that obvious... I think we should make it more clear, let me see.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct, I even found a containerd bug when trying to address this containerd/containerd#1376.

@abhi
Copy link
Member

abhi commented Aug 17, 2017

LGTM

@ijc
Copy link
Contributor

ijc commented Aug 17, 2017

LGTM (FWIW)

@Random-Liu Random-Liu force-pushed the cleanup-with-new-client branch 2 times, most recently from bbf796a to 9a4aaea Compare August 17, 2017 22:47
@Random-Liu
Copy link
Member Author

@abhinandanpb Addressed comments. PTAL.

@Random-Liu Random-Liu mentioned this pull request Aug 17, 2017
42 tasks
@Random-Liu
Copy link
Member Author

The new commit also added the ExecSync timeout.

@@ -120,6 +127,8 @@ func (c *criContainerdService) execInContainer(ctx context.Context, id string, o
return nil, fmt.Errorf("failed to create exec %q: %v", execID, err)
}
defer func() {
// TODO(random-liu): There is a containerd bug here containerd#1376, revisit this
// after that is fixed.
if _, err := process.Delete(ctx); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

wondering if we should just defer on process.Delete(ctx, containerd.WithProcessKill) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

As is mentioned in the containerd issue containerd/containerd#1376, it doesn't work.

Copy link
Member

Choose a reason for hiding this comment

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

Yep yep. forgot about it.

exitCode, err := c.waitContainerExec(eventstream, id, execID)
if err != nil {
return nil, fmt.Errorf("failed to wait for exec in container %q to finish: %v", id, err)
var timeoutCh <-chan time.Time
Copy link
Member

Choose a reason for hiding this comment

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

And then use context.WithDeadline if the timeout is set and just return

select{
     <-ctx.Done() : return err
                               ....
     <-resCh      :  ....
}

Copy link
Member

Choose a reason for hiding this comment

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

Just a thought. This works great too. WDYT ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried that. The problem is that once context is cancelled, we could not use it to call Delete or Kill. Of course, we could use context.Background() for those operations, but I'm not sure whether we should do that.

That is also why I filed #142.

Copy link
Member

Choose a reason for hiding this comment

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

Got it . makes sense

@abhi
Copy link
Member

abhi commented Aug 18, 2017

LGTM

@abhi abhi added the lgtm label Aug 18, 2017
@Random-Liu
Copy link
Member Author

@abhinandanpb Thanks for reviewing! :)

Signed-off-by: Lantao Liu <lantaol@google.com>
@Random-Liu
Copy link
Member Author

Squashed commits. Will merge after test passes.

@Random-Liu Random-Liu merged commit dcc3cb2 into containerd:master Aug 18, 2017
@Random-Liu Random-Liu deleted the cleanup-with-new-client branch August 18, 2017 22:04
lanchongyizu pushed a commit to lanchongyizu/cri-containerd that referenced this pull request Sep 3, 2017
…ient

Some cleanup after switching to new client.
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.

None yet

4 participants