-
Notifications
You must be signed in to change notification settings - Fork 40
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
Fix duplicate entries in IP pools list #4808
Conversation
@@ -81,6 +81,7 @@ impl DataStore { | |||
) | |||
.filter(ip_pool::time_deleted.is_null()) | |||
.select(IpPool::as_select()) | |||
.distinct() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the easy fix, but I'm wondering if instead of using linkage to the internal silo to identify the internal pool, we could leave out the join altogether if we just had a well-known name for the internal pool and filtered that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the SERVICE_IP_POOL_NAME
const should be usable for this.
pub const SERVICE_IP_POOL_NAME: &str = "oxide-service-pool"; |
omicron/nexus/db-queries/src/db/datastore/rack.rs
Lines 756 to 760 in 009c4ae
let internal_pool = | |
db::model::IpPool::new(&IdentityMetadataCreateParams { | |
name: SERVICE_IP_POOL_NAME.parse::<Name>().unwrap(), | |
description: String::from("IP Pool for Oxide Services"), | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will attempt.
009c4ae
to
6c0518c
Compare
6370b3e
to
d9d8701
Compare
})?; | ||
Ok((authz_pool, pool)) | ||
let name = SERVICE_IP_POOL_NAME.parse().unwrap(); | ||
LookupPath::new(&opctx, self).ip_pool_name(&Name(name)).fetch().await |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I count this as a win, haha.
// pool has no entry in the join table | ||
.or(ip_pool_resource::resource_id.is_null()), | ||
) | ||
.filter(ip_pool::name.ne(SERVICE_IP_POOL_NAME)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so much better 🙌
Bugfix for #4261. Using
distinct
to eliminate dupes from the left outer join works, but it's better to just use the well-known name of the service IP pool to exclude it from whatever operations it needs to be excluded from.Potential followup related to #4762: if the ID was well-known too, we could do the
is_internal
check without having to hit the DB.