-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement ephemeral IPs - Updates the current external IP allocation query to handle both floating and ephemeral IPs, by assuming that the whole port range is already reserved for any existing IP address. - Add public datastore methods for creating SNAT and Ephemeral IPs, delegating to private method for the actual query running/handling - Updates sagas to include UUID generation for external IPs as separate steps, for idempotency, and to create Ephemeral IPs if they're requested. Also rework instance creation/migration sagas to select the Ephemeral IP address, if one was requested, or the SNAT if not. - Adds optional restriction of IP Pools to a project. This adds the project ID or name in a bunch of places, and updates the external IP allocation query to only consider pools which are unrestricted, or whose project ID matches the one of the instance we're allocating an IP for. This relies on a new index on the `instance_external_ip` table, which induces an undesirable sorting (by project, not IP), so we add a new sorting criterion to the query. - Adds tests, especially for the external IP table's check constraints which verify integrity of the name / description / instance ID for different kinds of addresses, and for restriction of an IP pool to a project. - Plumb the external IPs up to Nexus's public API, including instance creation and an endpoint for listing external IPs for an instance. - Adds integration tests for assignment of Ephemeral IPs and authz tests for the endpoint(s) * remove unused wrapper types around external IP model type * Review feedback - More comments and links to issues - Better handling of external IP vs SNAT IPs during instance provision/migrate - Revert bad MAC address
- Loading branch information
Showing
36 changed files
with
1,511 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
//! External IP addresses for instances | ||
use crate::authz; | ||
use crate::context::OpContext; | ||
use crate::db::lookup::LookupPath; | ||
use crate::db::model::IpKind; | ||
use crate::db::model::Name; | ||
use crate::external_api::views::ExternalIp; | ||
use omicron_common::api::external::ListResultVec; | ||
|
||
impl super::Nexus { | ||
pub async fn instance_list_external_ips( | ||
&self, | ||
opctx: &OpContext, | ||
organization_name: &Name, | ||
project_name: &Name, | ||
instance_name: &Name, | ||
) -> ListResultVec<ExternalIp> { | ||
let (.., authz_instance) = LookupPath::new(opctx, &self.db_datastore) | ||
.organization_name(organization_name) | ||
.project_name(project_name) | ||
.instance_name(instance_name) | ||
.lookup_for(authz::Action::Read) | ||
.await?; | ||
Ok(self | ||
.db_datastore | ||
.instance_lookup_external_ips(opctx, authz_instance.id()) | ||
.await? | ||
.into_iter() | ||
.filter_map(|ip| { | ||
if ip.kind == IpKind::SNat { | ||
None | ||
} else { | ||
Some(ip.try_into().unwrap()) | ||
} | ||
}) | ||
.collect::<Vec<_>>()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.