diff --git a/go.mod b/go.mod index 4248e13158..ad6b58b56d 100644 --- a/go.mod +++ b/go.mod @@ -68,7 +68,7 @@ require ( github.com/talos-systems/crypto v0.2.1-0.20210427105118-4f80b976b640 github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0 github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0 - github.com/talos-systems/go-debug v0.2.0 + github.com/talos-systems/go-debug v0.2.1-0.20210525175311-3d0a6e1bf5e3 github.com/talos-systems/go-kmsg v0.1.0 github.com/talos-systems/go-loadbalancer v0.1.1 github.com/talos-systems/go-procfs v0.0.0-20210108152626-8cbc42d3dc24 diff --git a/go.sum b/go.sum index 09ca9ecd29..0152a440cc 100644 --- a/go.sum +++ b/go.sum @@ -1218,8 +1218,8 @@ github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0 h1: github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0/go.mod h1:qnn/zDc09I1DA2BUDDCOSA2D0P8pIDjN8pGiRoRaQig= github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0 h1:DI+BjK+fcrLBc70Fi50dZocQcaHosqsuWHrGHKp2NzE= github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0/go.mod h1:kf+rZzTEmlDiYQ6ulslvRONnKLQH8x83TowltGMhO+k= -github.com/talos-systems/go-debug v0.2.0 h1:IbBfDSJE7tUaSXKuytOksHFI/wAbU2/1/szGvnKpgqc= -github.com/talos-systems/go-debug v0.2.0/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0= +github.com/talos-systems/go-debug v0.2.1-0.20210525175311-3d0a6e1bf5e3 h1:beG97JtuU5oIL+ArSOKbJxbfsCfELOQ5VZu4RuSBJHU= +github.com/talos-systems/go-debug v0.2.1-0.20210525175311-3d0a6e1bf5e3/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0= github.com/talos-systems/go-kmsg v0.1.0 h1:juoZn+XioduYvtie6nqi/miKGJPLYSBNXRv5jRe6+lE= github.com/talos-systems/go-kmsg v0.1.0/go.mod h1:dppwQn+/mrdvsziGMbXjzfc4E+75oZhr39UIP6LgL0w= github.com/talos-systems/go-loadbalancer v0.1.1 h1:qjC0uWHu6O7VXG9EN4ovVPg79sRbypXTrJZJskdaa2k= diff --git a/internal/app/machined/pkg/system/services/apid.go b/internal/app/machined/pkg/system/services/apid.go index 9edb3f1c32..04d77a9c00 100644 --- a/internal/app/machined/pkg/system/services/apid.go +++ b/internal/app/machined/pkg/system/services/apid.go @@ -19,6 +19,7 @@ import ( "github.com/containerd/containerd/oci" "github.com/fsnotify/fsnotify" specs "github.com/opencontainers/runtime-spec/specs-go" + "github.com/talos-systems/go-debug" "github.com/talos-systems/talos/internal/app/machined/pkg/runtime" "github.com/talos-systems/talos/internal/app/machined/pkg/system/events" @@ -138,6 +139,10 @@ func (o *APID) Runner(r runtime.Runtime) (runner.Runner, error) { } } + if debug.RaceEnabled { + env = append(env, "GORACE=halt_on_error=1") + } + b, err := r.Config().Bytes() if err != nil { return nil, err diff --git a/internal/app/machined/pkg/system/services/trustd.go b/internal/app/machined/pkg/system/services/trustd.go index ddaa1959fe..4af74c1e82 100644 --- a/internal/app/machined/pkg/system/services/trustd.go +++ b/internal/app/machined/pkg/system/services/trustd.go @@ -14,6 +14,7 @@ import ( "github.com/containerd/containerd/oci" specs "github.com/opencontainers/runtime-spec/specs-go" + "github.com/talos-systems/go-debug" "github.com/talos-systems/talos/internal/app/machined/pkg/runtime" "github.com/talos-systems/talos/internal/app/machined/pkg/system/events" @@ -72,6 +73,10 @@ func (t *Trustd) Runner(r runtime.Runtime) (runner.Runner, error) { env = append(env, fmt.Sprintf("%s=%s", key, val)) } + if debug.RaceEnabled { + env = append(env, "GORACE=halt_on_error=1") + } + b, err := r.Config().Bytes() if err != nil { return nil, err diff --git a/internal/pkg/mount/switchroot/switchroot.go b/internal/pkg/mount/switchroot/switchroot.go index a6384fa442..fd81d492b0 100644 --- a/internal/pkg/mount/switchroot/switchroot.go +++ b/internal/pkg/mount/switchroot/switchroot.go @@ -9,6 +9,7 @@ import ( "log" "os" + "github.com/talos-systems/go-debug" "golang.org/x/sys/unix" "github.com/talos-systems/talos/internal/pkg/mount" @@ -60,7 +61,15 @@ func Switch(prefix string, mountpoints *mount.Points) (err error) { // convention. log.Println("executing /sbin/init") - if err = unix.Exec("/sbin/init", []string{"/sbin/init"}, []string{}); err != nil { + envv := []string{} + + if debug.RaceEnabled { + envv = append(envv, "GORACE=halt_on_error=1") + + log.Printf("race detection enabled with halt_on_error=1") + } + + if err = unix.Exec("/sbin/init", []string{"/sbin/init"}, envv); err != nil { return fmt.Errorf("error executing /sbin/init: %w", err) }