Block networking in sandbox test by default, fix roughtime panic (#3240)

* block networking in sandbox test by default, fix roughtime panic

* Update .bazelrc
This commit is contained in:
Preston Van Loon 2019-08-19 12:13:05 -04:00 committed by GitHub
parent 6ac0d12f5b
commit e88bbaf614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -8,3 +8,8 @@ test --build_tests_only
build --host_force_python=PY2
test --host_force_python=PY2
run --host_force_python=PY2
# Networking is blocked for tests by default, add "requires-network" tag to your test if networking
# is required within the sandbox. This flag is no longer experimental after 0.29.0.
# Network sandboxing only works on linux.
--experimental_sandbox_default_allow_network=false

View File

@ -7,6 +7,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"@com_github_cloudflare_roughtime//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_googlesource_roughtime_roughtime_git//go/config:go_default_library",
],
)

View File

@ -6,6 +6,7 @@ import (
"time"
rt "github.com/cloudflare/roughtime"
"github.com/sirupsen/logrus"
"roughtime.googlesource.com/roughtime.git/go/config"
)
@ -22,6 +23,8 @@ func mustDecodeString(in string) []byte {
return pk
}
var log = logrus.WithField("prefix", "roughtime")
func init() {
t0 := time.Now()
@ -71,7 +74,7 @@ func init() {
var err error
offset, err = rt.AvgDeltaWithRadiusThresh(results, t0, 2*time.Second)
if err != nil {
panic(err)
log.WithError(err).Error("Failed to calculate roughtime offset")
}
}