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

Error "failed to copy source directory (C:\Program Files\Elastic-Agent)" in powershell is displayed on installing the agent after enrolling and running it #21744

Closed
ghost opened this issue Oct 13, 2020 · 8 comments · Fixed by #21772

Comments

@ghost
Copy link

ghost commented Oct 13, 2020

Kibana version:
Kibana: 7.10.0 BC1 cloud environment with commit 7a9f9132fffd8567ce3b985dde8bea6529e8fa3c

Elasticsearch version:
Elasticsearch: 7.10.0 BC1 cloud environment

Host OS and Browser version:
Windows , All

Original install method (e.g. download page, yum, from source, etc.):
7.10.0 BC1 cloud environment deployed from Staging cloud platform https://staging.found.no

Description
Error "failed to copy source directory (C:\Program Files\Elastic-Agent)" in powershell is displayed on installing the agent after enrolling and running it

Preconditions

  1. 7.10.0 BC1 cloud environment should be available(with commit 7a9f9132fffd8567ce3b985dde8bea6529e8fa3c).
  2. Login to the above environment with elastic superuser.
  3. 7.10.0 BC1 agent downloaded from https://staging.elastic.co/7.10.0-116336aa/downloads/beats/elastic-agent/elastic-agent-7.10.0-windows-x86_64.zip
  4. A policy should exist.

Steps to Reproduce

  1. RDP to the endpoint and place the agent in C:/ProgramFiles directory
  2. Unarchive the agent
  3. Open powershell as admin and execute the enroll and run command(say) :
    .\elastic-agent enroll https://217abe597a6b48bba2b7bb82bd4aa8bb.us-central1.gcp.foundit.no:9243 TlhCMElYVUJsNGo3WW9rbDJ6clg6UWg2UDlYQUlUOTJNLWQ2QWNKUE5Edw==
    .\elastic-agent.exe run
  4. Execute ./elastic-agent install
  5. Observe that following error is displayed.
    "Error: failed to copy source directory (C:\Program Files\Elastic-Agent) to destination (C:\Program Files\Elastic\Agent):
    read C:\Program Files\Elastic-Agent\data\agent.lock: The process cannot access the file because another process has loc
    ked a portion of the file."

Test data
N/A

Impacted Test case id
N/A

Actual Result
Error "failed to copy source directory (C:\Program Files\Elastic-Agent)" is displayed in powershell on installing the agent after enrolling and running it

Expected Result
User should be successfully able to install the agent after enrolling and running it.

What's working

  • N/A

What's not working

  • N/A

Screenshot
powershell_error

Logs
agent lock file.zip

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 13, 2020
@ghost ghost self-assigned this Oct 13, 2020
@elasticmachine
Copy link
Collaborator

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

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Oct 13, 2020
@ghost ghost added the v7.10.0 label Oct 13, 2020
@ghost
Copy link
Author

ghost commented Oct 13, 2020

@vipulsrivastava-qasource Please review the bug.

@ghost ghost assigned EricDavisX Oct 13, 2020
@ghost
Copy link

ghost commented Oct 13, 2020

Reviewed and assigned to @EricDavisX

@blakerouse
Copy link
Contributor

Based on the reported error seems that you have an Elastic Agent running from inside that directory. At that point it cannot be installed. Ensure that you have no Elastic Agent running in that directory, then run the install command.

@EricDavisX EricDavisX removed their assignment Oct 13, 2020
@EricDavisX
Copy link
Contributor

EricDavisX commented Oct 13, 2020

@blakerouse while QA is re-testing this, I would ask if you think its useful to cite a ticket to make 'install' command more flexible or report better in the case it can detect an agent running in this case.

Rahul, regardless of the above, I wanted to ask if we can make sure we have a variation on this test case covered somewhere as:

  • RDP to the endpoint and place the agent in C:/ProgramFiles directory
  • Unarchive the agent
  • Open powershell as admin and Execute ./elastic-agent install with default policy
    verify agent comes on line and is functional
  • then execute the enroll command on the host in powershell to move it to a different policy:
    .\elastic-agent enroll adfasdfasdf.asdf:9243 adsfasdfsdf==
    verify it correctly changes to the new policy and comes up fine and is still functional

@ghost
Copy link
Author

ghost commented Oct 14, 2020

Hi @blake

Thank you for sharing the feedback.

We have tested the above scenario by stopping the elastic-agent(press ctrl+c in powershell) in C:\Program Files\Elastic-Agent and found that user is able to install the elastic-agent from the same directory(C:\Program Files\Elastic-Agent) using below command :-
./elastic-agent install

Screenshot:
install_to_same_policy

@EricDavisX We have performed the scenario shared and found that agent remains in Enrolling state with no activity logs.
We have reported bug #21794 and created testcase https://elastic.testrail.io/index.php?/cases/view/34391 for the same.

@EricDavisX
Copy link
Contributor

excellent - with this I think we can close it. Thanks

@ghost
Copy link
Author

ghost commented Nov 25, 2020

Bug Conversion:

Testcase already exists for this ticket.
https://elastic.testrail.io/index.php?/cases/view/34391

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants