Skip to content

feat(machine-id): Bot instances list (web)#54925

Merged
nicholasmarais1158 merged 26 commits intomasterfrom
nickmarais/feat/53584-bot-instances-list
May 27, 2025
Merged

feat(machine-id): Bot instances list (web)#54925
nicholasmarais1158 merged 26 commits intomasterfrom
nickmarais/feat/53584-bot-instances-list

Conversation

@nicholasmarais1158
Copy link
Copy Markdown
Contributor

@nicholasmarais1158 nicholasmarais1158 commented May 19, 2025

Description

This change adds a new page to the Machine & Workload Identity section for Bot Instances. The page shows a paginated list of all "active" (i.e. with non-expired credentials) bot instances. Paging and search term filter are powered by the backend. Sorting is not supported - the list is naturally sorted by bot name and then instance id.

The page and search state are stored in the URL.

Tested locally with 100,000 instance records. Page load and initial data page are fast. Using a search term that returns fewer rows than the page size (20) takes 1.5 seconds, as the full data set needs to be processed on the backend.

Updates #53584

Changelog: View and explore all "active" bot instances

Changes

  • Add Map slices utility
  • Add endpoint to list bot instances with paging and search filter (GET /webapi/sites/:site/machine-id/bot-instance)
  • Add [Machine & Workload Identity > Bot instances] nav item
  • Add page to list bot instances (tabularly) with backend paging and filter - sort is not supported
  • Add page info panel for bot instances
  • Fix a minor UI glitch on bots welcome/tutorial component

Demo (network throttled)

Screen.Recording.2025-05-22.at.12.49.40.mov

@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented May 19, 2025

Paging, sorting and filter are all done client-side

Why?

@nicholasmarais1158 nicholasmarais1158 changed the title feat(machine-id): [53584] Bot instances list (web) feat(machine-id): Bot instances list (web) May 19, 2025
Comment thread web/packages/teleport/src/BotInstances/List/BotInstancesList.tsx Outdated
Comment thread web/packages/teleport/src/services/bot/bot.ts Outdated
Comment thread web/packages/teleport/src/BotInstances/List/BotInstancesList.tsx
Comment thread web/packages/teleport/src/BotInstances/List/BotInstancesList.tsx Outdated
Comment thread lib/web/machineid.go Outdated
@strideynet strideynet requested review from ryanclark and removed request for klizhentas and zmb3 May 20, 2025 13:10
@nicholasmarais1158
Copy link
Copy Markdown
Contributor Author

Paging, sorting and filter are all done client-side

Why?

It's a compromise made to get an initial implementation out. We have a mixture of approaches throughout the app today; some fully client-side (Users page), some have backend support (Resources page), and others use the backend but have reduced scope like not supporting sorting (Roles page). The goal is to deliver as full an experience as possible, without tackling challenges at a 'platform' (system-wide, shared capabilities) level.

Supporting sorting, and pagination of sorted results, requires indexes for large datasets (such as bot instances). Each field required for sorting will need to be indexed to keep the operation performant. Data like version numbers can't be sorted as a string without first parsing them (using semver, for example), which adds complexity to indexes over this type of data.

While focusing on adding incremental value is advised, it should not compromise the quality and trust of the product. 100k bot instance records is currently the maximum any exiting client might have. At this level, a page load takes 7+ seconds, every sort operation 4+ seconds, and a filter around 700ms. These timings reduce user experience - sorting particularly, as it has no indication of progress. In my opinion, the experience is borderline 'acceptable' as it stands.

An alternative initial approach that can be considered, is to descope sorting, move filtering (keyword match) to the backend, and use the existing backend paging capability. This addresses the poor user experience, but at the cost of reduced functionality. Then, as a separate iteration, an approach leveraging the work being done on the in-memory cache should allow sorting to be added with relatively low effort.

Suggestions, challenges and other points of view are welcome. 🙏

@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented May 20, 2025

We have a mixture of approaches throughout the app today; some fully client-side (Users page), some have backend support (Resources page), and others

For some context, basically everything started out fully client-side, and we spent a couple years slowly replacing non-paginated APIs with paginated ones to fix a bunch of issues that customers ran into at scale.

At this point, the users page is one of the last remnants of the old non-paginated APIs, and @rudream has a goal this quarter to swap it out for the paginated API.

Unless there is very strong reason not to, I'd prefer that all new endpoints use server-side pagination from the start. Otherwise, we're just deferring the inevitable.

Comment thread lib/services/local/bot_instance.go Outdated
Comment thread lib/services/local/bot_instance.go
Comment thread lib/web/machineid.go Outdated
Copy link
Copy Markdown
Member

@ryanclark ryanclark left a comment

Choose a reason for hiding this comment

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

Sorry for the delay!

@nicholasmarais1158 nicholasmarais1158 added this pull request to the merge queue May 27, 2025
Merged via the queue into master with commit 057b52f May 27, 2025
46 checks passed
@nicholasmarais1158 nicholasmarais1158 deleted the nickmarais/feat/53584-bot-instances-list branch May 27, 2025 08:22
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@nicholasmarais1158 See the table below for backport results.

Branch Result
branch/v17 Failed

nicholasmarais1158 added a commit that referenced this pull request May 28, 2025
* Add navigation item

* Add bot instances page

* Populate page info

* Add missing license header

* Update bot instance nav icon

* Reword hint text

* Add active at timestamp tooltip

* Rename active at header

* Remove copy and sort

* Lint and test fixes

* Support backend search term filtering

* Simplify code

* Add search term filter auth tests

* Allow disabling `<Table />` loading indicator

* Rework frontend to use backend paging and filter (remove sort)

* Fix lint (ts)

* Remove unused BotInstances icon

* Add URL state (page and search)

* Use nil-safe getters on protos

* Fix crash on items w/o heartbeat data
# Conflicts:
#	api/gen/proto/go/teleport/machineid/v1/bot_instance_service.pb.go
smallinsky pushed a commit that referenced this pull request May 29, 2025
* Add navigation item

* Add bot instances page

* Populate page info

* Add missing license header

* Update bot instance nav icon

* Reword hint text

* Add active at timestamp tooltip

* Rename active at header

* Remove copy and sort

* Lint and test fixes

* Support backend search term filtering

* Simplify code

* Add search term filter auth tests

* Allow disabling `<Table />` loading indicator

* Rework frontend to use backend paging and filter (remove sort)

* Fix lint (ts)

* Remove unused BotInstances icon

* Add URL state (page and search)

* Use nil-safe getters on protos

* Fix crash on items w/o heartbeat data
github-merge-queue Bot pushed a commit that referenced this pull request Jun 2, 2025
* feat(machine-id): Bot instances list (web) (#54925)

* Add navigation item

* Add bot instances page

* Populate page info

* Add missing license header

* Update bot instance nav icon

* Reword hint text

* Add active at timestamp tooltip

* Rename active at header

* Remove copy and sort

* Lint and test fixes

* Support backend search term filtering

* Simplify code

* Add search term filter auth tests

* Allow disabling `<Table />` loading indicator

* Rework frontend to use backend paging and filter (remove sort)

* Fix lint (ts)

* Remove unused BotInstances icon

* Add URL state (page and search)

* Use nil-safe getters on protos

* Fix crash on items w/o heartbeat data
# Conflicts:
#	api/gen/proto/go/teleport/machineid/v1/bot_instance_service.pb.go

* Update protos grpc
github-merge-queue Bot pushed a commit that referenced this pull request Jun 3, 2025
* feat(machine-id): Bot instances list (web) (#54925)

* Add navigation item

* Add bot instances page

* Populate page info

* Add missing license header

* Update bot instance nav icon

* Reword hint text

* Add active at timestamp tooltip

* Rename active at header

* Remove copy and sort

* Lint and test fixes

* Support backend search term filtering

* Simplify code

* Add search term filter auth tests

* Allow disabling `<Table />` loading indicator

* Rework frontend to use backend paging and filter (remove sort)

* Fix lint (ts)

* Remove unused BotInstances icon

* Add URL state (page and search)

* Use nil-safe getters on protos

* Fix crash on items w/o heartbeat data
# Conflicts:
#	api/gen/proto/go/teleport/machineid/v1/bot_instance_service.pb.go

* Update protos grpc

* feat(machine-id): Add bot instance details page (web) (#55055)

* Add navigation item

* Add bot instances page

* Populate page info

* Add missing license header

* Update bot instance nav icon

* Reword hint text

* Add active at timestamp tooltip

* Rename active at header

* Remove copy and sort

* Lint and test fixes

* Support backend search term filtering

* Simplify code

* Add search term filter auth tests

* Allow disabling `<Table />` loading indicator

* Rework frontend to use backend paging and filter (remove sort)

* Fix lint (ts)

* Remove unused BotInstances icon

* Add URL state (page and search)

* Use nil-safe getters on protos

* Fix crash on items w/o heartbeat data

* Add bot instance details page

* Fix lint (ts)

* Fix formatting (prettier)

* Fix yaml time serialisation

* Rename ButtonIcon from jsx to tsx

* Convert ButtonIcon to tsx

* Fix copy button on row

* Correct casing

* Use `assert.YAMLEq`

* Revert changes to ButtonIcon - too big for this PR

* chore: Export feature for enterprise (bot instance details) (#55177)
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.

4 participants