Skip to content
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
6 changes: 6 additions & 0 deletions daemon/containerio/cio.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ func copyIO(fifos *containerdio.FIFOSet, ioset *ioSet, tty bool) (_ *wgCloser, e
}
}()

// if fifos directory is not exist, create fifo will fails,
// also in case of fifo directory lost in container recovery process.
if _, err := os.Stat(fifos.Dir); err != nil && os.IsNotExist(err) {
Copy link
Contributor

@fuweid fuweid Jul 23, 2018

Choose a reason for hiding this comment

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

if the error is not 404 not found, should we return it directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first , 404 cause by http, then, we deal with non-exist file error to make fifo can be created successful.

Copy link
Contributor

Choose a reason for hiding this comment

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

404 is metaphor. I means that if the os.IsNotExist(err) is false, should we return err directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I means we only need to deal this kind error, and not check Mkdir's return.

Copy link
Contributor

Choose a reason for hiding this comment

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

But the Mkdir maybe fail, right? And if os.IsNotExist(err) is false, I don't think it's necessary to execute the following statements. how do you think?

cc @allencloud

Copy link
Contributor Author

@Ace-Tang Ace-Tang Jul 23, 2018

Choose a reason for hiding this comment

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

We do not care about if mkdir' return, since if it fails , it means other problem, here we just deal with the problem the directory is not exist, so we also not deal with other error besides os.IsNotExist(err).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If other problem exist, fifo create will return. I do not want return error in the add funtion.

os.MkdirAll(fifos.Dir, 0700)
}

if fifos.In != "" {
if f, err = fifo.OpenFifo(ctx, fifos.In, syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil {
return nil, err
Expand Down