From 5f28aafdcf8709c545aa7e6b7ff47e4d2cb8a6a9 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Mon, 27 May 2024 18:26:38 +0100 Subject: [PATCH] diagnostics: cherry pick speedtest disable (#10509) Cherry pick PR #10449 into the release branch --- diagnostics/client.go | 4 +++- diagnostics/speedtest.go | 19 ++++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/diagnostics/client.go b/diagnostics/client.go index 284e46c1..df5b04a7 100644 --- a/diagnostics/client.go +++ b/diagnostics/client.go @@ -10,6 +10,7 @@ import ( type DiagnosticClient struct { metricsMux *http.ServeMux dataDirPath string + speedTest bool syncStats SyncStatistics snapshotFileList SnapshoFilesList @@ -26,10 +27,11 @@ type DiagnosticClient struct { networkSpeedMutex sync.Mutex } -func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string) *DiagnosticClient { +func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string, speedTest bool) *DiagnosticClient { return &DiagnosticClient{ metricsMux: metricsMux, dataDirPath: dataDirPath, + speedTest: speedTest, syncStats: SyncStatistics{}, hardwareInfo: HardwareInfo{}, snapshotFileList: SnapshoFilesList{}, diff --git a/diagnostics/speedtest.go b/diagnostics/speedtest.go index d2c463bb..77da08ac 100644 --- a/diagnostics/speedtest.go +++ b/diagnostics/speedtest.go @@ -8,22 +8,11 @@ import ( ) func (d *DiagnosticClient) setupSpeedtestDiagnostics(rootCtx context.Context) { - ticker := time.NewTicker(30 * time.Minute) go func() { - d.networkSpeedMutex.Lock() - d.networkSpeed = d.runSpeedTest(rootCtx) - d.networkSpeedMutex.Unlock() - - for { - select { - case <-ticker.C: - d.networkSpeedMutex.Lock() - d.networkSpeed = d.runSpeedTest(rootCtx) - d.networkSpeedMutex.Unlock() - case <-rootCtx.Done(): - ticker.Stop() - return - } + if d.speedTest { + d.networkSpeedMutex.Lock() + d.networkSpeed = d.runSpeedTest(rootCtx) + d.networkSpeedMutex.Unlock() } }() }