mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-31 19:41:17 +02:00
chore: allow building with debug handlers
Refs #3534. Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
This commit is contained in:
parent
c9651673b9
commit
c81cfb2167
5
Makefile
5
Makefile
@ -48,6 +48,7 @@ GO_LDFLAGS ?= -s -w \
|
||||
-X $(MGMT_HELPERS_PKG).ArtifactsPath=$(ARTIFACTS)
|
||||
|
||||
WITH_RACE ?=
|
||||
WITH_DEBUG ?=
|
||||
|
||||
ifneq ($(strip $(WITH_RACE)),)
|
||||
CGO_ENABLED = 1
|
||||
@ -55,6 +56,10 @@ GO_BUILDFLAGS += -race
|
||||
GO_LDFLAGS += -linkmode=external -extldflags '-static'
|
||||
endif
|
||||
|
||||
ifeq ($(WITH_DEBUG), true)
|
||||
GO_BUILDFLAGS += -tags sidero.debug
|
||||
endif
|
||||
|
||||
, := ,
|
||||
space := $(subst ,, )
|
||||
BUILD := docker buildx build
|
||||
|
3
go.mod
3
go.mod
@ -68,6 +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-kmsg v0.1.0
|
||||
github.com/talos-systems/go-loadbalancer v0.1.1
|
||||
github.com/talos-systems/go-procfs v0.0.0-20210108152626-8cbc42d3dc24
|
||||
@ -84,7 +85,7 @@ require (
|
||||
go.etcd.io/etcd/client/v3 v3.5.0-alpha.0
|
||||
go.etcd.io/etcd/etcdctl/v3 v3.5.0-alpha.0
|
||||
go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
|
||||
golang.org/x/net v0.0.0-20210505214959-0714010a04ed
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||
golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
|
||||
|
9
go.sum
9
go.sum
@ -1135,6 +1135,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-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=
|
||||
@ -1384,8 +1386,9 @@ golang.org/x/net v0.0.0-20201216054612-986b41b23924/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210505214959-0714010a04ed h1:V9kAVxLvz1lkufatrpHuUVyJ/5tR3Ms7rk951P4mI98=
|
||||
golang.org/x/net v0.0.0-20210505214959-0714010a04ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -1508,6 +1511,7 @@ golang.org/x/sys v0.0.0-20210216163648-f7da38b97c65/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6 h1:cdsMqa2nXzqlgs183pHxtvoVwU7CyzaCTAUOg94af4c=
|
||||
golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -1523,8 +1527,9 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
@ -5,11 +5,13 @@
|
||||
package apid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
debug "github.com/talos-systems/go-debug"
|
||||
"github.com/talos-systems/grpc-proxy/proxy"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"google.golang.org/grpc"
|
||||
@ -25,6 +27,10 @@ import (
|
||||
"github.com/talos-systems/talos/pkg/startup"
|
||||
)
|
||||
|
||||
const (
|
||||
debugAddr = ":9981"
|
||||
)
|
||||
|
||||
var (
|
||||
endpoints *string
|
||||
useK8sEndpoints *bool
|
||||
@ -39,6 +45,15 @@ func Main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
go func() {
|
||||
debugLogFunc := func(msg string) {
|
||||
log.Print(msg)
|
||||
}
|
||||
if lErr := debug.ListenAndServe(context.TODO(), debugAddr, debugLogFunc); lErr != nil {
|
||||
log.Fatalf("failed to start debug server: %s", lErr)
|
||||
}
|
||||
}()
|
||||
|
||||
if err := startup.RandSeed(); err != nil {
|
||||
log.Fatalf("failed to seed RNG: %v", err)
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
goruntime "runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/talos-systems/go-cmd/pkg/cmd/proc"
|
||||
"github.com/talos-systems/go-cmd/pkg/cmd/proc/reaper"
|
||||
debug "github.com/talos-systems/go-debug"
|
||||
"github.com/talos-systems/go-procfs/procfs"
|
||||
"golang.org/x/net/http/httpproxy"
|
||||
"golang.org/x/sys/unix"
|
||||
@ -38,10 +38,11 @@ import (
|
||||
"github.com/talos-systems/talos/pkg/startup"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Explicitly disable memory profiling to save around 1.4MiB of memory.
|
||||
goruntime.MemProfileRate = 0
|
||||
const (
|
||||
debugAddr = ":9982"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Explicitly set the default http client transport to work around proxy.Do
|
||||
// once. This is the http.DefaultTransport with the Proxy func overridden so
|
||||
// that the environment variables with be reread/initialized each time the
|
||||
@ -200,6 +201,15 @@ func run() error {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
go func() {
|
||||
debugLogFunc := func(msg string) {
|
||||
log.Print(msg)
|
||||
}
|
||||
if lErr := debug.ListenAndServe(ctx, debugAddr, debugLogFunc); lErr != nil {
|
||||
log.Fatalf("failed to start debug server: %s", lErr)
|
||||
}
|
||||
}()
|
||||
|
||||
// Schedule service shutdown on any return.
|
||||
defer system.Services(c.Runtime()).Shutdown(ctx)
|
||||
|
||||
|
@ -5,11 +5,13 @@
|
||||
package trustd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
stdlibnet "net"
|
||||
|
||||
"github.com/talos-systems/crypto/tls"
|
||||
debug "github.com/talos-systems/go-debug"
|
||||
"github.com/talos-systems/net"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
@ -23,6 +25,10 @@ import (
|
||||
"github.com/talos-systems/talos/pkg/startup"
|
||||
)
|
||||
|
||||
const (
|
||||
debugAddr = ":9983"
|
||||
)
|
||||
|
||||
// Main is the entrypoint into trustd.
|
||||
//
|
||||
//nolint:gocyclo
|
||||
@ -31,6 +37,15 @@ func Main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
go func() {
|
||||
debugLogFunc := func(msg string) {
|
||||
log.Print(msg)
|
||||
}
|
||||
if lErr := debug.ListenAndServe(context.TODO(), debugAddr, debugLogFunc); lErr != nil {
|
||||
log.Fatalf("failed to start debug server: %s", lErr)
|
||||
}
|
||||
}()
|
||||
|
||||
var err error
|
||||
|
||||
if err = startup.RandSeed(); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user