Include Pinned Resources in User Preferences#32009
Conversation
| // displayed in the user's pinned resources tab in the Web UI | ||
| message PinnedResourcesUserPreferences { | ||
| // pinned_resources is a map of resource IDs pinned per cluster | ||
| map<string, ClusterPinnedResources> pinned_resources = 1; |
There was a problem hiding this comment.
I've got a few questions around pinned resources that I couldn't find answers to by poking around. If there is a RFD or some other documentation where these decisions have been made please point me to them.
- Should pinned resources be stored per cluster rather than having them all in the root cluster?
- Is there an upper bound to the number of pinned resources? Is it per cluster or total?
- How do pinned resources get cleaned up? Is it manual? What happens if a leaf cluster is removed entirely?
- What will be displayed to a user if a pinned resource is removed? Is the resource id enough information for a user to discern which resource they pinned?
There was a problem hiding this comment.
Should pinned resources be stored per cluster rather than having them all in the root cluster?
I'm not sure yet. It seems reasonable enough to allow it but I haven't done any super thinking on it yet.
Is there an upper bound to the number of pinned resources? Is it per cluster or total?
There isn't an upperbound programmed in yet, but we'd want to stay under the max size of an item, lets say in dynamodb, which is 400kb. if we have a node id like "123123-123123123-123123123/node", well over 10k could fit and still have plenty of room for more (and other user preferences).
I don't think 10k pinned resources across all clusters is a realistic outcome in terms of what people actually pin, but we should put some safeguards up regardless. and also it comes into play with my next point.
How do pinned resources get cleaned up? Is it manual? What happens if a leaf cluster is removed entirely?
This will require some extra thinking. My first inclination is that when a pinned resources request is made, we can track how many resources "couldn't be found" from their pinned list, and then just remove them. But I don't think thats a good place to do it as I wouldn't want to add extra latency to the request. there should be some way to clean them up however, because if that was left to grow unbounded then we could run into the issue above.
What will be displayed to a user if a pinned resource is removed?
If they pinned something that gets removed or they lose access to it, it just wouldn't be in shown. a "pinned resource" is really just an extra filter with specific IDs. you can do the same with an advanced query, so the same UX if they opened the normal tab and a resource was gone. it just wouldn't be there.
Is the resource id enough information for a user to discern which resource they pinned?
This isn't super relevant yet since they won't see something that doesn't exist. However, I could envision a future where there is a 'user preferences' page that could show the IDs they have pinned (existing and not) and be able to edit it there. Then maybe ID wouldn't be enough, but ID + if it exists or not (with info from existing resources surrounding it) might be enough. That bridge is very far down the road tho.
To summarize, the main points that should probably be solved now-ish or at least documented are the cleanup phase and the max size. I will try to get something written up about this
There was a problem hiding this comment.
Based on the above, I'd lean toward storing the pins per-cluster rather than storing all pins in root as is currently done. If we store pins per cluster, doing automatic cleanup as a periodic won't be too difficult. If, on the other hand, we do all pinning in the root that makes things very complicated. Cross-cluster communication is non-trivial.
Also note that a resource disappearing temporarily doesn't necessarily mean that it's gone. An automatic cleanup routine should probably track timestamps and only clean up resource that remain missing for some minimum amount of time + number of checks.
IMO wether or not this PR includes a cleanup mechanism, we should have a reasonably clear idea of how the cleanup mechanism will function prior to merging it.
There was a problem hiding this comment.
I don't think it's a bad idea to put an upper limit on the number of pinned resources. Pinning resources becomes less helpful the more you pin, so I'd expect people won't pin too many. Maybe we set a hard cap to something like 300 or 500?
As far as cleanup goes, I think for now it's okay if your preferences reference a resource that no longer exists - they just won't show up in the listing.
We can work with @roraback to get some designs for how you might remove them.
|
Updated to store cluster preferences per cluster |
| } | ||
|
|
||
| item, err := createBackendItem(username, preferences) | ||
| item, err := createBackendItem(username, prefs) |
There was a problem hiding this comment.
This was removed because originally, we'd only be sending small chunks of the user preferences to update. Now we send the entire thing (before this PR) so we can just completely overwrite the prefs. Using a range to go through what was sent in the protomessage would skip empty values and therefor not allow us to "empty" our pinned resources. Now that we send the entire thing, it works as expected.
There was a problem hiding this comment.
nit: this is only called in one place and this function has become simple enough it might be worthwhile to just instantiate the response struct inline.
There was a problem hiding this comment.
nit: only the comments in the .ts files end with punctuation.
| // PinnedResourcesUserPreferences is a collection of resource IDs that will be | |
| // displayed in the user's pinned resources tab in the Web UI | |
| // PinnedResourcesUserPreferences is a collection of resource IDs that will be | |
| // displayed in the user's pinned resources tab in the Web UI. |
d2d0b55 to
dceb604
Compare
|
🤖 Vercel preview here: https://docs-5j32kwuz0-goteleport.vercel.app/docs/ver/preview |
Closes #32008
In support of #30418
This will add Pinned Resources to the user preferences object. The shape on web is:
We will use this to get a list of resource IDs to display which resources are pinned in the unified resource view.

node: two PRs will be be opened that rely on this. The fetching of the actual resource based on the users preferences, and updating which resources are saved via the Pin button. Both of those will be opened shortly after this one.
It can be tested by inspecting the user preferences local storage object after logging in (it will be empty but there!)