Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace timer with ticker in download progress reporter #3548

Merged

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Oct 5, 2023

What does this PR do?

This PR fixes a bug in the progress logger being used while downloading the Agent artifact during the upgrade process. Prior to this PR the progress logger used a time.Timer to log progress of the download. With this PR, the progress logger uses a time.Ticker instead.

Why is it important?

The progress logger should periodically log progress of the download, not just once (after a delay).

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Related issues

@ycombinator ycombinator added Team:Elastic-Agent Label for the Agent team >bug backport-v8.11.0 Automated backport with mergify labels Oct 5, 2023
@ycombinator ycombinator requested a review from a team as a code owner October 5, 2023 18:31
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@@ -223,7 +227,6 @@ func (e *Downloader) downloadFile(ctx context.Context, artifactName, filename, f
type downloadProgressReporter struct {
log progressLogger
sourceURI string
timeout time.Duration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unrelated to this PR per se. But I noticed while working on this PR that this field was never being used, so I'm deleting it as part of this PR.

@@ -75,11 +75,11 @@ func TestDownloadBodyError(t *testing.T) {
}

func TestDownloadLogProgressWithLength(t *testing.T) {
fileSize := 100 * units.MiB
fileSize := 100 * units.MB
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to make the math easier.

@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 5, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-10-10T17:39:59.913+0000

  • Duration: 28 min 5 sec

Test stats 🧪

Test Results
Failed 0
Passed 6525
Skipped 59
Total 6584

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 5, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 98.795% (82/83) 👍
Files 67.114% (200/298) 👍
Classes 65.766% (365/555) 👍
Methods 53.033% (1154/2176) 👍
Lines 38.617% (13180/34130) 👍 0.027
Conditionals 100.0% (0/0) 💚

Copy link
Member

@pchila pchila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ycombinator ycombinator enabled auto-merge (squash) October 10, 2023 17:38
@ycombinator ycombinator force-pushed the bugfix-upgrade-progress-reporter branch from 64d234a to adb0a13 Compare October 10, 2023 17:39
@elastic-sonarqube
Copy link

@ycombinator ycombinator merged commit 1c5010f into elastic:main Oct 10, 2023
11 checks passed
@ycombinator ycombinator deleted the bugfix-upgrade-progress-reporter branch October 10, 2023 19:46
mergify bot pushed a commit that referenced this pull request Oct 10, 2023
* Replace timer with ticker in download progress reporter

* Adding CHANGELOG entry

* Refactoring: extracting common code into helper function

(cherry picked from commit 1c5010f)
ycombinator added a commit that referenced this pull request Oct 16, 2023
* Replace timer with ticker in download progress reporter

* Adding CHANGELOG entry

* Refactoring: extracting common code into helper function

(cherry picked from commit 1c5010f)

Co-authored-by: Shaunak Kashyap <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.11.0 Automated backport with mergify >bug Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants