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] Add upgrade CLI to initiate upgrade of Agent locally #21425

Merged
merged 7 commits into from
Oct 5, 2020

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Sep 30, 2020

What does this PR do?

Adds a new upgrade CLI command that communicates with the running Elastic Agent to perform self-upgrading. This also allows a local upgrade to a new build using the --source-uri file://${path} command line flag.

Why is it important?

To allow upgrading of the installed Elastic Agent, as well as to help with testing the upgrade process because of the allowed file:// prefix in the --source-uri.

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

Using a properly installed Elastic Agent with ./elastic-agent install. You can initiate an upgrade:

$ elastic-agent upgrade 8.0.0

The above will fail because there is no pushed 8.0.0, but using the same command and the added --source-uri upgrading can be tested.

$ elastic-agent upgrade 8.0.0 --source-uri file://$PWD/build/distributions

This requires that the branch was build with DEV on so that the *.asc files are not required DEV=true mag package. You can point it to the same installed version but that will result in the following error:

$ elastic-agent upgrade 8.0.0 --source-uri file://$PWD/build/distributions
The upgrade process of Elastic Agent is currently EXPERIMENTAL and should not be used in production
Failed trigger upgrade of daemon: upgrading to same version: /go/src/github.com/elastic/beats/x-pack/elastic-agent/pkg/agent/application/upgrade/upgrade.go[103]: unknown error

Adding a commit and rebuilding will result in a new version that will successfully upgrade.

$ elastic-agent upgrade 8.0.0 --source-uri file://$PWD/build/distributions
The upgrade process of Elastic Agent is currently EXPERIMENTAL and should not be used in production
Upgrade triggered to version 8.0.0, Elastic Agent is currently restarting

Related issues

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Team:Ingest Management)

@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 30, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 30, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #21425 updated]

  • Start Time: 2020-10-05T17:50:27.659+0000

  • Duration: 33 min 8 sec

Test stats 🧪

Test Results
Failed 0
Passed 1384
Skipped 4
Total 1388

@@ -205,6 +206,7 @@ func newManaged(
[]context.CancelFunc{managedApplication.cancelCtxFn},
reexec,
acker)
uc.SetUpgrader(managedApplication.upgrader)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we allow to upgrade agent when enrolled?

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 think we should allow it, but I can disable it if we think that is correct.

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.

Code LGTM, not sure if we should enable manual upgrade when connected to fleet, but code wise it looks ok

@blakerouse
Copy link
Contributor Author

Switched it to not allow local upgrade when Agent is controlled by Fleet.

@blakerouse blakerouse merged commit c858dd0 into elastic:master Oct 5, 2020
@blakerouse blakerouse deleted the agent-upgrade-cli branch October 5, 2020 18:39
blakerouse added a commit to blakerouse/beats that referenced this pull request Oct 5, 2020
…lastic#21425)

* Add new upgrade command to initiate a local upgrade of Elastic Agent.

* Update drop path with file:// prefix is defined.

* Add comment.

* Add missing new line.

* Add changelog.

* Prevent upgrading of Agent locally when connected to Fleet.

* Fixes from rebase.

(cherry picked from commit c858dd0)
blakerouse added a commit that referenced this pull request Oct 6, 2020
…21425) (#21542)

* Add new upgrade command to initiate a local upgrade of Elastic Agent.

* Update drop path with file:// prefix is defined.

* Add comment.

* Add missing new line.

* Add changelog.

* Prevent upgrading of Agent locally when connected to Fleet.

* Fixes from rebase.

(cherry picked from commit c858dd0)
v1v added a commit to v1v/beats that referenced this pull request Oct 6, 2020
* upstream/master:
  [CI] Setup git config globally (elastic#21562)
  docs: update generate_fields_docs.py (elastic#21359)
  Add support for additional fields from V2 ALB logs (elastic#21540)
  Move Prometheus query & remote_write to GA (elastic#21507)
  feat: add a new step to run the e2e tests for certain parts of Beats (elastic#21100)
  [Elastic Agent] Add elastic agent ID and version to events from filebeat and metricbeat. (elastic#21543)
  Release cloudfoundry input and processor as GA (elastic#21525)
  [Packetbeat] New SIP protocol (elastic#21221)
  [Filebeat][New Module] Add support for Microsoft MTP / 365 Defender (elastic#21446)
  [Beats][pytest] Asserting if filebeat logs include errors (elastic#20999)
  junipersrx-module initial release (elastic#20017)
  Add a persistent cache for cloudfoundry metadata based on badger (elastic#20775)
  Add missing changelog entry for cisco umbrella (elastic#21550)
  [Elastic Agent] Add upgrade CLI to initiate upgrade of Agent locally (elastic#21425)
  Enable filestream input (elastic#21533)
  Add filestream input reader (elastic#21481)
  [CI] fix 'no matches found within 10000' (elastic#21466)
  Fix billing.go aws.GetStartTimeEndTime (elastic#21531)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Elastic Agent] Add ability to communicate and control the running agent daemon.
3 participants