Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Jan 3, 2024
1 parent ba1eb0e commit 9a3ffb8
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 283 deletions.
11 changes: 0 additions & 11 deletions nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,13 @@
use omicron_common::api::external::SemverVersion;

<<<<<<< HEAD
/// The version of the database schema this particular version of Nexus was
/// built against.
///
/// This should be updated whenever the schema is changed. For more details,
/// refer to: schema/crdb/README.adoc
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(22, 0, 1);

||||||| 7c3cd6abe
=======
/// The version of the database schema this particular version of Nexus was
/// built against.
///
/// This should be updated whenever the schema is changed. For more details,
/// refer to: schema/crdb/README.adoc
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(21, 0, 0);

>>>>>>> main
table! {
disk (id) {
id -> Uuid,
Expand Down
50 changes: 0 additions & 50 deletions nexus/db-queries/src/db/datastore/external_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,49 +143,14 @@ impl DataStore {
) -> CreateResult<ExternalIp> {
let ip_id = Uuid::new_v4();

<<<<<<< HEAD
// TODO: NameOrId resolution should happen a level higher, in the nexus function
let (.., authz_pool, pool) = match params.pool {
Some(NameOrId::Name(name)) => {
LookupPath::new(opctx, self)
.ip_pool_name(&Name(name))
.fetch_for(authz::Action::Read)
.await?
||||||| 7c3cd6abe
let pool_id = match params.pool {
Some(NameOrId::Name(name)) => {
LookupPath::new(opctx, self)
.ip_pool_name(&Name(name))
.fetch_for(authz::Action::Read)
.await?
.1
=======
// See `allocate_instance_ephemeral_ip`: we're replicating
// its strucutre to prevent cross-silo pool access.
let pool_id = if let Some(name_or_id) = params.pool {
let (.., authz_pool, pool) = match name_or_id {
NameOrId::Name(name) => {
LookupPath::new(opctx, self)
.ip_pool_name(&Name(name))
.fetch_for(authz::Action::CreateChild)
.await?
}
NameOrId::Id(id) => {
LookupPath::new(opctx, self)
.ip_pool_id(id)
.fetch_for(authz::Action::CreateChild)
.await?
}
};

let authz_silo_id = opctx.authn.silo_required()?.id();
if let Some(pool_silo_id) = pool.silo_id {
if pool_silo_id != authz_silo_id {
return Err(authz_pool.not_found());
}
>>>>>>> main
}
<<<<<<< HEAD
Some(NameOrId::Id(id)) => {
LookupPath::new(opctx, self)
.ip_pool_id(id)
Expand All @@ -200,21 +165,6 @@ impl DataStore {
// If this pool is not linked to the current silo, 404
if self.ip_pool_fetch_link(opctx, pool_id).await.is_err() {
return Err(authz_pool.not_found());
||||||| 7c3cd6abe
Some(NameOrId::Id(id)) => {
LookupPath::new(opctx, self)
.ip_pool_id(id)
.fetch_for(authz::Action::Read)
.await?
.1
}
None => self.ip_pools_fetch_default(opctx).await?,
=======

pool
} else {
self.ip_pools_fetch_default(opctx).await?
>>>>>>> main
}

let data = if let Some(ip) = params.address {
Expand Down
16 changes: 0 additions & 16 deletions nexus/src/app/sagas/disk_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,22 +851,6 @@ pub(crate) mod test {
const DISK_NAME: &str = "my-disk";
const PROJECT_NAME: &str = "springfield-squidport";

<<<<<<< HEAD
||||||| 7c3cd6abe
async fn create_org_and_project(client: &ClientTestContext) -> Uuid {
create_ip_pool(&client, "p0", None).await;
let project = create_project(client, PROJECT_NAME).await;
project.identity.id
}

=======
async fn create_org_and_project(client: &ClientTestContext) -> Uuid {
create_ip_pool(&client, "p0", None, None).await;
let project = create_project(client, PROJECT_NAME).await;
project.identity.id
}

>>>>>>> main
pub fn new_disk_create_params() -> params::DiskCreate {
params::DiskCreate {
identity: IdentityMetadataCreateParams {
Expand Down
16 changes: 0 additions & 16 deletions nexus/src/app/sagas/disk_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,6 @@ pub(crate) mod test {

const PROJECT_NAME: &str = "springfield-squidport";

<<<<<<< HEAD
||||||| 7c3cd6abe
async fn create_org_and_project(client: &ClientTestContext) -> Uuid {
create_ip_pool(&client, "p0", None).await;
let project = create_project(client, PROJECT_NAME).await;
project.identity.id
}

=======
async fn create_org_and_project(client: &ClientTestContext) -> Uuid {
create_ip_pool(&client, "p0", None, None).await;
let project = create_project(client, PROJECT_NAME).await;
project.identity.id
}

>>>>>>> main
pub fn test_opctx(cptestctx: &ControlPlaneTestContext) -> OpContext {
OpContext::for_tests(
cptestctx.logctx.log.new(o!()),
Expand Down
8 changes: 0 additions & 8 deletions nexus/src/app/sagas/snapshot_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1782,18 +1782,10 @@ mod test {
const DISK_NAME: &str = "disky-mcdiskface";
const INSTANCE_NAME: &str = "base-instance";

<<<<<<< HEAD
async fn create_project_and_disk_and_pool(
client: &ClientTestContext,
) -> Uuid {
create_default_ip_pool(&client).await;
||||||| 7c3cd6abe
async fn create_org_project_and_disk(client: &ClientTestContext) -> Uuid {
create_ip_pool(&client, "p0", None).await;
=======
async fn create_org_project_and_disk(client: &ClientTestContext) -> Uuid {
create_ip_pool(&client, "p0", None, None).await;
>>>>>>> main
create_project(client, PROJECT_NAME).await;
create_disk(client, PROJECT_NAME, DISK_NAME).await.identity.id
}
Expand Down
48 changes: 10 additions & 38 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
use super::{
console_api, device_auth, params,
params::{ProjectSelector, UninitializedSledId},
shared::UninitializedSled,
views::{
self, Certificate, Group, IdentityProvider, Image, IpPool, IpPoolRange,
PhysicalDisk, Project, Rack, Role, Silo, SiloQuotas, SiloUtilization,
Sled, SledInstance, Snapshot, SshKey, Switch, User, UserBuiltin, Vpc,
VpcRouter, VpcSubnet,
PhysicalDisk, Project, Rack, Role, Silo, SiloUtilization, Sled,
Snapshot, SshKey, User, UserBuiltin, Vpc, VpcRouter, VpcSubnet,
},
};
use crate::external_api::shared;
Expand Down Expand Up @@ -40,32 +37,13 @@ use dropshot::{
use ipnetwork::IpNetwork;
use nexus_db_queries::authz;
use nexus_db_queries::db;
use nexus_db_queries::db::identity::AssetIdentityMetadata;
use nexus_db_queries::db::identity::Resource;
use nexus_db_queries::db::lookup::ImageLookup;
use nexus_db_queries::db::lookup::ImageParentLookup;
use nexus_db_queries::db::model::Name;
<<<<<<< HEAD
use nexus_types::external_api::views::SiloQuotas;
use nexus_types::{
external_api::views::{SledInstance, Switch},
identity::AssetIdentityMetadata,
};
||||||| 7c3cd6abe
use nexus_db_queries::{
authz::ApiResource, db::fixed_data::silo::INTERNAL_SILO_ID,
};
use nexus_types::external_api::{params::ProjectSelector, views::SiloQuotas};
use nexus_types::{
external_api::views::{SledInstance, Switch},
identity::AssetIdentityMetadata,
};
=======
use nexus_db_queries::{
authz::ApiResource, db::fixed_data::silo::INTERNAL_SILO_ID,
};
use nexus_types::external_api::views::Utilization;
>>>>>>> main
use nexus_types::identity::AssetIdentityMetadata;
use omicron_common::api::external::http_pagination::data_page_params_for;
use omicron_common::api::external::http_pagination::marker_for_name;
use omicron_common::api::external::http_pagination::marker_for_name_or_id;
Expand Down Expand Up @@ -1315,13 +1293,7 @@ async fn project_policy_update(

// IP Pools

<<<<<<< HEAD
/// List all IP pools
||||||| 7c3cd6abe
/// List all IP Pools that can be used by a given project.
=======
/// List all IP pools that can be used by a given project
>>>>>>> main
#[endpoint {
method = GET,
path = "/v1/ip-pools",
Expand Down Expand Up @@ -4788,7 +4760,7 @@ async fn rack_view(
async fn sled_list_uninitialized(
rqctx: RequestContext<Arc<ServerContext>>,
query: Query<PaginationParams<EmptyScanParams, String>>,
) -> Result<HttpResponseOk<ResultsPage<UninitializedSled>>, HttpError> {
) -> Result<HttpResponseOk<ResultsPage<shared::UninitializedSled>>, HttpError> {
let apictx = rqctx.context();
// We don't actually support real pagination
let pag_params = query.into_inner();
Expand Down Expand Up @@ -4819,7 +4791,7 @@ async fn sled_list_uninitialized(
}]
async fn sled_add(
rqctx: RequestContext<Arc<ServerContext>>,
sled: TypedBody<UninitializedSledId>,
sled: TypedBody<params::UninitializedSledId>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let apictx = rqctx.context();
let nexus = &apictx.nexus;
Expand Down Expand Up @@ -4933,7 +4905,7 @@ async fn sled_instance_list(
rqctx: RequestContext<Arc<ServerContext>>,
path_params: Path<params::SledPath>,
query_params: Query<PaginatedById>,
) -> Result<HttpResponseOk<ResultsPage<SledInstance>>, HttpError> {
) -> Result<HttpResponseOk<ResultsPage<views::SledInstance>>, HttpError> {
let apictx = rqctx.context();
let handler = async {
let nexus = &apictx.nexus;
Expand All @@ -4954,7 +4926,7 @@ async fn sled_instance_list(
Ok(HttpResponseOk(ScanById::results_page(
&query,
sled_instances,
&|_, sled_instance: &SledInstance| sled_instance.identity.id,
&|_, sled_instance: &views::SledInstance| sled_instance.identity.id,
)?))
};
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
Expand Down Expand Up @@ -5003,7 +4975,7 @@ async fn physical_disk_list(
async fn switch_list(
rqctx: RequestContext<Arc<ServerContext>>,
query_params: Query<PaginatedById>,
) -> Result<HttpResponseOk<ResultsPage<Switch>>, HttpError> {
) -> Result<HttpResponseOk<ResultsPage<views::Switch>>, HttpError> {
let apictx = rqctx.context();
let handler = async {
let nexus = &apictx.nexus;
Expand All @@ -5018,7 +4990,7 @@ async fn switch_list(
Ok(HttpResponseOk(ScanById::results_page(
&query,
switches,
&|_, switch: &Switch| switch.identity.id,
&|_, switch: &views::Switch| switch.identity.id,
)?))
};
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
Expand All @@ -5033,7 +5005,7 @@ async fn switch_list(
async fn switch_view(
rqctx: RequestContext<Arc<ServerContext>>,
path_params: Path<params::SwitchPath>,
) -> Result<HttpResponseOk<Switch>, HttpError> {
) -> Result<HttpResponseOk<views::Switch>, HttpError> {
let apictx = rqctx.context();
let handler = async {
let nexus = &apictx.nexus;
Expand Down
9 changes: 0 additions & 9 deletions nexus/test-utils/src/resource_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ pub async fn create_ip_pool(
client: &ClientTestContext,
pool_name: &str,
ip_range: Option<IpRange>,
silo: Option<Uuid>,
) -> (IpPool, IpPoolRange) {
let pool = object_create(
client,
Expand All @@ -223,14 +222,6 @@ pub async fn create_ip_pool(
name: pool_name.parse().unwrap(),
description: String::from("an ip pool"),
},
<<<<<<< HEAD
||||||| 7c3cd6abe
silo: None,
is_default: false,
=======
silo: silo.map(|id| NameOrId::Id(id)),
is_default: false,
>>>>>>> main
},
)
.await;
Expand Down
3 changes: 2 additions & 1 deletion nexus/tests/integration_tests/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,8 @@ async fn test_phantom_disk_rename(cptestctx: &ControlPlaneTestContext) {

let _disk_test = DiskTest::new(&cptestctx).await;

populate_ip_pool(&client, "default", None).await;
// TODO
// populate_ip_pool(&client, "default", None).await;
let _project_id1 = create_project(client, PROJECT_NAME).await.identity.id;

// Create a 1 GB disk
Expand Down
Loading

0 comments on commit 9a3ffb8

Please sign in to comment.