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

Fix duplicate entries in IP pools list #4808

Merged
merged 4 commits into from
Jan 16, 2024
Merged

Fix duplicate entries in IP pools list #4808

merged 4 commits into from
Jan 16, 2024

Conversation

david-crespo
Copy link
Contributor

@david-crespo david-crespo commented Jan 12, 2024

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.

@@ -81,6 +81,7 @@ impl DataStore {
)
.filter(ip_pool::time_deleted.is_null())
.select(IpPool::as_select())
.distinct()
Copy link
Contributor Author

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.

Copy link
Contributor

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";

let internal_pool =
db::model::IpPool::new(&IdentityMetadataCreateParams {
name: SERVICE_IP_POOL_NAME.parse::<Name>().unwrap(),
description: String::from("IP Pool for Oxide Services"),
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will attempt.

@david-crespo david-crespo changed the title Fix list ip pools by deduping results of left outer join Fix duplicate entries in IP pools list Jan 12, 2024
})?;
Ok((authz_pool, pool))
let name = SERVICE_IP_POOL_NAME.parse().unwrap();
LookupPath::new(&opctx, self).ip_pool_name(&Name(name)).fetch().await
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦

Copy link
Contributor

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))
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, so much better 🙌

@david-crespo david-crespo merged commit 4796057 into main Jan 16, 2024
20 checks passed
@david-crespo david-crespo deleted the fix-ip-pools-list branch January 16, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants