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 #21206 to 7.x: [Elastic Agent] Add install/uninstall sub-command #21387

Merged
merged 1 commit into from
Sep 30, 2020

Conversation

blakerouse
Copy link
Contributor

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

What does this PR do?

Adds a new install and uninstall command to the Elastic Agent.

install is used to install the Elastic Agent onto the system persistently. This will place Elastic Agent in the correct location for the platform, register it as a service and start the service. install also has the ability to detect if an installation is broken and offer the option to overwrite that installation with the executing non-installed Elastic Agent. install cannot be called from the installed version on the system

uninstall is used to uninstall the Elastic Agent on the current system. This can only be called from the installed Elastic Agent. If the uninstall command is executed from a non-installed Elastic Agent it will provide information on how to run it from the installed Elastic Agent, if it is installed on the system.

Why is it important?

Provides a uniform path to installed the Elastic Agent onto the system, as well as allows that Elastic Agent to be self-upgradable.

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 (impossible to unit test)
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

With a built package run

./elastic-agent install

Once installed run

elastic-agent uninstall

Related issues

* Add install command.

* Fix binary name on darwin.

* Fix install of mkdir.

* Update shell wrapper path for darwin.

* Add ability to fix broken installation.

* Fix issues with install/uninstall.

* Add dedicated uninstall command.

* Add enrollment at the end of install command.

* Fix installation of shell wrapper.

* Fix root_windows.go

* Fix uninstall on Windows.

* Add sleep to removal on Windows.

* Fix sleep to timeout in uninstall subcommand.

* Fix uninstall for nested timeout with cmd.exe.

* Fix uninstall on windows to actually sleep correctly.

* Fix formatting.

* Add changelog.

* Fixes for mage check.

* Create the symlink on Windows on install, fix issue with enroll questions during install.

* Refactor to remove the paths.yml and symlink dance on Windows, because new install command handles that.

* Cleanup repeat GA warning.

* Fix symlink on Windows.

* Fix control socket on windows.

* Fix socket path and authority on Windows.

* Fix username matching for SYSTEM.

* Fix socket path on darwin.

* Fix darwin service name. Fix uninstall on systemd.

* Fix install on linux.

* Fix RunningInstalled on Linux.

* Prevent upgrade unless conditions are correct.

* Add ability to force upgradable with DEV=true when built.

* Fixes from code review.

* Fix issue with service description.

(cherry picked from commit 2996b6f)
@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 29, 2020
@blakerouse blakerouse self-assigned this Sep 29, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 29, 2020

💔 Build Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Started by user Blake Rouse, Restarted from build #1, stage Build&Test]

  • Start Time: 2020-09-30T12:31:23.424+0000

  • Duration: 3 min 44 sec

Steps errors

Expand to view the steps failures

  • Name: General Build Step

    • Description: Exception while performing download

    • Duration: 0 min 0 sec

    • Start Time: 2020-09-30T12:34:06.508+0000

    • log

  • Name: General Build Step

    • Description:

    • Duration: 0 min 0 sec

    • Start Time: 2020-09-30T12:34:06.787+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-09-30T12:31:29.111Z] Resume disabled by user, switching to high-performance, low-durability mode.
[2020-09-30T12:31:55.332Z] Still waiting to schedule task
[2020-09-30T12:31:55.333Z] All nodes of label ‘ubuntu-18&&immutable’ are offline
[2020-09-30T12:32:34.598Z] Running on beats-ci-immutable-ubuntu-1804-1601469102531765753 in /var/lib/jenkins/workspace/Beats_beats_PR-21387
[2020-09-30T12:32:34.720Z] �[39;49m[INFO] Override default checkout�[0m
[2020-09-30T12:32:34.802Z] Sleeping for 10 sec
[2020-09-30T12:32:47.742Z] using credential f6c7695a-671e-4f4f-a331-acdce44ff9ba
[2020-09-30T12:32:47.788Z] Wiping out workspace first.
[2020-09-30T12:32:47.816Z] Cloning the remote Git repository
[2020-09-30T12:32:47.816Z] Using shallow clone with depth 3
[2020-09-30T12:32:47.816Z] Avoid fetching tags
[2020-09-30T12:32:47.840Z] Cloning repository git@github.com:elastic/beats.git
[2020-09-30T12:32:47.895Z]  > git init /var/lib/jenkins/workspace/Beats_beats_PR-21387 # timeout=10
[2020-09-30T12:32:47.954Z] Fetching upstream changes from git@github.com:elastic/beats.git
[2020-09-30T12:32:47.954Z]  > git --version # timeout=10
[2020-09-30T12:32:47.967Z]  > git --version # 'git version 2.17.1'
[2020-09-30T12:32:47.968Z] using GIT_SSH to set credentials GitHub user @elasticmachine SSH key
[2020-09-30T12:32:48.035Z]  > git fetch --no-tags --progress -- git@github.com:elastic/beats.git +refs/heads/*:refs/remotes/origin/* # timeout=15
[2020-09-30T12:33:56.176Z] Cleaning workspace
[2020-09-30T12:33:56.194Z] Using shallow fetch with depth 3
[2020-09-30T12:33:56.194Z] Pruning obsolete local branches
[2020-09-30T12:33:57.786Z] Merging remotes/origin/7.x commit 72de6d78185c41d3a4f26a6da774db87985eaaf8 into PR head commit 8b82c8ae4371b2941c82df167ac6678d58d2201e
[2020-09-30T12:33:59.339Z] Merge succeeded, producing 8b82c8ae4371b2941c82df167ac6678d58d2201e
[2020-09-30T12:33:59.340Z] Checking out Revision 8b82c8ae4371b2941c82df167ac6678d58d2201e (PR-21387)
[2020-09-30T12:33:56.138Z]  > git config remote.origin.url git@github.com:elastic/beats.git # timeout=10
[2020-09-30T12:33:56.151Z]  > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
[2020-09-30T12:33:56.164Z]  > git config remote.origin.url git@github.com:elastic/beats.git # timeout=10
[2020-09-30T12:33:56.179Z]  > git rev-parse --verify HEAD # timeout=10
[2020-09-30T12:33:56.183Z] No valid HEAD. Skipping the resetting
[2020-09-30T12:33:56.184Z]  > git clean -fdx # timeout=10
[2020-09-30T12:33:56.199Z] Fetching upstream changes from git@github.com:elastic/beats.git
[2020-09-30T12:33:56.200Z] using GIT_SSH to set credentials GitHub user @elasticmachine SSH key
[2020-09-30T12:33:56.204Z]  > git fetch --no-tags --progress --prune -- git@github.com:elastic/beats.git +refs/pull/21387/head:refs/remotes/origin/PR-21387 +refs/heads/7.x:refs/remotes/origin/7.x # timeout=15
[2020-09-30T12:33:57.795Z]  > git config core.sparsecheckout # timeout=10
[2020-09-30T12:33:57.807Z]  > git checkout -f 8b82c8ae4371b2941c82df167ac6678d58d2201e # timeout=15
[2020-09-30T12:33:59.270Z]  > git remote # timeout=10
[2020-09-30T12:33:59.277Z]  > git config --get remote.origin.url # timeout=10
[2020-09-30T12:33:59.291Z] using GIT_SSH to set credentials GitHub user @elasticmachine SSH key
[2020-09-30T12:33:59.304Z]  > git merge 72de6d78185c41d3a4f26a6da774db87985eaaf8 # timeout=10
[2020-09-30T12:33:59.326Z]  > git rev-parse HEAD^{commit} # timeout=10
[2020-09-30T12:33:59.343Z]  > git config core.sparsecheckout # timeout=10
[2020-09-30T12:33:59.348Z]  > git checkout -f 8b82c8ae4371b2941c82df167ac6678d58d2201e # timeout=15
[2020-09-30T12:34:03.530Z] Commit message: "[Elastic Agent] Add install/uninstall sub-command (#21206)"
[2020-09-30T12:34:03.535Z]  > git rev-list --no-walk 8b82c8ae4371b2941c82df167ac6678d58d2201e # timeout=10
[2020-09-30T12:34:03.596Z] Cleaning workspace
[2020-09-30T12:34:03.598Z]  > git rev-parse --verify HEAD # timeout=10
[2020-09-30T12:34:03.611Z] Resetting working tree
[2020-09-30T12:34:03.611Z]  > git reset --hard # timeout=10
[2020-09-30T12:34:04.085Z]  > git clean -fdx # timeout=10
[2020-09-30T12:34:05.353Z] Timeout set to expire in 2 hr 0 min
[2020-09-30T12:34:05.378Z] The timestamps step is unnecessary when timestamps are enabled for all Pipeline builds.
[2020-09-30T12:34:05.470Z] Stage "Checkout" skipped due to this build restarting at stage "Build&Test"
[2020-09-30T12:34:05.555Z] Stage "Lint" skipped due to this build restarting at stage "Build&Test"
[2020-09-30T12:34:06.477Z] [INFO] unstashV2: JOB_GCS_BUCKET is set. bucket param got precedency instead.
[2020-09-30T12:34:06.502Z] [INFO] unstashV2: JOB_GCS_CREDENTIALS is set. credentialsId param got precedency instead.
[2020-09-30T12:34:06.756Z] [INFO] unstashV2: JOB_GCS_BUCKET is set. bucket param got precedency instead.
[2020-09-30T12:34:06.781Z] [INFO] unstashV2: JOB_GCS_CREDENTIALS is set. credentialsId param got precedency instead.
[2020-09-30T12:34:06.852Z] Error when executing always post condition:
[2020-09-30T12:34:06.858Z] com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
[2020-09-30T12:34:06.858Z] {
[2020-09-30T12:34:06.858Z]   "code" : 404,
[2020-09-30T12:34:06.858Z]   "errors" : [ {
[2020-09-30T12:34:06.858Z]     "domain" : "global",
[2020-09-30T12:34:06.858Z]     "message" : "No such object: beats-ci-temp/Beats/beats/PR-21387-2/source/source.tgz",
[2020-09-30T12:34:06.858Z]     "reason" : "notFound"
[2020-09-30T12:34:06.858Z]   } ],
[2020-09-30T12:34:06.858Z]   "message" : "No such object: beats-ci-temp/Beats/beats/PR-21387-2/source/source.tgz"
[2020-09-30T12:34:06.858Z] }
[2020-09-30T12:34:06.858Z] 	at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)
[2020-09-30T12:34:06.858Z] 	at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
[2020-09-30T12:34:06.858Z] 	at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
[2020-09-30T12:34:06.858Z] 	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
[2020-09-30T12:34:06.858Z] 	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
[2020-09-30T12:34:06.858Z] 	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
[2020-09-30T12:34:06.858Z] 	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
[2020-09-30T12:34:06.858Z] 	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
[2020-09-30T12:34:06.858Z] 	at com.google.jenkins.plugins.util.RequestCallable$1.call(RequestCallable.java:46)
[2020-09-30T12:34:06.858Z] 	at com.google.jenkins.plugins.util.Executor$Default.execute(Executor.java:125)
[2020-09-30T12:34:06.858Z] Caused: com.google.jenkins.plugins.util.NotFoundException
[2020-09-30T12:34:06.858Z] 	at com.google.jenkins.plugins.util.Executor$Default.execute(Executor.java:132)
[2020-09-30T12:34:06.858Z] 	at com.google.jenkins.plugins.util.Executor.execute(Executor.java:49)
[2020-09-30T12:34:06.858Z] 	at com.google.jenkins.plugins.storage.DownloadStep.resolveBucketPath(DownloadStep.java:419)
[2020-09-30T12:34:06.858Z] 	at com.google.jenkins.plugins.storage.DownloadStep.perform(DownloadStep.java:210)
[2020-09-30T12:34:06.858Z] Caused: java.io.IOException: Exception while performing download
[2020-09-30T12:34:06.858Z] 	at com.google.jenkins.plugins.storage.DownloadStep.perform(DownloadStep.java:223)
[2020-09-30T12:34:06.858Z] 	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
[2020-09-30T12:34:06.858Z] 	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
[2020-09-30T12:34:06.858Z] 	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
[2020-09-30T12:34:06.858Z] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[2020-09-30T12:34:06.858Z] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2020-09-30T12:34:06.858Z] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[2020-09-30T12:34:06.858Z] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[2020-09-30T12:34:06.858Z] 	at java.lang.Thread.run(Thread.java:748)
[2020-09-30T12:34:06.858Z] 
[2020-09-30T12:34:07.004Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-21387
[2020-09-30T12:34:07.135Z] [INFO] getVaultSecret: Getting secrets
[2020-09-30T12:34:07.219Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-09-30T12:34:08.139Z] + chmod 755 generate-build-data.sh
[2020-09-30T12:34:08.139Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21387/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21387/runs/2 FAILURE 164443
[2020-09-30T12:34:08.139Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-21387/runs/2/steps/?limit=10000 -o steps-info.json

@blakerouse
Copy link
Contributor Author

CI failures are unrelated to this change.

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

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

backport LGTM.

@blakerouse blakerouse merged commit 385ec4e into elastic:7.x Sep 30, 2020
@blakerouse blakerouse deleted the backport_21206_7.x branch September 30, 2020 21:51
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