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

Use only fs.NewDownloader for file://. #3682

Merged
merged 4 commits into from
Nov 6, 2023

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Nov 1, 2023

What does this PR do?

Changes the upgrade artifacts fetcher to only use the fs.NewDownloader when a --source-uri is passed with file:// prefix.

Why is it important?

Ensures that when a file:// source URI is provided that a file will never be downloaded from the artifacts API. Upgrade requested to use a local file it should only look there.

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 (already used in tests)

How to test this PR locally

$ elastic-agent upgrade --skip-verify --source-uri file:///home/doesnt-exist 8.12.0-SNAPSHOT
Error: Failed trigger upgrade of daemon: failed download of agent binary: unable to download package: package '/home/ubuntu/elastic-agent-8.12.0-SNAPSHOT-linux-arm64.tar.gz' not found: open /home/ubuntu/elastic-agent-8.12.0-SNAPSHOT-linux-arm64.tar.gz: permission denied
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.12/fleet-troubleshooting.html

@blakerouse blakerouse added Team:Elastic-Agent Label for the Agent team backport-skip labels Nov 1, 2023
@blakerouse blakerouse self-assigned this Nov 1, 2023
@blakerouse blakerouse requested a review from a team as a code owner November 1, 2023 15:13
@elasticmachine
Copy link
Collaborator

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

@elasticmachine
Copy link
Collaborator

elasticmachine commented Nov 1, 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-11-06T14:40:23.037+0000

  • Duration: 50 min 23 sec

❕ Flaky test report

No test was executed to be analysed.

🤖 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!)

Copy link
Contributor

@michalpristas michalpristas left a comment

Choose a reason for hiding this comment

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

looks good


// set specific downloader, local file just uses the fs.NewDownloader
// no fallback is allowed because it was requested that this specific source be used
factory = func(ver *agtversion.ParsedSemVer, l *logger.Logger, config *artifact.Config, d *details.Details) (download.Downloader, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can even move this to fs and have factory = fs.NewDownloaderFactory to make it a bit more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i didn't do that as the factory interface is private, takes arguments that the download module doesn't really need to import as its not used

@blakerouse
Copy link
Contributor Author

buildkite test this

@blakerouse blakerouse enabled auto-merge (squash) November 6, 2023 14:39
@cmacknz
Copy link
Member

cmacknz commented Nov 6, 2023

Buildkite failure is only in the merge coverage reports step, force merging.

@cmacknz cmacknz disabled auto-merge November 6, 2023 16:40
@cmacknz cmacknz merged commit dba2166 into elastic:main Nov 6, 2023
9 of 10 checks passed
@blakerouse blakerouse deleted the upgrade-specific-fs-downloader branch November 6, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants