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

Move libcontainer to x/sys/unix #1442

Merged
merged 3 commits into from
May 26, 2017

Conversation

clnperez
Copy link
Contributor

@clnperez clnperez commented May 9, 2017

Since syscall is outdated and broken for some architectures,
use x/sys/unix instead.

There are still some dependencies on the syscall package that will
remain in syscall for the forseeable future:

Errno
Signal
SysProcAttr

Additionally, os still uses syscall, so it needs to be kept for anything
returning *os.ProcessState, such as process.Wait.

Signed-off-by: Christy Perez christy@linux.vnet.ibm.com

@clnperez
Copy link
Contributor Author

clnperez commented May 9, 2017

This fixes several tests that were failing on POWER (ppc64le) -- including some criu tests. I tested using make test but with a modified dockerfile and makefile to pull in the right power bits.

@clnperez
Copy link
Contributor Author

clnperez commented May 9, 2017

On a closer look, there's not that much code outside of libcontainer that doesn't also need to be changed, so WDYT about replacing syscall everywhere else as well?

@clnperez
Copy link
Contributor Author

clnperez commented May 9, 2017

Hm. Tests failing again. Hold off on this for now.

@@ -710,7 +711,7 @@ func setupSeccomp(config *specs.LinuxSeccomp) (*configs.Seccomp, error) {
return nil, nil
}

// No default action specified, no syscalls listed, assume seccomp disabled
// No default action specified, no unixs listed, assume seccomp disabled
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this (and a few later entries) should keep syscalls. In #1445 I replaced sycalls. with unix. (including the trailing period), and while that can still have false positives (e.g. when the word is at the end of a comment sentence), it won't accidentally do things like this.

Copy link
Contributor Author

@clnperez clnperez May 11, 2017

Choose a reason for hiding this comment

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

Oops. Yep. I thought I caught all the spots I needed to keep syscall. I'll take a closer look.

@clnperez
Copy link
Contributor Author

Fixed those error message and comment false positives @wking. PTAL.

@wking
Copy link
Contributor

wking commented May 11, 2017 via email

@wking
Copy link
Contributor

wking commented May 11, 2017

Travis isn't happy. It looks like the tests hung?

@@ -303,7 +304,7 @@ func (l *LinuxFactory) StartInitialization() (err error) {
return err
}

// If Init succeeds, syscall.Exec will not return, hence none of the defers will be called.
// If Init succeeds, unix.Exec will not return, hence none of the defers will be called.
Copy link
Contributor

Choose a reason for hiding this comment

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

this should still be syscall.Exec

@@ -19,6 +19,8 @@ import (
"github.com/opencontainers/runc/libcontainer/user"
"github.com/opencontainers/runc/libcontainer/utils"
"github.com/vishvananda/netlink"

sysunix "golang.org/x/sys/unix"
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we use sysunix import name here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weird. I swear there was a conflict here. I'll change it to unix, thanks.

return err
}
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for removing unused functions !

list.go Outdated
@@ -7,7 +7,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"syscall"
"syscall" // avoid use if possible
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this comment is not required.

@clnperez
Copy link
Contributor Author

Strange that this failed with go 1.8, but not 1.7, and not go tip. Is that failure something that anyone has seen before?

@clnperez
Copy link
Contributor Author

For reference (because I'm about to rebase) the failure seen on go 1.8 is:

--- FAIL: TestNotifyOnOOM (0.00s)
	notify_linux_test.go:99: expected event control to be closed
	notify_linux_test.go:103: expected event fd to be closed

@clnperez
Copy link
Contributor Author

😆 So this time -- that same test passed with 1.8 and failed with go tip and 1.7. I'll take a look at that test.

@clnperez
Copy link
Contributor Author

I added the error to the debug output so that I could see what error it's getting, since not unix.EBADF -- but this time all three go versions' tests passed. WDYT @dqminh, @wking?

@wking
Copy link
Contributor

wking commented May 15, 2017 via email

@clnperez clnperez force-pushed the libcontainer-sys-unix branch 3 times, most recently from ad1bf68 to a958c89 Compare May 16, 2017 21:41
@clnperez
Copy link
Contributor Author

Welp, I tried several times and just can't get this to fail again.

@clnperez
Copy link
Contributor Author

Does this look okay to merge? I can't get the test to fail again so it must be flaky.

@crosbymichael
Copy link
Member

@clnperez this needs to be rebased

@clnperez clnperez force-pushed the libcontainer-sys-unix branch 2 times, most recently from eb81e24 to 9e7fc57 Compare May 22, 2017 20:59
devType = 'b'
}
stat_t, ok := fileInfo.Sys().(*syscall.Stat_t)
stat_t, ok := fileInfo.Sys().(*unix.Stat_t)
Copy link
Member

Choose a reason for hiding this comment

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

May need to verify this line, i'm not sure if the cast will work

Copy link
Member

Choose a reason for hiding this comment

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

Ya, you will have to revert this line.

panic: interface conversion: interface {} is *syscall.Stat_t, not *unix.Stat_t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i thought i had fixed that issue. hold tight on reviews while i take a look at my rebase.

Copy link
Member

Choose a reason for hiding this comment

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

It also looks like you have an unrelated commit shfmt'ing files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i put that in there b/c the tests failed (but also kept it separate b/c it is unrelated)

@clnperez clnperez force-pushed the libcontainer-sys-unix branch 2 times, most recently from fc52b35 to a11a682 Compare May 22, 2017 21:30
Since syscall is outdated and broken for some architectures,
use x/sys/unix instead.

There are still some dependencies on the syscall package that will
remain in syscall for the forseeable future:

Errno
Signal
SysProcAttr

Additionally:
- os still uses syscall, so it needs to be kept for anything
returning *os.ProcessState, such as process.Wait.

Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>
@clnperez
Copy link
Contributor Author

@crosbymichael PTAL. Three questions:

  • Can I leave the other usages of Stat_t as-is (unix.Stat_t)?
  • What should I do about the unrelated shfmt commit? The CI fails me I don't fix those up.
  • Should I squash the two code changes (or three...) into one commit? I was originally planning on only updating libcontainer but there weren't many more files outside of it that needed switching over.

Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>
@clnperez
Copy link
Contributor Author

Tests seem a little flaky. All passing now.

@crosbymichael
Copy link
Member

crosbymichael commented May 25, 2017

LGTM

I don't know anything about why the tests are failing because of shfmt.

unix.Stat_t is food for all the other cases because you are using it in the syscall and not what FileInfo returns.

Thanks!

Approved with PullApprove

@dqminh
Copy link
Contributor

dqminh commented May 26, 2017

LGTM

Approved with PullApprove

@dqminh dqminh merged commit 67bd2ab into opencontainers:master May 26, 2017
@clnperez clnperez deleted the libcontainer-sys-unix branch May 30, 2017 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants