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

[Fleet] Elastic Agent upgrade states UI #167539

Merged
merged 18 commits into from
Oct 17, 2023

Conversation

jillguyonnet
Copy link
Contributor

@jillguyonnet jillguyonnet commented Sep 28, 2023

Summary

Closes https://github.com/elastic/ingest-dev/issues/1937

This PR implements the UI side of the new Elastic Agent upgrade states.

Note: the following changes will be present regardless of whether Elastic Agent has upgrade details:

  • Wider Version column
  • Upgrade available text is now a badge

Screenshots

Screenshot 2023-10-30 at 15 31 26

Screenshot 2023-10-05 at 11 36 08 Screenshot 2023-10-05 at 17 09 03 Screenshot 2023-10-05 at 11 36 23 Screenshot 2023-10-05 at 11 36 30 Screenshot 2023-10-05 at 11 36 40 Screenshot 2023-10-05 at 11 36 47 Screenshot 2023-10-05 at 11 36 53 Screenshot 2023-10-05 at 11 36 58 Screenshot 2023-10-05 at 11 37 05 Screenshot 2023-10-05 at 11 37 35

Steps to reproduce

Note: the Elastic Agent changes are not ready yet, so the proposed testing steps aim to mock the upgrade states by editing the agent document(s) manually.

  1. Run Kibana on this branch.
  2. Enroll at least one agent (or more to test more quickly).
  3. Create a "super duper user" in order to edit the agent document(s) (see below). Use this user to edit your agent document(s) and add upgrade details (see below for examples). ⚠️ These upgrade details won't stay for very long, so make sure to check the UI immediately.
  4. In Fleet UI, check that the UI correctly reflects the upgrade state (badge and tooltip).
  5. Check that an upgrading agent with no upgrade details correctly gets a tooltip informing that the upgrade details are not available. This can be mocked by editing the agent document again and setting upgrade_started_at to some timestamp and upgraded_at to null.

How to create a "super duper user"

In dev tools, run the following two commands:

PUT _security/role/super_duper_user
{
  "cluster" : [
    "all"
  ],
  "indices" : [
    {
      "names" : [
        "*"
      ],
      "privileges" : [
        "all"
      ],
      "field_security" : {
        "grant" : [
          "*"
        ],
        "except" : [ ]
      },
      "allow_restricted_indices" : true
    }
  ],
  "applications" : [ ],
  "run_as" : [ ],
  "metadata" : { },
  "transient_metadata" : {
    "enabled" : true
  }
}

PUT _security/user/strong_user
{

    "roles": [
      "super_duper_user",
      "superuser"
    ],
    "full_name": "Super Duper User",
    "email": "super@elastic.co",
    "password": "changeme",
    "metadata": {},
    "enabled": true
  
}

Adding upgrade details to an agent

Example commands:

POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_SCHEDULED",
      "metadata": {
        "scheduled_at": "2023-10-04T16:34:12Z" // edit this to a better time to check that the number of hours in the tooltip message is correct
      }
    }
  }
}
POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_DOWNLOADING",
      "metadata": {
        "download_percent": 16.4
      }
    }
  }
}
POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_FAILED",
      "metadata": {
        "failed_state": "UPG_DOWNLOADING",
        "error_msg": "Something went BOOM"
      }
    }
  }
}

Checklist

@apmmachine
Copy link
Contributor

🤖 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!)

@jillguyonnet
Copy link
Contributor Author

@elasticmachine merge upstream

@jillguyonnet
Copy link
Contributor Author

@elasticmachine merge upstream

@jillguyonnet jillguyonnet added Team:Fleet Team label for Observability Data Collection Fleet team v8.11.0 release_note:enhancement labels Oct 4, 2023
@jillguyonnet jillguyonnet self-assigned this Oct 4, 2023
);
}

// TODO: check logic
Copy link
Contributor Author

@jillguyonnet jillguyonnet Oct 4, 2023

Choose a reason for hiding this comment

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

This is something I'm not sure of: we want to show this tooltip if the agent is upgrading but doesn't have upgrade details. Is this check a proper way to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the check to upgrade_started_at:* AND NOT upgraded_at:* (thanks @juliaElastic).
@ycombinator Could you confirm this is correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

This predicate makes sense to me. And I think it's clever to show the tooltip in this scenario (agent is upgrading but we don't have upgrade details) as it encourages users to upgrade to 8.12.

My only feedback would be to somehow not hardcode the 8.12 if possible because we don't know yet when the entire implementation of the upgrade details (including the Agent side of things) will be done. I'm reasonably sure we're on track for 8.12 on the Agent side of things but if, for some odd reason, we don't make that, how can we remember to update this tooltip text? Or perhaps, to be safe, we could pull out just the code for this scenario into a separate PR that we merge at the very end, when we're absolutely sure of the version upgrade details will be available, end-to-end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree hardcoding the version number is not ideal.

Perhaps a narrow way to be safe could be to define a minVersion variable, currently undefined, and only render the tooltip when its value is set. Then, when the changes are ready on Agent side, we would have to remember to open a PR to set the value to 8.12 or another.

@juliaElastic WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, we could create a small gh issue and put in this sprint so we don't forget to set the variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ycombinator I've pushed this change and the other one (no download percent indication in the tooltip if 0) and opened a WIP followup PR to set the version: #168638 that could be merged after the Agent changes are ready.

Could you confirm whether we're ok to merge this PR and add a task to elastic/elastic-agent#3119 to ping Fleet team to merge #168638 when you are ready on your end?

@jillguyonnet jillguyonnet marked this pull request as ready for review October 4, 2023 14:43
@jillguyonnet jillguyonnet requested a review from a team as a code owner October 4, 2023 14:43
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

id="xpack.fleet.agentUpgradeStatusTooltip.upgradeDownloading"
defaultMessage="Downloading the new agent artifact version ({downloadPercent}%)."
values={{
downloadPercent: agentUpgradeDetails?.metadata.download_percent,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is download_percent going to be always populated? If not, maybe we should set 0 if not set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should exist and be populated if the state is UPG_DOWNLOADING, otherwise I don't think it's set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In saying that, I think it's a really good idea to fall back to 0 in case for some reason the agent doesn't have a download percent. Thanks for the suggesting, will add!

Copy link
Contributor

Choose a reason for hiding this comment

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

May I suggest that if the download_percent field is not set OR if it's set to 0, we don't include it in the message? In other words, would it be possible to start including the download percent value in the message only when download_percent > 0? Otherwise we could end up showing a download percent of 0 to the user for the entire time we're in the UPG_DOWNLOADING state and then suddenly move to the next state, which might be a bit confusing.

},
},
});
expectBadgeLabel(results, 'Upgrade failed');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the tooltip text could be verified for cases where there is a text with variables

Copy link
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.

Looks great, some minor comments, otherwise 🚀

@@ -295,6 +295,47 @@ export const AGENT_MAPPINGS = {
upgrade_status: {
type: 'keyword',
},
upgrade_details: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding this comment based on our offline discussion.
This mappings file is there for the only purpose of helping in the KQL validation. It's not adding any new field to the agent index mappings as those live in Elasticsearch repo. I think you'll need to open a separate PR there.

Also, this makes me think that the comment I had on this file is not super clear, so I'll open a small PR to better clarify what's the purpose of this file.

However this is a nice addition because it will enable the KQL searchbox to search on the newly defined fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just checked the existing mappings and noticed that they were added already in this PR elastic/elasticsearch#98680. So you should be good there :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for checking this @criamico! 👍

Copy link
Contributor

@criamico criamico left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

@jillguyonnet
Copy link
Contributor Author

@juliaElastic @criamico @zombieFox
The following changes have been pushed (updated screenshots in description):

  • Improved tooltip message for scheduled state: the tooltip now reads "less than 15 minute/30 minutes/1 hour/2 hours..." (there are a comment and a unit test for the function).
  • "Upgrade available" is no longer a warning icon and a text, but a white badge (no tooltip).
  • Unit tests for tooltip messages.

Thanks all for your feedback! I have one remaining question: FF 8.11.0 was on Oct 3 - should I keep 8.11.0 as the version for this PR (that includes the label text for when the agent has no upgrade details) or should it be changed?

@kpollich
Copy link
Member

kpollich commented Oct 5, 2023

FF 8.11.0 was on Oct 3 - should I keep 8.11.0 as the version for this PR (that includes the label text for when the agent has no upgrade details) or should it be changed?

I don't think this needs to land in 8.11.0 especially since we're still waiting on agent's implementation for this to really be "active" correct? Perhaps we should change this to target 8.12?

@jillguyonnet
Copy link
Contributor Author

jillguyonnet commented Oct 5, 2023

Thanks @kpollich - looking at elastic/elastic-agent#3119 this does seem to make sense.

Changing to 8.12.0 unless there are any objections.

@jillguyonnet
Copy link
Contributor Author

@elasticmachine merge upstream

@jillguyonnet
Copy link
Contributor Author

@elasticmachine merge upstream

@jillguyonnet
Copy link
Contributor Author

@elasticmachine merge upstream

@jillguyonnet
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 940 941 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fleet 1084 1085 +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 +4.8KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
fleet 42 43 +1
Unknown metric groups

API count

id before after diff
fleet 1202 1203 +1

History

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

cc @jillguyonnet

@kpollich
Copy link
Member

Merging as this is green + approved and Jill is on PTO 🙂

@kpollich kpollich merged commit d70e4c7 into elastic:main Oct 17, 2023
33 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Oct 17, 2023
WafaaNasr pushed a commit to WafaaNasr/kibana that referenced this pull request Oct 18, 2023
## Summary

Closes https://github.com/elastic/ingest-dev/issues/1937

This PR implements the UI side of the new Elastic Agent upgrade states.

Note: the following changes will be present regardless of whether
Elastic Agent has upgrade details:
- Wider `Version` column
- `Upgrade available` text is now a badge

### Screenshots

<img width="1903" alt="Screenshot 2023-10-05 at 14 23 46"
src="https://github.com/elastic/kibana/assets/23701614/6d24b9d6-2561-4018-b8b0-9582095804bc">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 08"
src="https://github.com/elastic/kibana/assets/23701614/ed550127-4c03-423d-9a7c-dace1211f67d">

<img width="314" alt="Screenshot 2023-10-05 at 17 09 03"
src="https://github.com/elastic/kibana/assets/23701614/80d18cf1-31d4-4969-acf3-e6afd39aee92">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 23"
src="https://github.com/elastic/kibana/assets/23701614/2a8257d7-6f8d-40be-a629-1634ed15f054">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 30"
src="https://github.com/elastic/kibana/assets/23701614/a4fef046-4bcd-4c99-a51e-ce994f9c6565">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 40"
src="https://github.com/elastic/kibana/assets/23701614/501a1b6d-d41b-448a-9d37-5987717d81d1">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 47"
src="https://github.com/elastic/kibana/assets/23701614/6cdb7f42-2cb3-4861-b6e5-86267602c2fa">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 53"
src="https://github.com/elastic/kibana/assets/23701614/9a04421c-4b8a-437d-8bb9-114ece3bea6a">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 58"
src="https://github.com/elastic/kibana/assets/23701614/1bb1b362-e30a-4985-877f-9908c778acf0">

<img width="382" alt="Screenshot 2023-10-05 at 11 37 05"
src="https://github.com/elastic/kibana/assets/23701614/66d0bf65-67f2-432b-a3a8-7dd5773368a0">

<img width="1196" alt="Screenshot 2023-10-05 at 11 37 35"
src="https://github.com/elastic/kibana/assets/23701614/353f5942-e74f-468a-9430-895b7dbe19e5">



### Steps to reproduce

Note: the [Elastic Agent
changes](elastic/elastic-agent#3119) are not
ready yet, so the proposed testing steps aim to mock the upgrade states
by editing the agent document(s) manually.

1. Run Kibana on this branch.
2. Enroll at least one agent (or more to test more quickly).
3. Create a "super duper user" in order to edit the agent document(s)
(see below). Use this user to edit your agent document(s) and add
upgrade details (see below for examples). ⚠️ These upgrade details won't
stay for very long, so make sure to check the UI immediately.
4. In Fleet UI, check that the UI correctly reflects the upgrade state
(badge and tooltip).
5. Check that an upgrading agent with no upgrade details correctly gets
a tooltip informing that the upgrade details are not available. This can
be mocked by editing the agent document again and setting
`upgrade_started_at` to some timestamp and `upgraded_at` to `null`.

#### How to create a "super duper user"

In dev tools, run the following two commands:
```
PUT _security/role/super_duper_user
{
  "cluster" : [
    "all"
  ],
  "indices" : [
    {
      "names" : [
        "*"
      ],
      "privileges" : [
        "all"
      ],
      "field_security" : {
        "grant" : [
          "*"
        ],
        "except" : [ ]
      },
      "allow_restricted_indices" : true
    }
  ],
  "applications" : [ ],
  "run_as" : [ ],
  "metadata" : { },
  "transient_metadata" : {
    "enabled" : true
  }
}

PUT _security/user/strong_user
{

    "roles": [
      "super_duper_user",
      "superuser"
    ],
    "full_name": "Super Duper User",
    "email": "super@elastic.co",
    "password": "changeme",
    "metadata": {},
    "enabled": true
  
}
```

#### Adding upgrade details to an agent

Example commands:

```
POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_SCHEDULED",
      "metadata": {
        "scheduled_at": "2023-10-04T16:34:12Z" // edit this to a better time to check that the number of hours in the tooltip message is correct
      }
    }
  }
}
```

```
POST .fleet-agents/_update/<agent_id>
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_DOWNLOADING",
      "metadata": {
        "download_percent": 16.4
      }
    }
  }
}
```

```
POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_FAILED",
      "metadata": {
        "failed_state": "UPG_DOWNLOADING",
        "error_msg": "Something went BOOM"
      }
    }
  }
}
```

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
benakansara pushed a commit to benakansara/kibana that referenced this pull request Oct 22, 2023
## Summary

Closes elastic/ingest-dev#1937

This PR implements the UI side of the new Elastic Agent upgrade states.

Note: the following changes will be present regardless of whether
Elastic Agent has upgrade details:
- Wider `Version` column
- `Upgrade available` text is now a badge

### Screenshots

<img width="1903" alt="Screenshot 2023-10-05 at 14 23 46"
src="https://github.com/elastic/kibana/assets/23701614/6d24b9d6-2561-4018-b8b0-9582095804bc">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 08"
src="https://github.com/elastic/kibana/assets/23701614/ed550127-4c03-423d-9a7c-dace1211f67d">

<img width="314" alt="Screenshot 2023-10-05 at 17 09 03"
src="https://github.com/elastic/kibana/assets/23701614/80d18cf1-31d4-4969-acf3-e6afd39aee92">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 23"
src="https://github.com/elastic/kibana/assets/23701614/2a8257d7-6f8d-40be-a629-1634ed15f054">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 30"
src="https://github.com/elastic/kibana/assets/23701614/a4fef046-4bcd-4c99-a51e-ce994f9c6565">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 40"
src="https://github.com/elastic/kibana/assets/23701614/501a1b6d-d41b-448a-9d37-5987717d81d1">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 47"
src="https://github.com/elastic/kibana/assets/23701614/6cdb7f42-2cb3-4861-b6e5-86267602c2fa">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 53"
src="https://github.com/elastic/kibana/assets/23701614/9a04421c-4b8a-437d-8bb9-114ece3bea6a">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 58"
src="https://github.com/elastic/kibana/assets/23701614/1bb1b362-e30a-4985-877f-9908c778acf0">

<img width="382" alt="Screenshot 2023-10-05 at 11 37 05"
src="https://github.com/elastic/kibana/assets/23701614/66d0bf65-67f2-432b-a3a8-7dd5773368a0">

<img width="1196" alt="Screenshot 2023-10-05 at 11 37 35"
src="https://github.com/elastic/kibana/assets/23701614/353f5942-e74f-468a-9430-895b7dbe19e5">



### Steps to reproduce

Note: the [Elastic Agent
changes](elastic/elastic-agent#3119) are not
ready yet, so the proposed testing steps aim to mock the upgrade states
by editing the agent document(s) manually.

1. Run Kibana on this branch.
2. Enroll at least one agent (or more to test more quickly).
3. Create a "super duper user" in order to edit the agent document(s)
(see below). Use this user to edit your agent document(s) and add
upgrade details (see below for examples). ⚠️ These upgrade details won't
stay for very long, so make sure to check the UI immediately.
4. In Fleet UI, check that the UI correctly reflects the upgrade state
(badge and tooltip).
5. Check that an upgrading agent with no upgrade details correctly gets
a tooltip informing that the upgrade details are not available. This can
be mocked by editing the agent document again and setting
`upgrade_started_at` to some timestamp and `upgraded_at` to `null`.

#### How to create a "super duper user"

In dev tools, run the following two commands:
```
PUT _security/role/super_duper_user
{
  "cluster" : [
    "all"
  ],
  "indices" : [
    {
      "names" : [
        "*"
      ],
      "privileges" : [
        "all"
      ],
      "field_security" : {
        "grant" : [
          "*"
        ],
        "except" : [ ]
      },
      "allow_restricted_indices" : true
    }
  ],
  "applications" : [ ],
  "run_as" : [ ],
  "metadata" : { },
  "transient_metadata" : {
    "enabled" : true
  }
}

PUT _security/user/strong_user
{

    "roles": [
      "super_duper_user",
      "superuser"
    ],
    "full_name": "Super Duper User",
    "email": "super@elastic.co",
    "password": "changeme",
    "metadata": {},
    "enabled": true
  
}
```

#### Adding upgrade details to an agent

Example commands:

```
POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_SCHEDULED",
      "metadata": {
        "scheduled_at": "2023-10-04T16:34:12Z" // edit this to a better time to check that the number of hours in the tooltip message is correct
      }
    }
  }
}
```

```
POST .fleet-agents/_update/<agent_id>
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_DOWNLOADING",
      "metadata": {
        "download_percent": 16.4
      }
    }
  }
}
```

```
POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_FAILED",
      "metadata": {
        "failed_state": "UPG_DOWNLOADING",
        "error_msg": "Something went BOOM"
      }
    }
  }
}
```

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
benakansara pushed a commit to benakansara/kibana that referenced this pull request Oct 22, 2023
## Summary

Closes elastic/ingest-dev#1937

This PR implements the UI side of the new Elastic Agent upgrade states.

Note: the following changes will be present regardless of whether
Elastic Agent has upgrade details:
- Wider `Version` column
- `Upgrade available` text is now a badge

### Screenshots

<img width="1903" alt="Screenshot 2023-10-05 at 14 23 46"
src="https://github.com/elastic/kibana/assets/23701614/6d24b9d6-2561-4018-b8b0-9582095804bc">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 08"
src="https://github.com/elastic/kibana/assets/23701614/ed550127-4c03-423d-9a7c-dace1211f67d">

<img width="314" alt="Screenshot 2023-10-05 at 17 09 03"
src="https://github.com/elastic/kibana/assets/23701614/80d18cf1-31d4-4969-acf3-e6afd39aee92">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 23"
src="https://github.com/elastic/kibana/assets/23701614/2a8257d7-6f8d-40be-a629-1634ed15f054">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 30"
src="https://github.com/elastic/kibana/assets/23701614/a4fef046-4bcd-4c99-a51e-ce994f9c6565">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 40"
src="https://github.com/elastic/kibana/assets/23701614/501a1b6d-d41b-448a-9d37-5987717d81d1">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 47"
src="https://github.com/elastic/kibana/assets/23701614/6cdb7f42-2cb3-4861-b6e5-86267602c2fa">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 53"
src="https://github.com/elastic/kibana/assets/23701614/9a04421c-4b8a-437d-8bb9-114ece3bea6a">

<img width="382" alt="Screenshot 2023-10-05 at 11 36 58"
src="https://github.com/elastic/kibana/assets/23701614/1bb1b362-e30a-4985-877f-9908c778acf0">

<img width="382" alt="Screenshot 2023-10-05 at 11 37 05"
src="https://github.com/elastic/kibana/assets/23701614/66d0bf65-67f2-432b-a3a8-7dd5773368a0">

<img width="1196" alt="Screenshot 2023-10-05 at 11 37 35"
src="https://github.com/elastic/kibana/assets/23701614/353f5942-e74f-468a-9430-895b7dbe19e5">



### Steps to reproduce

Note: the [Elastic Agent
changes](elastic/elastic-agent#3119) are not
ready yet, so the proposed testing steps aim to mock the upgrade states
by editing the agent document(s) manually.

1. Run Kibana on this branch.
2. Enroll at least one agent (or more to test more quickly).
3. Create a "super duper user" in order to edit the agent document(s)
(see below). Use this user to edit your agent document(s) and add
upgrade details (see below for examples). ⚠️ These upgrade details won't
stay for very long, so make sure to check the UI immediately.
4. In Fleet UI, check that the UI correctly reflects the upgrade state
(badge and tooltip).
5. Check that an upgrading agent with no upgrade details correctly gets
a tooltip informing that the upgrade details are not available. This can
be mocked by editing the agent document again and setting
`upgrade_started_at` to some timestamp and `upgraded_at` to `null`.

#### How to create a "super duper user"

In dev tools, run the following two commands:
```
PUT _security/role/super_duper_user
{
  "cluster" : [
    "all"
  ],
  "indices" : [
    {
      "names" : [
        "*"
      ],
      "privileges" : [
        "all"
      ],
      "field_security" : {
        "grant" : [
          "*"
        ],
        "except" : [ ]
      },
      "allow_restricted_indices" : true
    }
  ],
  "applications" : [ ],
  "run_as" : [ ],
  "metadata" : { },
  "transient_metadata" : {
    "enabled" : true
  }
}

PUT _security/user/strong_user
{

    "roles": [
      "super_duper_user",
      "superuser"
    ],
    "full_name": "Super Duper User",
    "email": "super@elastic.co",
    "password": "changeme",
    "metadata": {},
    "enabled": true
  
}
```

#### Adding upgrade details to an agent

Example commands:

```
POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_SCHEDULED",
      "metadata": {
        "scheduled_at": "2023-10-04T16:34:12Z" // edit this to a better time to check that the number of hours in the tooltip message is correct
      }
    }
  }
}
```

```
POST .fleet-agents/_update/<agent_id>
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_DOWNLOADING",
      "metadata": {
        "download_percent": 16.4
      }
    }
  }
}
```

```
POST .fleet-agents/_update/<agent_id>
{
  "doc": {
    "upgrade_details": {
      "target_version": "8.11",
      "action_id": "xxxxxxxx",
      "state": "UPG_FAILED",
      "metadata": {
        "failed_state": "UPG_DOWNLOADING",
        "error_msg": "Something went BOOM"
      }
    }
  }
}
```

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@jillguyonnet jillguyonnet deleted the fleet/agent-upgrade-states-ui branch October 23, 2023 08:24
szaffarano pushed a commit to szaffarano/kibana that referenced this pull request Nov 21, 2023
## Summary

Followup to elastic#167539.

Closes elastic/ingest-dev#2568.

As the version on which agents will have upgrade details is not known
yet, we decided to defer showing the tooltip for agents that don't until
it is (cf.
elastic#167539 (comment)).

This PR sets the version to 8.12.

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 commit does not require backporting release_note:enhancement Team:Fleet Team label for Observability Data Collection Fleet team v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants