Skip to content

[Fleet] Display message explaining why agent is not upgradeable#173253

Merged
criamico merged 16 commits intoelastic:mainfrom
criamico:171840_upgradeable_agent_UI
Dec 19, 2023
Merged

[Fleet] Display message explaining why agent is not upgradeable#173253
criamico merged 16 commits intoelastic:mainfrom
criamico:171840_upgradeable_agent_UI

Conversation

@criamico
Copy link
Copy Markdown
Member

@criamico criamico commented Dec 13, 2023

Closes #171840
Also implements the UI part of #173281

Summary

When trying to upgrade a single agent that is not upgradeable, the error message doesn't specify why the agent cannot be upgraded. This PR is introducing:

  • More granular error messages in the endpoint POST agent/{agent_id}/upgrade. The messages are now different depending on which conditions are met. For the case when the agent is reported not upgradeable from elastic agent, there is now an error message the states it explicitly.
  • When clicking on the upgrade 1 agent from the bulk actions, if the agent is not upgradeable the submit button is now greyed out and a message explaining the reason is shown:

Screenshot 2023-12-18 at 14 41 48

The same warning appears when clicking on other upgrade actions in the bulk action menu, but only for a single agent. Multiple upgrades have not been changed.

  • In the agents list, reuse the existing tooltip besides the version to show the same messages when the agent is not upgradeable:
    Screenshot 2023-12-18 at 14 40 32

Checklist

@criamico criamico added the Team:Fleet Team label for Observability Data Collection Fleet team label Dec 13, 2023
@ghost
Copy link
Copy Markdown

ghost commented Dec 13, 2023

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@criamico
Copy link
Copy Markdown
Member Author

/ci

@criamico criamico self-assigned this Dec 13, 2023
@criamico
Copy link
Copy Markdown
Member Author

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Member Author

/ci

@criamico criamico marked this pull request as ready for review December 14, 2023 10:56
@criamico criamico requested a review from a team as a code owner December 14, 2023 10:56
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

describe('Fleet - getNotUpgradeableMessage', () => {
it('if agent reports not upgradeable with agent version < latest agent version', () => {
expect(getNotUpgradeableMessage(getAgent({ version: '7.9.0' }), '8.0.0')).toBe(
'agent is marked as not upgradeable in elastic-agent.'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
'agent is marked as not upgradeable in elastic-agent.'
'agent cannot be upgraded through Fleet. It may be running in a container.'

cc @cmacknz - Any input on this particular message? I feel we don't want to surface something as technical as the supervisor process/PID 1 details here, but something explicit would be helpful until we get a more granular reason from #173281. Tried to borrow some wording from https://www.elastic.co/guide/en/fleet/current/elastic-agent-container.html#_what_you_need.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My suggestion would be something like "It may be running in a container or is not installed as a service".

That second scenario is the case where someone has just executed ./elastic-agent.exe directly out of the installation directory.

@criamico
Copy link
Copy Markdown
Member Author

criamico commented Dec 14, 2023

@kpollich thanks for the review, I'm going to update the messages and I'll also add a tooltip since it's a very easy change. We already have a tooltip on the version numbers of the agent list, we just need to reuse the same function.

@kpollich
Copy link
Copy Markdown
Member

Perfect, @criamico thank you!

@criamico
Copy link
Copy Markdown
Member Author

@elasticmachine merge upstream

@criamico criamico requested a review from kpollich December 18, 2023 11:32
@criamico
Copy link
Copy Markdown
Member Author

@elasticmachine merge upstream

if (getRecentUpgradeInfoForAgent(agent).hasBeenUpgradedRecently) {
const timeToWaitMins = getRecentUpgradeInfoForAgent(agent).timeToWaitMins;
const elapsedMinsSinceUpgrade = getRecentUpgradeInfoForAgent(agent).elapsedMinsSinceUpgrade;
// const upgradeStarted = moment().subtract(AGENT_UPGRADE_COOLDOWN_IN_MIN - timeToWaitMins).minutes();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: comment should be removed

<em>
<FormattedMessage
id="xpack.fleet.upgradeAgents.upgradeSingleTimeout"
// TODO: Add link to docs regarding agent upgrade cooldowns
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we have an issue for this in ingest-docs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not sure, the comment was already there, I tried to find docs for it but couldn't. I can open an issue for it

Copy link
Copy Markdown
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@criamico
Copy link
Copy Markdown
Member Author

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Member Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 954 955 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.2MB 1.2MB +1.0KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 157.4KB 158.9KB +1.6KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @criamico

@criamico criamico merged commit 63f4e38 into elastic:main Dec 19, 2023
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Dec 19, 2023
@criamico criamico deleted the 171840_upgradeable_agent_UI branch December 19, 2023 11:36
criamico added a commit that referenced this pull request Jan 2, 2024
Fixes #173370
Closes #171941

## Summary
Show a warning when download upgrade is failing.

This PR addresses a specific case of `upgrade downloading`: when the
upgrade started but it's failing with an error. In this case, since
8.12, the agent metadata have a `retry_msg` that can be used to
distinguish this case from the regular upgrade.
I'm also fixing one smaller bug that I introduced with
#173253, the tooltip shown in the
case when the agent is not upgradeable was hiding the badge, so I'm
moving the if as the last one in the function.

## Testing
- Have an 8.12 agent installed with Multipass (it needs to be
upgradeable)
- Change the download binary url to something broken: `sourceURI:
https://artifacts.elastic.co/notdownloads/`
- Force upgrade from dev tools:
```
POST kbn:/api/fleet/agents/c3f09103-4e69-4a36-bee2-84223bedef36/upgrade
{
  "version": "8.12.0",
  "force": true
}
```
- Go to agent overview, the badge will show "upgrading" but will also
have a warning icon with a tooltip, showing the retry message and the
`retry_until` time in humanized format (retry until...remaining):
![Screenshot 2024-01-02 at 16 54
20](https://github.com/elastic/kibana/assets/16084106/ac340e7d-5151-4e4e-b6a6-731a113ff984)

This way the message shows the values present in the agent metadata.

- Same is reported in the agent list table:
![Screenshot 2024-01-02 at 16 54
28](https://github.com/elastic/kibana/assets/16084106/1f8823c4-9e5c-4f4c-9cdc-2839b16214bb)


- After a while the retries will be finished and the agent will show the
regular "upgrade failed" badge (this was already implemented):
![Screenshot 2023-12-21 at 12 07
27](https://github.com/elastic/kibana/assets/16084106/c1d5bf67-a4fd-4b04-aa8d-24dc8d4af54e)



### Checklist
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:enhancement Team:Fleet Team label for Observability Data Collection Fleet team v8.13.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fleet] Surface conditions making the agent "not upgradeable" on "error upgrading agent" message

7 participants