Skip to content

[nexus] Remove project_id, rack_id from IP pools - #2056

Merged
smklein merged 13 commits into
mainfrom
ip-pool-party
Dec 19, 2022
Merged

smklein merged 13 commits into
mainfrom
ip-pool-party

Conversation

@smklein

@smklein smklein commented Dec 14, 2022 •

Copy link
Copy Markdown
Collaborator

Before this PR

This PR

  • Adds a default IP pool named default, which is used for address allocation unless a more specific IP pool is provided
  • Removes "project ID" from IP pools (and external IP addresses)
  • Removes "rack ID" from IP pool API and DB representation

In the future

  • This PR doesn't provide the many-to-many connection between projects and IP pools that we eventually want, where projects can be configured to use different IP pools for different purposes. However, by removing the not-quite-accurate relationship that an IP pool must belong to a single project, the API moves closer towards this direction.
  • We probably should access the service_ip_pool API with the AZ UUID used for the query, but since AZs don't exist in the API yet, this has been omitted.

Part of #2055

Comment on lines -511 to -518
// Type used to identify a Project in request bodies, where one may not have
// the path in the request URL.
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct ProjectPath {
pub organization: Name,
pub project: Name,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@smklein smklein added api Related to the API. nexus Related to nexus labels Dec 15, 2022
@smklein
smklein marked this pull request as ready for review December 15, 2022 16:05
@smklein smklein mentioned this pull request Dec 15, 2022
4 of 5 tasks
@smklein
smklein requested review from bnaecker and rmustacc December 15, 2022 16:12
@smklein

smklein commented Dec 15, 2022

Copy link
Copy Markdown
Collaborator Author

I suspect we'll want a follow-up to this PR to add APIs for the following:

  • Given a project, use ACLs to describe which IP pools are visible to a user
  • Given a project, configure a set of IP pools that it should use for address allocation

As mentioned on #2055

Comment thread nexus/db-model/src/ip_pool.rs Resolved
Comment thread common/src/sql/dbinit.sql Outdated
* should probably point to an AZ or fleet, not a rack.
*/
rack_id UUID,
internal_only BOOL NOT NULL,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor bikeshedding here, no action required unless you feel like it.

This could just be called internal as only seems to me to be implied.

It'd probably be good to copy the comment from the datastore struct or just note to check that file. Do @see comments work in rust? Maybe that's just a jsdoc thing. Again, not required. Just a nice to have.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in b4dd0b1

I dunno about the linked comments, but I included a summary here.

Comment thread nexus/src/app/ip_pool.rs
.await
}

pub async fn ip_pool_services_create(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's outside the scope of this PR, but I wonder if IP Pool Services is the right way to frame this now. Should it just be internal ip pools?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I hear you on this; maybe s/service/internal would be more consistent. When I originally wrote this, I think I was writing "service" as shorthand for "internal service".

Comment thread nexus/src/app/sagas/instance_create.rs Outdated
Comment on lines +630 to +631
let (.., pool) = datastore
.ip_pools_lookup_by_name_no_auth(&opctx, "default")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this really just for looking up the default IP pool? If so, I wonder if we shouldn't just have a ip_pools_lookup_default that's documented to not require authz but otherwise doesn't take arbitrary names.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I did this, and added authz checks, within 91415a4

@just-be-dev just-be-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great! Thanks for tackling it @smklein.

@smklein
smklein enabled auto-merge (squash) December 19, 2022 22:42
@smklein
smklein merged commit f47aefc into main Dec 19, 2022
@smklein
smklein deleted the ip-pool-party branch December 19, 2022 23:24
smklein added a commit that referenced this pull request Jan 6, 2023
Fixes a regression introduced by
#2056

Updates polar policy to allow instance creation from regular Silo users,
and adds a regression test
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

Development

Successfully merging this pull request may close these issues.

3 participants