copy Omicron's sort order for mock API items#3033
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| const { project } = useProjectSelector() | ||
| const snapshotsQuery = useQuery(q(api.snapshotList, { query: { project } })) | ||
| const snapshotsQuery = useQuery( | ||
| q(api.snapshotList, { query: { project, limit: ALL_ISH } }) |
There was a problem hiding this comment.
Our snapshots dropdown was getting cut off; we should think about a more robust fix in a future PR for very long snapshot lists
|
I see the |
|
Sorry; wrote and never hit the button to submit this. My intent with this is less that we're ensuring correctness in the client, but more that it's a representation of the saga defaults that Omicron sets up. This is tied, in part, to #2932, which would actually add the "default" data to the mock DB, but this PR's intent is to render the mock DB's data in the console it in a similar order to how the API would return it. |
|
Fidelity to the real API logic is not necessarily a goal in itself. For me, it’s only a goal insofar as it helps us test (manually or automatically) the correctness of the client logic. That’s how we keep the mock server’s complexity manageable — we could go arbitrarily detailed in our imitation of Nexus, but we only do the minimum necessary to exercise the console. Lack of infidelity is more important to me than positive fidelity, and my worry is that this sorting logic as written is a kind of false fidelity — it's not actually very accurate to the API but it gives the impression that it should be. I might rather do nothing and be clear we're doing nothing (the status quo) than give that impression. For example: in Nexus, the page token encodes not only the identifier for the last item in the previous page but also the sort mode Going back to using the ID as the token takes a lot of the complexity away, without losing much — see #3094. With that simplification in place it will be easier to ask whether this logic makes it easier to ensure the console is correct. Might also be worth considering going the other way, putting the sort mode in the page token. |
|
Another thing I thought of that might be interesting: if we really wanted to know what sort modes were allowed on a given endpoint, we have that from the OpenAPI schema because every |
This PR just pulls a small fix to the mock API out of #3033, which I'll be closing shortly. I don't expect this to change much in day-to-day usage of the mock API. In short, when auto-selecting an IP Pool, the mock API currently selects the default pool from the default silo, regardless of what silo you're actually interacting with. To be clear, this is just an issue in the mock backend we use for local development / testing of the console app, not an underlying issue with Omicron. The fix here involves passing in the actual silo the project belongs to, instead of just going with the default silo's default pool.
|
I realized a simpler fix with the mock DB, should we even want to go through with the "adding the default resources" (which I do still think could have merit) and should we decide that we want things to be alphabetized, would be to just alphabetize the items in the JS arrays, rather than trying to parse/order the lists. Regardless, there's enough unsettled on this that I'm going to close this PR. |

This PR copies the Omicron API's sorting in the mock API, so Console results more accurately reflect what a user would see on an actual rack.

Before:
After:

This should not affect tables / lists with custom sort orders:

Closes #2776
Changes Made
Key Findings from Omicron Analysis
Based on the Omicron source code (https://github.com/uuid-rs/uuid):
The mock API now properly sorts results by default, matching Omicron's pagination behavior where:
Sources: