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

Give end user a way to tell which IP pool is silo default #4752

Closed
david-crespo opened this issue Jan 4, 2024 · 3 comments · Fixed by #4843
Closed

Give end user a way to tell which IP pool is silo default #4752

david-crespo opened this issue Jan 4, 2024 · 3 comments · Fixed by #4843
Assignees
Labels
api Related to the API. nexus Related to nexus

Comments

@david-crespo
Copy link
Contributor

#4261 makes is_default a property of the link to the silo (IpPoolSilo) and not of the IpPool itself, which means that when /v1/ip-pools lists IpPools for the current silo, there is no way to tell which is the default, i.e., which one instance create will pull an IP from if they don't specify a pool.

The fastest way to do this would be to add is_default: true to the default pool in the list (if there is one). What gives me pause is that it means the endpoint no longer returns the same IpPool object that we are using in all the other endpoints — this one now has an is_default property, so it would need to be a new struct. Maybe that's fine.

Another (probably worse) approach would be to add another endpoint like /v1/ip-pools/default (that path only makes sense if we don't intend to add /v1/ip-pools/{name-or-id}, and we probably do intend to for symmetry even though it's not very important). That way /v1/ip-pools would not have to change, but we could still hit this other endpoint in the console to show which is the default. I am inclined against this because only the console would really benefit from it — a CLI or SDK consumer would have to do extra work to match what we do in the console.

@david-crespo david-crespo added api Related to the API. nexus Related to nexus labels Jan 5, 2024
@karencfv
Copy link
Contributor

karencfv commented Jan 9, 2024

The fastest way to do this would be to add is_default: true to the default pool in the list (if there is one). What gives me pause is that it means the endpoint no longer returns the same IpPool object that we are using in all the other endpoints — this one now has an is_default property, so it would need to be a new struct. Maybe that's fine.

Why can't we add the is_default field to the IpPool object that is used for all the other endpoints?

@david-crespo
Copy link
Contributor Author

Because after #4261, a pool is default or not for a particular silo, so if they’re just listed across all silos, like a fleet admin listing all pools, there is no single value for is_default for a given pool. You’d have to list silos where it’s the default. Only when pools are listed in the context of a particular silo is there a well-defined single answer for is_default.

@karencfv
Copy link
Contributor

karencfv commented Jan 9, 2024

Ah! Gotcha. Hmm, then I think you're right. Your first option of returning a slightly different object for the list command makes sense 🤔 Not sure I can think of a better option

@david-crespo david-crespo self-assigned this Jan 18, 2024
david-crespo added a commit that referenced this issue Jan 20, 2024
…scoped IP pools list (#4843)

Fixes #4752
Fixes #4763 

The main trick here is introducing `views::SiloIpPool`, which is the
same as `views::IpPool` except it also has `is_default` on it. It only
makes sense in the context of a particular silo because `is_default` is
only defined for a (pool, silo) pair, not for a pool alone.

- [x] Add `GET /v1/system/silos/{silo}/ip-pools`
- [x] `/v1/ip-pools` and `/v1/ip-pools/{pool}` should return
`SiloIpPool` too
- [x] Tests for `/v1/system/silos/{silo}/ip-pools`
- [x] We can't have both `SiloIpPool` and `IpPoolSilo`, cleaned up by
changing:
  - `views::IpPoolSilo` -> `views::SiloIpSiloLink`
  - `params::IpPoolSiloLink` -> `views::IpPoolLinkSilo`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the API. nexus Related to nexus
Projects
None yet
2 participants