[client] Add full sync response to debug bundle (#4287)

This commit is contained in:
Viktor Liu
2025-08-05 14:55:50 +02:00
committed by GitHub
parent 92ce5afe80
commit 3d3c4c5844
10 changed files with 298 additions and 221 deletions

View File

@@ -27,15 +27,16 @@ func (s *Server) DebugBundle(_ context.Context, req *proto.DebugBundleRequest) (
s.mutex.Lock()
defer s.mutex.Unlock()
networkMap, err := s.getLatestNetworkMap()
syncResponse, err := s.getLatestSyncResponse()
if err != nil {
log.Warnf("failed to get latest network map: %v", err)
log.Warnf("failed to get latest sync response: %v", err)
}
bundleGenerator := debug.NewBundleGenerator(
debug.GeneratorDependencies{
InternalConfig: s.config,
StatusRecorder: s.statusRecorder,
NetworkMap: networkMap,
SyncResponse: syncResponse,
LogFile: s.logFile,
},
debug.BundleConfig{
@@ -192,26 +193,25 @@ func (s *Server) SetLogLevel(_ context.Context, req *proto.SetLogLevelRequest) (
return &proto.SetLogLevelResponse{}, nil
}
// SetNetworkMapPersistence sets the network map persistence for the server.
func (s *Server) SetNetworkMapPersistence(_ context.Context, req *proto.SetNetworkMapPersistenceRequest) (*proto.SetNetworkMapPersistenceResponse, error) {
// SetSyncResponsePersistence sets the sync response persistence for the server.
func (s *Server) SetSyncResponsePersistence(_ context.Context, req *proto.SetSyncResponsePersistenceRequest) (*proto.SetSyncResponsePersistenceResponse, error) {
s.mutex.Lock()
defer s.mutex.Unlock()
enabled := req.GetEnabled()
s.persistNetworkMap = enabled
s.persistSyncResponse = enabled
if s.connectClient != nil {
s.connectClient.SetNetworkMapPersistence(enabled)
s.connectClient.SetSyncResponsePersistence(enabled)
}
return &proto.SetNetworkMapPersistenceResponse{}, nil
return &proto.SetSyncResponsePersistenceResponse{}, nil
}
// getLatestNetworkMap returns the latest network map from the engine if network map persistence is enabled
func (s *Server) getLatestNetworkMap() (*mgmProto.NetworkMap, error) {
func (s *Server) getLatestSyncResponse() (*mgmProto.SyncResponse, error) {
cClient := s.connectClient
if cClient == nil {
return nil, errors.New("connect client is not initialized")
}
return cClient.GetLatestNetworkMap()
return cClient.GetLatestSyncResponse()
}