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

Cherry-pick #20359 to 7.x: [Elastic Agent] Improve version, restart, enroll CLI commands #20431

Merged
merged 2 commits into from
Aug 4, 2020

Conversation

blakerouse
Copy link
Contributor

Cherry-pick of PR #20359 to 7.x branch. Original message:

What does this PR do?

version has been changed to show both the version of the running daemon and the version of the executing binary. Along with --binary-only argument to skip connecting and reporting the version of the daemon and --yaml to print machine parsable version information.

enroll has been updated to connect to the running daemon and perform a restart. This is because after enroll if the daemon is already started it needs to be restart to load the new mode of communicating with Fleet.

restart is a new command added to just trigger restart of the current running daemon. This is very useful to test re-execution (especially on Windows, because SIGHUP doesn't exist on Windows).

This also includes some fixes that I thought was in my last PR for Windows, except I forgot to commit before merging the PR.

Why is it important?

To show the current running daemon version of the Agent, which could be different then the user executing binary. To improve the UX of the enroll command to re-start the daemon once successfully enrolled. To help debugging of re-execution.

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.

Related issues

Logs

version

blake@MacBook-Pro elastic-agent % ./elastic_agent version
Daemon: 8.0.0 (build: unknown at 0001-01-01 00:00:00 +0000 UTC)
Binary: 8.0.0 (build: unknown at 0001-01-01 00:00:00 +0000 UTC)
blake@MacBook-Pro elastic-agent % ./elastic_agent version --yaml
binary:
  version: 8.0.0
  commit: unknown
  build_time: 0001-01-01T00:00:00Z
  snapshot: false
daemon:
  version: 8.0.0
  commit: unknown
  build_time: 0001-01-01T00:00:00Z
  snapshot: false
blake@MacBook-Pro elastic-agent % ./elastic_agent version --binary-only --yaml
binary:
  version: 8.0.0
  commit: unknown
  build_time: 0001-01-01T00:00:00Z
  snapshot: false

enroll

blake@MacBook-Pro elastic-agent % ./elastic_agent enroll http://localhost:5061 LVY3Tm9ITUItQ1RKdjBvVU9nN1Q6WkNQQTdsMUlUbWVrOWRsQ3c3QUszdw --insecure --force
The Elastic Agent is currently in BETA and should not be used in production
2020-07-30T13:41:11.926-0400	DEBUG	kibana/client.go:170	Request method: POST, path: /api/ingest_manager/fleet/agents/enroll
Successfully enrolled the Elastic Agent.
Successfully triggered restart on running Elastic Agent.

restart

blake@MacBook-Pro elastic-agent % ./elastic_agent restart
blake@MacBook-Pro elastic-agent %

…c#20359)

* Add improve version CLI cmd.

* Add new restart cmd. Perform restart at end of enroll.

* Fix yaml annotations on version struct.

* Fix control.Address on Windows.

* Fix control.Address on Windows.

* Fix windows dialer.

* Fix control.Address on Windows.

* Add to CHANGELOG.

* Review cleanups.

* Fix go vet.

* Update talking to communicating.

(cherry picked from commit 77b3b07)
…107 characters (elastic#20426)

* Fix agent control socket path to always be less than 107 characters.

* Use os.TempDir.

* Don't use os.TempDir.
@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 Aug 4, 2020
@blakerouse blakerouse self-assigned this Aug 4, 2020
@blakerouse
Copy link
Contributor Author

This PR also includes #20426.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20431 opened]

  • Start Time: 2020-08-04T14:36:57.164+0000

  • Duration: 37 min 14 sec

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 g:eyes:d

@blakerouse blakerouse merged commit 9615f41 into elastic:7.x Aug 4, 2020
@blakerouse blakerouse deleted the backport_20359_7.x branch August 4, 2020 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants