Skip to content

Conversation

rdner
Copy link
Member

@rdner rdner commented Apr 5, 2024

What does this PR do?

The upgrade CLI command creates a client, connects to the Elastic Agent server and triggers the upgrade process which is supposed to shut down the agent and start the upgrade. Sometimes, this happens before the client gets a successful response and the upgrade command returns an error code although the upgrade succeeded.

This change checks if the connection was interrupted and treats it as a successful result instead of error.

Why is it important?

This race condition occasionally fails our integration tests.

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/fragments using the changelog tool
    - [ ] I have added an integration test or an E2E test

Related issues

The upgrade CLI command creates a client, connects to the Elastic Agent
server and triggers the upgrade process which is supposed to shut down
the agent and start the upgrade. Sometimes, this happens before
the client gets a successful response and the upgrade command returns
an error code although the upgrade succeeded.

This change checks if the connection was interrupted and treats it as
a successful result instead of error.
@rdner rdner added bug Something isn't working Team:Elastic-Agent Label for the Agent team backport-v8.13.0 Automated backport with mergify labels Apr 5, 2024
@rdner rdner self-assigned this Apr 5, 2024
@rdner rdner marked this pull request as ready for review April 5, 2024 13:30
@rdner rdner requested a review from a team as a code owner April 5, 2024 13:30
@rdner rdner requested review from blakerouse and pchila April 5, 2024 13:30
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@rdner rdner requested review from cmacknz and removed request for pchila April 5, 2024 13:35
@rdner rdner enabled auto-merge (squash) April 5, 2024 13:35
@rdner rdner disabled auto-merge April 5, 2024 14:24
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, thanks for the fix!

@rdner rdner enabled auto-merge (squash) April 5, 2024 15:46
@rdner
Copy link
Member Author

rdner commented Apr 5, 2024

I still need to fix the new test for Windows.

@rdner rdner disabled auto-merge April 5, 2024 16:43
Copy link

Quality Gate passed Quality Gate passed

The SonarQube Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
75.0% 75.0% Coverage on New Code
0.0% 0.0% Duplication on New Code

See analysis details on SonarQube

@rdner rdner merged commit 4ad7824 into elastic:main Apr 6, 2024
@rdner rdner deleted the fix-upgrade-cmd-fail-when-disconnecting branch April 6, 2024 15:30
mergify bot pushed a commit that referenced this pull request Apr 6, 2024
…4519)

The upgrade CLI command creates a client, connects to the Elastic Agent
server and triggers the upgrade process which is supposed to shut down
the agent and start the upgrade. Sometimes, this happens before
the client gets a successful response and the upgrade command returns
an error code although the upgrade succeeded.

This change checks if the connection was interrupted and treats it as
a successful result instead of error.

(cherry picked from commit 4ad7824)
rdner added a commit that referenced this pull request Apr 6, 2024
…4519) (#4532)

The upgrade CLI command creates a client, connects to the Elastic Agent
server and triggers the upgrade process which is supposed to shut down
the agent and start the upgrade. Sometimes, this happens before
the client gets a successful response and the upgrade command returns
an error code although the upgrade succeeded.

This change checks if the connection was interrupted and treats it as
a successful result instead of error.

(cherry picked from commit 4ad7824)

Co-authored-by: Denis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v8.13.0 Automated backport with mergify bug Something isn't working Team:Elastic-Agent Label for the Agent team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The elastic-agent upgrade command can fail even though the upgrade succeeds

3 participants