From 0034aaa82ac00a75866e77a3570febdec8d291d1 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Thu, 22 Aug 2019 13:25:29 -0700 Subject: Send sandbox log to test log This used to be the case, but when --alsologtostderr was added, it stopped logging. PiperOrigin-RevId: 264905640 --- runsc/test/testutil/testutil.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/runsc/test/testutil/testutil.go b/runsc/test/testutil/testutil.go index e288c7758..4a3dfa0e3 100644 --- a/runsc/test/testutil/testutil.go +++ b/runsc/test/testutil/testutil.go @@ -127,13 +127,15 @@ func FindFile(path string) (string, error) { // 'RootDir' must be set by caller if required. func TestConfig() *boot.Config { return &boot.Config{ - Debug: true, - LogFormat: "text", - LogPackets: true, - Network: boot.NetworkNone, - Strace: true, - Platform: "ptrace", - FileAccess: boot.FileAccessExclusive, + Debug: true, + LogFormat: "text", + DebugLogFormat: "text", + AlsoLogToStderr: true, + LogPackets: true, + Network: boot.NetworkNone, + Strace: true, + Platform: "ptrace", + FileAccess: boot.FileAccessExclusive, TestOnlyAllowRunAsCurrentUserWithoutChroot: true, NumNetworkChannels: 1, } -- cgit v1.2.3 From 0e82f9f3fb76600e4c7987f95a65b140860ee845 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Thu, 22 Aug 2019 14:15:20 -0700 Subject: test: set shard_count to 5 by default In cl/264434674 and cl/264498919, we stop running test cases in parallel to not overload test hosts. But now tests requires more time to run, so we need to increase a default number of shards or a default test timeout. Let's start with increasing the number of shards and see how it will works. PiperOrigin-RevId: 264917055 --- test/syscalls/build_defs.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/syscalls/build_defs.bzl b/test/syscalls/build_defs.bzl index a63eda81d..771d171f8 100644 --- a/test/syscalls/build_defs.bzl +++ b/test/syscalls/build_defs.bzl @@ -4,7 +4,7 @@ # on the host (native) and runsc. def syscall_test( test, - shard_count = 1, + shard_count = 5, size = "small", use_tmpfs = False, add_overlay = False, -- cgit v1.2.3 From 761e4bf2fe520dae1120341b09c26be1577a2adb Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Thu, 22 Aug 2019 14:33:16 -0700 Subject: Ensure yield-equivalent with an already-expired timeout. PiperOrigin-RevId: 264920977 --- pkg/sentry/kernel/task_block.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/sentry/kernel/task_block.go b/pkg/sentry/kernel/task_block.go index 2a2e6f662..dd69939f9 100644 --- a/pkg/sentry/kernel/task_block.go +++ b/pkg/sentry/kernel/task_block.go @@ -15,6 +15,7 @@ package kernel import ( + "runtime" "time" ktime "gvisor.dev/gvisor/pkg/sentry/kernel/time" @@ -121,6 +122,17 @@ func (t *Task) block(C <-chan struct{}, timerChan <-chan struct{}) error { // Deactive our address space, we don't need it. interrupt := t.SleepStart() + // If the request is not completed, but the timer has already expired, + // then ensure that we run through a scheduler cycle. This is because + // we may see applications relying on timer slack to yield the thread. + // For example, they may attempt to sleep for some number of nanoseconds, + // and expect that this will actually yield the CPU and sleep for at + // least microseconds, e.g.: + // https://github.com/LMAX-Exchange/disruptor/commit/6ca210f2bcd23f703c479804d583718e16f43c07 + if len(timerChan) > 0 { + runtime.Gosched() + } + select { case <-C: t.SleepFinish(true) -- cgit v1.2.3 From f225fdbbe77c2017225517adcf67df70fcf8e36e Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Thu, 22 Aug 2019 18:25:57 -0700 Subject: Log message sent before logging is setup Moved log message to after the log options have been read and log setup. PiperOrigin-RevId: 264964171 --- runsc/main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/runsc/main.go b/runsc/main.go index e864118b2..c61583441 100644 --- a/runsc/main.go +++ b/runsc/main.go @@ -117,13 +117,6 @@ func main() { // All subcommands must be registered before flag parsing. flag.Parse() - if *testOnlyAllowRunAsCurrentUserWithoutChroot { - // SIGTERM is sent to all processes if a test exceeds its - // timeout and this case is handled by syscall_test_runner. - log.Warningf("Block the TERM signal. This is only safe in tests!") - signal.Ignore(syscall.SIGTERM) - } - // Are we showing the version? if *showVersion { // The format here is the same as runc. @@ -265,6 +258,13 @@ func main() { log.Infof("\t\tStrace: %t, max size: %d, syscalls: %s", conf.Strace, conf.StraceLogSize, conf.StraceSyscalls) log.Infof("***************************") + if *testOnlyAllowRunAsCurrentUserWithoutChroot { + // SIGTERM is sent to all processes if a test exceeds its + // timeout and this case is handled by syscall_test_runner. + log.Warningf("Block the TERM signal. This is only safe in tests!") + signal.Ignore(syscall.SIGTERM) + } + // Call the subcommand and pass in the configuration. var ws syscall.WaitStatus subcmdCode := subcommands.Execute(context.Background(), conf, &ws) -- cgit v1.2.3