mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-20 20:39:08 +02:00
Add profile name and events for status
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/netbirdio/netbird/client/internal/profilemanager"
|
"github.com/netbirdio/netbird/client/internal/profilemanager"
|
||||||
"github.com/netbirdio/netbird/client/proto"
|
"github.com/netbirdio/netbird/client/proto"
|
||||||
"github.com/netbirdio/netbird/client/server"
|
"github.com/netbirdio/netbird/client/server"
|
||||||
nbstatus "github.com/netbirdio/netbird/client/status"
|
|
||||||
mgmProto "github.com/netbirdio/netbird/shared/management/proto"
|
mgmProto "github.com/netbirdio/netbird/shared/management/proto"
|
||||||
"github.com/netbirdio/netbird/upload-server/types"
|
"github.com/netbirdio/netbird/upload-server/types"
|
||||||
)
|
)
|
||||||
@@ -98,7 +97,6 @@ func debugBundle(cmd *cobra.Command, _ []string) error {
|
|||||||
client := proto.NewDaemonServiceClient(conn)
|
client := proto.NewDaemonServiceClient(conn)
|
||||||
request := &proto.DebugBundleRequest{
|
request := &proto.DebugBundleRequest{
|
||||||
Anonymize: anonymizeFlag,
|
Anonymize: anonymizeFlag,
|
||||||
Status: getStatusOutput(cmd, anonymizeFlag),
|
|
||||||
SystemInfo: systemInfoFlag,
|
SystemInfo: systemInfoFlag,
|
||||||
LogFileCount: logFileCount,
|
LogFileCount: logFileCount,
|
||||||
}
|
}
|
||||||
@@ -220,9 +218,6 @@ func runForDuration(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
|
|
||||||
headerPostUp := fmt.Sprintf("----- NetBird post-up - Timestamp: %s", time.Now().Format(time.RFC3339))
|
|
||||||
statusOutput := fmt.Sprintf("%s\n%s", headerPostUp, getStatusOutput(cmd, anonymizeFlag))
|
|
||||||
|
|
||||||
if waitErr := waitForDurationOrCancel(cmd.Context(), duration, cmd); waitErr != nil {
|
if waitErr := waitForDurationOrCancel(cmd.Context(), duration, cmd); waitErr != nil {
|
||||||
return waitErr
|
return waitErr
|
||||||
}
|
}
|
||||||
@@ -230,11 +225,8 @@ func runForDuration(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
cmd.Println("Creating debug bundle...")
|
cmd.Println("Creating debug bundle...")
|
||||||
|
|
||||||
headerPreDown := fmt.Sprintf("----- NetBird pre-down - Timestamp: %s - Duration: %s", time.Now().Format(time.RFC3339), duration)
|
|
||||||
statusOutput = fmt.Sprintf("%s\n%s\n%s", statusOutput, headerPreDown, getStatusOutput(cmd, anonymizeFlag))
|
|
||||||
request := &proto.DebugBundleRequest{
|
request := &proto.DebugBundleRequest{
|
||||||
Anonymize: anonymizeFlag,
|
Anonymize: anonymizeFlag,
|
||||||
Status: statusOutput,
|
|
||||||
SystemInfo: systemInfoFlag,
|
SystemInfo: systemInfoFlag,
|
||||||
LogFileCount: logFileCount,
|
LogFileCount: logFileCount,
|
||||||
}
|
}
|
||||||
@@ -301,25 +293,6 @@ func setSyncResponsePersistence(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStatusOutput(cmd *cobra.Command, anon bool) string {
|
|
||||||
var statusOutputString string
|
|
||||||
statusResp, err := getStatus(cmd.Context(), true)
|
|
||||||
if err != nil {
|
|
||||||
cmd.PrintErrf("Failed to get status: %v\n", err)
|
|
||||||
} else {
|
|
||||||
pm := profilemanager.NewProfileManager()
|
|
||||||
var profName string
|
|
||||||
if activeProf, err := pm.GetActiveProfile(); err == nil {
|
|
||||||
profName = activeProf.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
statusOutputString = nbstatus.ParseToFullDetailSummary(
|
|
||||||
nbstatus.ConvertToStatusOutputOverview(statusResp.GetFullStatus(), anon, statusResp.GetDaemonVersion(), "", nil, nil, nil, "", profName),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return statusOutputString
|
|
||||||
}
|
|
||||||
|
|
||||||
func waitForDurationOrCancel(ctx context.Context, duration time.Duration, cmd *cobra.Command) error {
|
func waitForDurationOrCancel(ctx context.Context, duration time.Duration, cmd *cobra.Command) error {
|
||||||
ticker := time.NewTicker(1 * time.Second)
|
ticker := time.NewTicker(1 * time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ import (
|
|||||||
"github.com/netbirdio/netbird/client/anonymize"
|
"github.com/netbirdio/netbird/client/anonymize"
|
||||||
"github.com/netbirdio/netbird/client/internal/peer"
|
"github.com/netbirdio/netbird/client/internal/peer"
|
||||||
"github.com/netbirdio/netbird/client/internal/profilemanager"
|
"github.com/netbirdio/netbird/client/internal/profilemanager"
|
||||||
|
nbstatus "github.com/netbirdio/netbird/client/status"
|
||||||
mgmProto "github.com/netbirdio/netbird/shared/management/proto"
|
mgmProto "github.com/netbirdio/netbird/shared/management/proto"
|
||||||
"github.com/netbirdio/netbird/util"
|
"github.com/netbirdio/netbird/util"
|
||||||
|
"github.com/netbirdio/netbird/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const readmeContent = `Netbird debug bundle
|
const readmeContent = `Netbird debug bundle
|
||||||
@@ -221,7 +223,6 @@ type BundleGenerator struct {
|
|||||||
logPath string
|
logPath string
|
||||||
|
|
||||||
anonymize bool
|
anonymize bool
|
||||||
clientStatus string
|
|
||||||
includeSystemInfo bool
|
includeSystemInfo bool
|
||||||
logFileCount uint32
|
logFileCount uint32
|
||||||
|
|
||||||
@@ -230,7 +231,6 @@ type BundleGenerator struct {
|
|||||||
|
|
||||||
type BundleConfig struct {
|
type BundleConfig struct {
|
||||||
Anonymize bool
|
Anonymize bool
|
||||||
ClientStatus string
|
|
||||||
IncludeSystemInfo bool
|
IncludeSystemInfo bool
|
||||||
LogFileCount uint32
|
LogFileCount uint32
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,6 @@ func NewBundleGenerator(deps GeneratorDependencies, cfg BundleConfig) *BundleGen
|
|||||||
logPath: deps.LogPath,
|
logPath: deps.LogPath,
|
||||||
|
|
||||||
anonymize: cfg.Anonymize,
|
anonymize: cfg.Anonymize,
|
||||||
clientStatus: cfg.ClientStatus,
|
|
||||||
includeSystemInfo: cfg.IncludeSystemInfo,
|
includeSystemInfo: cfg.IncludeSystemInfo,
|
||||||
logFileCount: logFileCount,
|
logFileCount: logFileCount,
|
||||||
}
|
}
|
||||||
@@ -304,13 +303,6 @@ func (g *BundleGenerator) createArchive() error {
|
|||||||
return fmt.Errorf("add status: %w", err)
|
return fmt.Errorf("add status: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.statusRecorder != nil {
|
|
||||||
status := g.statusRecorder.GetFullStatus()
|
|
||||||
seedFromStatus(g.anonymizer, &status)
|
|
||||||
} else {
|
|
||||||
log.Debugf("no status recorder available for seeding")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := g.addConfig(); err != nil {
|
if err := g.addConfig(); err != nil {
|
||||||
log.Errorf("failed to add config to debug bundle: %v", err)
|
log.Errorf("failed to add config to debug bundle: %v", err)
|
||||||
}
|
}
|
||||||
@@ -388,11 +380,26 @@ func (g *BundleGenerator) addReadme() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *BundleGenerator) addStatus() error {
|
func (g *BundleGenerator) addStatus() error {
|
||||||
if status := g.clientStatus; status != "" {
|
if g.statusRecorder != nil {
|
||||||
statusReader := strings.NewReader(status)
|
pm := profilemanager.NewProfileManager()
|
||||||
|
var profName string
|
||||||
|
if activeProf, err := pm.GetActiveProfile(); err == nil {
|
||||||
|
profName = activeProf.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
fullStatus := g.statusRecorder.GetFullStatus()
|
||||||
|
protoFullStatus := nbstatus.ToProtoFullStatus(fullStatus)
|
||||||
|
protoFullStatus.Events = g.statusRecorder.GetEventHistory()
|
||||||
|
overview := nbstatus.ConvertToStatusOutputOverview(protoFullStatus, g.anonymize, version.NetbirdVersion(), "", nil, nil, nil, "", profName)
|
||||||
|
statusOutput := nbstatus.ParseToFullDetailSummary(overview)
|
||||||
|
|
||||||
|
statusReader := strings.NewReader(statusOutput)
|
||||||
if err := g.addFileToZip(statusReader, "status.txt"); err != nil {
|
if err := g.addFileToZip(statusReader, "status.txt"); err != nil {
|
||||||
return fmt.Errorf("add status file to zip: %w", err)
|
return fmt.Errorf("add status file to zip: %w", err)
|
||||||
}
|
}
|
||||||
|
seedFromStatus(g.anonymizer, &fullStatus)
|
||||||
|
} else {
|
||||||
|
log.Debugf("no status recorder available for seeding")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ import (
|
|||||||
semaphoregroup "github.com/netbirdio/netbird/util/semaphore-group"
|
semaphoregroup "github.com/netbirdio/netbird/util/semaphore-group"
|
||||||
|
|
||||||
nbssh "github.com/netbirdio/netbird/client/ssh"
|
nbssh "github.com/netbirdio/netbird/client/ssh"
|
||||||
nbstatus "github.com/netbirdio/netbird/client/status"
|
|
||||||
"github.com/netbirdio/netbird/client/system"
|
"github.com/netbirdio/netbird/client/system"
|
||||||
nbdns "github.com/netbirdio/netbird/dns"
|
nbdns "github.com/netbirdio/netbird/dns"
|
||||||
"github.com/netbirdio/netbird/route"
|
"github.com/netbirdio/netbird/route"
|
||||||
@@ -68,7 +67,6 @@ import (
|
|||||||
signal "github.com/netbirdio/netbird/shared/signal/client"
|
signal "github.com/netbirdio/netbird/shared/signal/client"
|
||||||
sProto "github.com/netbirdio/netbird/shared/signal/proto"
|
sProto "github.com/netbirdio/netbird/shared/signal/proto"
|
||||||
"github.com/netbirdio/netbird/util"
|
"github.com/netbirdio/netbird/util"
|
||||||
"github.com/netbirdio/netbird/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// PeerConnectionTimeoutMax is a timeout of an initial connection attempt to a remote peer.
|
// PeerConnectionTimeoutMax is a timeout of an initial connection attempt to a remote peer.
|
||||||
@@ -1051,12 +1049,6 @@ func (e *Engine) handleBundle(params *mgmProto.BundleParameters) (*mgmProto.JobR
|
|||||||
return nil, errors.New("sync response is not available")
|
return nil, errors.New("sync response is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert fullStatus to statusOutput
|
|
||||||
fullStatus := e.statusRecorder.GetFullStatus()
|
|
||||||
protoFullStatus := nbstatus.ToProtoFullStatus(fullStatus)
|
|
||||||
overview := nbstatus.ConvertToStatusOutputOverview(protoFullStatus, params.Anonymize, version.NetbirdVersion(), "", nil, nil, nil, "", "")
|
|
||||||
statusOutput := nbstatus.ParseToFullDetailSummary(overview)
|
|
||||||
|
|
||||||
bundleDeps := debug.GeneratorDependencies{
|
bundleDeps := debug.GeneratorDependencies{
|
||||||
InternalConfig: e.config.ProfileConfig,
|
InternalConfig: e.config.ProfileConfig,
|
||||||
StatusRecorder: e.statusRecorder,
|
StatusRecorder: e.statusRecorder,
|
||||||
@@ -1066,7 +1058,6 @@ func (e *Engine) handleBundle(params *mgmProto.BundleParameters) (*mgmProto.JobR
|
|||||||
|
|
||||||
bundleJobParams := debug.BundleConfig{
|
bundleJobParams := debug.BundleConfig{
|
||||||
Anonymize: params.Anonymize,
|
Anonymize: params.Anonymize,
|
||||||
ClientStatus: statusOutput,
|
|
||||||
IncludeSystemInfo: true,
|
IncludeSystemInfo: true,
|
||||||
LogFileCount: uint32(params.LogFileCount),
|
LogFileCount: uint32(params.LogFileCount),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ import (
|
|||||||
"github.com/netbirdio/netbird/client/internal/ingressgw"
|
"github.com/netbirdio/netbird/client/internal/ingressgw"
|
||||||
"github.com/netbirdio/netbird/client/internal/relay"
|
"github.com/netbirdio/netbird/client/internal/relay"
|
||||||
"github.com/netbirdio/netbird/client/proto"
|
"github.com/netbirdio/netbird/client/proto"
|
||||||
|
"github.com/netbirdio/netbird/route"
|
||||||
"github.com/netbirdio/netbird/shared/management/domain"
|
"github.com/netbirdio/netbird/shared/management/domain"
|
||||||
relayClient "github.com/netbirdio/netbird/shared/relay/client"
|
relayClient "github.com/netbirdio/netbird/shared/relay/client"
|
||||||
"github.com/netbirdio/netbird/route"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const eventQueueSize = 10
|
const eventQueueSize = 10
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.6
|
// protoc-gen-go v1.36.6
|
||||||
// protoc v6.32.1
|
// protoc v6.33.1
|
||||||
// source: daemon.proto
|
// source: daemon.proto
|
||||||
|
|
||||||
package proto
|
package proto
|
||||||
@@ -2377,7 +2377,6 @@ func (x *ForwardingRulesResponse) GetRules() []*ForwardingRule {
|
|||||||
type DebugBundleRequest struct {
|
type DebugBundleRequest struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Anonymize bool `protobuf:"varint,1,opt,name=anonymize,proto3" json:"anonymize,omitempty"`
|
Anonymize bool `protobuf:"varint,1,opt,name=anonymize,proto3" json:"anonymize,omitempty"`
|
||||||
Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"`
|
|
||||||
SystemInfo bool `protobuf:"varint,3,opt,name=systemInfo,proto3" json:"systemInfo,omitempty"`
|
SystemInfo bool `protobuf:"varint,3,opt,name=systemInfo,proto3" json:"systemInfo,omitempty"`
|
||||||
UploadURL string `protobuf:"bytes,4,opt,name=uploadURL,proto3" json:"uploadURL,omitempty"`
|
UploadURL string `protobuf:"bytes,4,opt,name=uploadURL,proto3" json:"uploadURL,omitempty"`
|
||||||
LogFileCount uint32 `protobuf:"varint,5,opt,name=logFileCount,proto3" json:"logFileCount,omitempty"`
|
LogFileCount uint32 `protobuf:"varint,5,opt,name=logFileCount,proto3" json:"logFileCount,omitempty"`
|
||||||
@@ -2422,13 +2421,6 @@ func (x *DebugBundleRequest) GetAnonymize() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DebugBundleRequest) GetStatus() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Status
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DebugBundleRequest) GetSystemInfo() bool {
|
func (x *DebugBundleRequest) GetSystemInfo() bool {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.SystemInfo
|
return x.SystemInfo
|
||||||
@@ -4829,10 +4821,9 @@ const file_daemon_proto_rawDesc = "" +
|
|||||||
"\x12translatedHostname\x18\x04 \x01(\tR\x12translatedHostname\x128\n" +
|
"\x12translatedHostname\x18\x04 \x01(\tR\x12translatedHostname\x128\n" +
|
||||||
"\x0etranslatedPort\x18\x05 \x01(\v2\x10.daemon.PortInfoR\x0etranslatedPort\"G\n" +
|
"\x0etranslatedPort\x18\x05 \x01(\v2\x10.daemon.PortInfoR\x0etranslatedPort\"G\n" +
|
||||||
"\x17ForwardingRulesResponse\x12,\n" +
|
"\x17ForwardingRulesResponse\x12,\n" +
|
||||||
"\x05rules\x18\x01 \x03(\v2\x16.daemon.ForwardingRuleR\x05rules\"\xac\x01\n" +
|
"\x05rules\x18\x01 \x03(\v2\x16.daemon.ForwardingRuleR\x05rules\"\x94\x01\n" +
|
||||||
"\x12DebugBundleRequest\x12\x1c\n" +
|
"\x12DebugBundleRequest\x12\x1c\n" +
|
||||||
"\tanonymize\x18\x01 \x01(\bR\tanonymize\x12\x16\n" +
|
"\tanonymize\x18\x01 \x01(\bR\tanonymize\x12\x1e\n" +
|
||||||
"\x06status\x18\x02 \x01(\tR\x06status\x12\x1e\n" +
|
|
||||||
"\n" +
|
"\n" +
|
||||||
"systemInfo\x18\x03 \x01(\bR\n" +
|
"systemInfo\x18\x03 \x01(\bR\n" +
|
||||||
"systemInfo\x12\x1c\n" +
|
"systemInfo\x12\x1c\n" +
|
||||||
|
|||||||
@@ -390,7 +390,6 @@ message ForwardingRulesResponse {
|
|||||||
// DebugBundler
|
// DebugBundler
|
||||||
message DebugBundleRequest {
|
message DebugBundleRequest {
|
||||||
bool anonymize = 1;
|
bool anonymize = 1;
|
||||||
string status = 2;
|
|
||||||
bool systemInfo = 3;
|
bool systemInfo = 3;
|
||||||
string uploadURL = 4;
|
string uploadURL = 4;
|
||||||
uint32 logFileCount = 5;
|
uint32 logFileCount = 5;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ func (s *Server) DebugBundle(_ context.Context, req *proto.DebugBundleRequest) (
|
|||||||
},
|
},
|
||||||
debug.BundleConfig{
|
debug.BundleConfig{
|
||||||
Anonymize: req.GetAnonymize(),
|
Anonymize: req.GetAnonymize(),
|
||||||
ClientStatus: req.GetStatus(),
|
|
||||||
IncludeSystemInfo: req.GetSystemInfo(),
|
IncludeSystemInfo: req.GetSystemInfo(),
|
||||||
LogFileCount: req.GetLogFileCount(),
|
LogFileCount: req.GetLogFileCount(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,13 +15,14 @@ import (
|
|||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
"github.com/netbirdio/netbird/client/anonymize"
|
"github.com/netbirdio/netbird/client/anonymize"
|
||||||
"github.com/netbirdio/netbird/client/internal/peer"
|
"github.com/netbirdio/netbird/client/internal/peer"
|
||||||
probeRelay "github.com/netbirdio/netbird/client/internal/relay"
|
probeRelay "github.com/netbirdio/netbird/client/internal/relay"
|
||||||
"github.com/netbirdio/netbird/client/proto"
|
"github.com/netbirdio/netbird/client/proto"
|
||||||
"github.com/netbirdio/netbird/shared/management/domain"
|
"github.com/netbirdio/netbird/shared/management/domain"
|
||||||
"github.com/netbirdio/netbird/version"
|
"github.com/netbirdio/netbird/version"
|
||||||
"golang.org/x/exp/maps"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PeerStateDetailOutput struct {
|
type PeerStateDetailOutput struct {
|
||||||
@@ -835,4 +836,3 @@ func anonymizeOverview(a *anonymize.Anonymizer, overview *OutputOverview) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-69
@@ -18,9 +18,7 @@ import (
|
|||||||
"github.com/skratchdot/open-golang/open"
|
"github.com/skratchdot/open-golang/open"
|
||||||
|
|
||||||
"github.com/netbirdio/netbird/client/internal"
|
"github.com/netbirdio/netbird/client/internal"
|
||||||
"github.com/netbirdio/netbird/client/internal/profilemanager"
|
|
||||||
"github.com/netbirdio/netbird/client/proto"
|
"github.com/netbirdio/netbird/client/proto"
|
||||||
nbstatus "github.com/netbirdio/netbird/client/status"
|
|
||||||
uptypes "github.com/netbirdio/netbird/upload-server/types"
|
uptypes "github.com/netbirdio/netbird/upload-server/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -291,13 +289,12 @@ func (s *serviceClient) handleRunForDuration(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
statusOutput, err := s.collectDebugData(conn, initialState, params, progressUI)
|
if err := s.collectDebugData(conn, initialState, params, progressUI); err != nil {
|
||||||
if err != nil {
|
|
||||||
handleError(progressUI, err.Error())
|
handleError(progressUI, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.createDebugBundleFromCollection(conn, params, statusOutput, progressUI); err != nil {
|
if err := s.createDebugBundleFromCollection(conn, params, progressUI); err != nil {
|
||||||
handleError(progressUI, err.Error())
|
handleError(progressUI, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -417,76 +414,33 @@ func (s *serviceClient) collectDebugData(
|
|||||||
state *debugInitialState,
|
state *debugInitialState,
|
||||||
params *debugCollectionParams,
|
params *debugCollectionParams,
|
||||||
progress *progressUI,
|
progress *progressUI,
|
||||||
) (string, error) {
|
) error {
|
||||||
ctx, cancel := context.WithTimeout(s.ctx, params.duration)
|
ctx, cancel := context.WithTimeout(s.ctx, params.duration)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
startProgressTracker(ctx, &wg, params.duration, progress)
|
startProgressTracker(ctx, &wg, params.duration, progress)
|
||||||
|
|
||||||
if err := s.configureServiceForDebug(conn, state, params.enablePersistence); err != nil {
|
if err := s.configureServiceForDebug(conn, state, params.enablePersistence); err != nil {
|
||||||
return "", err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
pm := profilemanager.NewProfileManager()
|
|
||||||
var profName string
|
|
||||||
if activeProf, err := pm.GetActiveProfile(); err == nil {
|
|
||||||
profName = activeProf.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
postUpStatus, err := conn.Status(s.ctx, &proto.StatusRequest{GetFullPeerStatus: true})
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("Failed to get post-up status: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var postUpStatusOutput string
|
|
||||||
if postUpStatus != nil {
|
|
||||||
if full := postUpStatus.GetFullStatus(); full != nil {
|
|
||||||
overview := nbstatus.ConvertToStatusOutputOverview(full, params.anonymize, postUpStatus.GetDaemonVersion(), "", nil, nil, nil, "", profName)
|
|
||||||
postUpStatusOutput = nbstatus.ParseToFullDetailSummary(overview)
|
|
||||||
} else {
|
|
||||||
log.Warn("debug bundle: daemon response missing FullStatus after post-up")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
headerPostUp := fmt.Sprintf("----- NetBird post-up - Timestamp: %s", time.Now().Format(time.RFC3339))
|
|
||||||
statusOutput := fmt.Sprintf("%s\n%s", headerPostUp, postUpStatusOutput)
|
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
progress.progressBar.Hide()
|
progress.progressBar.Hide()
|
||||||
progress.statusLabel.SetText("Collecting debug data...")
|
progress.statusLabel.SetText("Collecting debug data...")
|
||||||
|
|
||||||
preDownStatus, err := conn.Status(s.ctx, &proto.StatusRequest{GetFullPeerStatus: true})
|
return nil
|
||||||
if err != nil {
|
|
||||||
log.Warnf("Failed to get pre-down status: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var preDownStatusOutput string
|
|
||||||
if preDownStatus != nil {
|
|
||||||
if full := preDownStatus.GetFullStatus(); full != nil {
|
|
||||||
overview := nbstatus.ConvertToStatusOutputOverview(full, params.anonymize, preDownStatus.GetDaemonVersion(), "", nil, nil, nil, "", profName)
|
|
||||||
preDownStatusOutput = nbstatus.ParseToFullDetailSummary(overview)
|
|
||||||
} else {
|
|
||||||
log.Warn("debug bundle: daemon response missing FullStatus after pre-down")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
headerPreDown := fmt.Sprintf("----- NetBird pre-down - Timestamp: %s - Duration: %s",
|
|
||||||
time.Now().Format(time.RFC3339), params.duration)
|
|
||||||
statusOutput = fmt.Sprintf("%s\n%s\n%s", statusOutput, headerPreDown, preDownStatusOutput)
|
|
||||||
|
|
||||||
return statusOutput, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the debug bundle with collected data
|
// Create the debug bundle with collected data
|
||||||
func (s *serviceClient) createDebugBundleFromCollection(
|
func (s *serviceClient) createDebugBundleFromCollection(
|
||||||
conn proto.DaemonServiceClient,
|
conn proto.DaemonServiceClient,
|
||||||
params *debugCollectionParams,
|
params *debugCollectionParams,
|
||||||
statusOutput string,
|
|
||||||
progress *progressUI,
|
progress *progressUI,
|
||||||
) error {
|
) error {
|
||||||
progress.statusLabel.SetText("Creating debug bundle with collected logs...")
|
progress.statusLabel.SetText("Creating debug bundle with collected logs...")
|
||||||
|
|
||||||
request := &proto.DebugBundleRequest{
|
request := &proto.DebugBundleRequest{
|
||||||
Anonymize: params.anonymize,
|
Anonymize: params.anonymize,
|
||||||
Status: statusOutput,
|
|
||||||
SystemInfo: params.systemInfo,
|
SystemInfo: params.systemInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,26 +543,8 @@ func (s *serviceClient) createDebugBundle(anonymize bool, systemInfo bool, uploa
|
|||||||
return nil, fmt.Errorf("get client: %v", err)
|
return nil, fmt.Errorf("get client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pm := profilemanager.NewProfileManager()
|
|
||||||
var profName string
|
|
||||||
if activeProf, err := pm.GetActiveProfile(); err == nil {
|
|
||||||
profName = activeProf.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
statusResp, err := conn.Status(s.ctx, &proto.StatusRequest{GetFullPeerStatus: true})
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("failed to get status for debug bundle: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var statusOutput string
|
|
||||||
if statusResp != nil {
|
|
||||||
overview := nbstatus.ConvertToStatusOutputOverview(statusResp.GetFullStatus(), anonymize, statusResp.GetDaemonVersion(), "", nil, nil, nil, "", profName)
|
|
||||||
statusOutput = nbstatus.ParseToFullDetailSummary(overview)
|
|
||||||
}
|
|
||||||
|
|
||||||
request := &proto.DebugBundleRequest{
|
request := &proto.DebugBundleRequest{
|
||||||
Anonymize: anonymize,
|
Anonymize: anonymize,
|
||||||
Status: statusOutput,
|
|
||||||
SystemInfo: systemInfo,
|
SystemInfo: systemInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user