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

Elastic-agent snapshot lookup will use proxy settings #27904

Merged
merged 1 commit into from
Sep 14, 2021

Conversation

michel-laterman
Copy link
Contributor

@michel-laterman michel-laterman commented Sep 13, 2021

What does this PR do?

Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(agent.download in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.

Why is it important?

Allows agent to upgrade to snapshot versions when agents are behind an Internet proxy.

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.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

  1. Deploy agent behind an Internet proxy.
  2. Add a agent.download.proxy_url setting to fleet.yml.
  3. Trigger an upgrade to a newer snapshot version through the Fleet UI

Related issues

@michel-laterman michel-laterman added bug Team:Elastic-Agent Label for the Agent team labels Sep 13, 2021
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Sep 13, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 13, 2021

💚 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: 2021-09-13T22:24:23.086+0000

  • Duration: 79 min 53 sec

  • Commit: f8410a7

Test stats 🧪

Test Results
Failed 0
Passed 7044
Skipped 16
Total 7060

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 7044
Skipped 16
Total 7060

Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(`agent.download` in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.
Copy link
Contributor

@EricDavisX EricDavisX left a comment

Choose a reason for hiding this comment

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

PR looks fairly simple and contained - this is great. Still, is there any benefit or simple place to add in a test for the new config? I guess that would entail possibly adding in more error handling to the code base too. Might be particularly needed if the values in the config are not formatted correctly or if the url exists but the artifact isn't found?

@michel-laterman
Copy link
Contributor Author

i've tested that the elastic-agent can now (correctly) download snapshot artifacts when behind a proxy.

@michel-laterman michel-laterman marked this pull request as ready for review September 14, 2021 20:49
@elasticmachine
Copy link
Collaborator

Pinging @elastic/agent (Team:Agent)

@michel-laterman michel-laterman added backport-v7.15.0 Automated backport with mergify backport-v7.16.0 Automated backport with mergify labels Sep 14, 2021
Copy link
Contributor

@blakerouse blakerouse 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.

@michel-laterman michel-laterman added the backport-v7.14.0 Automated backport with mergify label Sep 14, 2021
@michel-laterman
Copy link
Contributor Author

@EricDavisX, my fix here is to apply an existing config option to another request when retrieving the snapshot artifacts. Config validation already has an issue made for tracking it (#26685), we can also ensure that url values are correct as part of that issue.
I think if the artifact is not found (either by the search or subsequent request), the error is passed up and logged (and i believe that the agent will appear as unhealthy or reconfiguring for a while before aborting the update).

@michel-laterman michel-laterman merged commit 0ee910f into elastic:master Sep 14, 2021
@michel-laterman michel-laterman deleted the snapshot-proxy-fix branch September 14, 2021 21:09
mergify bot pushed a commit that referenced this pull request Sep 14, 2021
Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(`agent.download` in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.

(cherry picked from commit 0ee910f)
mergify bot pushed a commit that referenced this pull request Sep 14, 2021
Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(`agent.download` in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.

(cherry picked from commit 0ee910f)
mergify bot pushed a commit that referenced this pull request Sep 14, 2021
Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(`agent.download` in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.

(cherry picked from commit 0ee910f)
michel-laterman added a commit that referenced this pull request Sep 14, 2021
Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(`agent.download` in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.

(cherry picked from commit 0ee910f)

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
michel-laterman added a commit that referenced this pull request Sep 14, 2021
Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(`agent.download` in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.

(cherry picked from commit 0ee910f)

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
michel-laterman added a commit that referenced this pull request Sep 14, 2021
…settings (#27926)

* Elastic-agent snapshot lookup will use proxy settings (#27904)

Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(`agent.download` in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.

(cherry picked from commit 0ee910f)

* Fix CHANGELOG

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Co-authored-by: michel-laterman <michel.laterman@elastic.co>
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
Change the HTTP client from the standard library client to one built
from the http settings supplied to the artifact downloader
(`agent.download` in fleet.yml) so that proxy settings are used for the
initial request to find the artifact location as well as the subsequent
download.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.14.0 Automated backport with mergify backport-v7.15.0 Automated backport with mergify backport-v7.16.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.

Elastic-Agent snapshot downloader ignores proxy settings
4 participants