diff --git a/internal/pkg/agent/application/upgrade/artifact/download/http/progress_observer.go b/internal/pkg/agent/application/upgrade/artifact/download/http/progress_observer.go index 77b0477a3cc..08977cccc85 100644 --- a/internal/pkg/agent/application/upgrade/artifact/download/http/progress_observer.go +++ b/internal/pkg/agent/application/upgrade/artifact/download/http/progress_observer.go @@ -114,14 +114,14 @@ func (dpObs *detailsProgressObserver) Report(sourceURI string, timePast time.Dur dpObs.mu.Lock() defer dpObs.mu.Unlock() - dpObs.upgradeDetails.SetDownloadPercent(percentComplete) + dpObs.upgradeDetails.SetDownloadProgress(percentComplete, downloadRate) } func (dpObs *detailsProgressObserver) ReportCompleted(sourceURI string, timePast time.Duration, downloadRate float64) { dpObs.mu.Lock() defer dpObs.mu.Unlock() - dpObs.upgradeDetails.SetDownloadPercent(1) + dpObs.upgradeDetails.SetDownloadProgress(1, downloadRate) } func (dpObs *detailsProgressObserver) ReportFailed(sourceURI string, timePast time.Duration, downloadedBytes, totalBytes, percentComplete, downloadRate float64, err error) { diff --git a/internal/pkg/agent/application/upgrade/details/details.go b/internal/pkg/agent/application/upgrade/details/details.go index 6512b6ac96d..f376486685d 100644 --- a/internal/pkg/agent/application/upgrade/details/details.go +++ b/internal/pkg/agent/application/upgrade/details/details.go @@ -24,6 +24,7 @@ type Details struct { type DetailsMetadata struct { ScheduledAt string DownloadPercent float64 + DownloadRate float64 // FailedState is the state an upgrade was in if/when it failed. Use the // Fail() method of UpgradeDetails to correctly record details when @@ -56,13 +57,14 @@ func (d *Details) SetState(s State) { d.notifyObservers() } -// SetDownloadPercent is a convenience method to set the download percent +// SetDownloadProgress is a convenience method to set the download percent // when the upgrade is in UPG_DOWNLOADING state. -func (d *Details) SetDownloadPercent(downloadPercent float64) { +func (d *Details) SetDownloadProgress(downloadPercent, downloadRate float64) { d.mu.Lock() defer d.mu.Unlock() d.Metadata.DownloadPercent = downloadPercent + d.Metadata.DownloadRate = downloadRate d.notifyObservers() }