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

Setup the VMM reservoir in a background task #5124

Merged
merged 35 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1d0ed8c
Setup the VMM reservoir in a background task
andrewjstone Feb 22, 2024
bbbe079
comments
andrewjstone Feb 22, 2024
bdea2f6
review fixes
andrewjstone Feb 23, 2024
710b0ce
Wait for VMM reservoir allocation when ensuring propolis instances
andrewjstone Feb 26, 2024
233f2d1
Revert "Wait for VMM reservoir allocation when ensuring propolis inst…
andrewjstone Feb 27, 2024
bedf0c1
remove watch from vmm_reservoir
andrewjstone Feb 27, 2024
7bdf2e3
Add sled_agent_get to nexus internal API
andrewjstone Feb 27, 2024
7c4a2de
wip
andrewjstone Feb 28, 2024
58a84fa
wip
andrewjstone Feb 28, 2024
f6116b6
wip
andrewjstone Feb 28, 2024
cf185cf
wip
andrewjstone Feb 28, 2024
7dbcedc
wip
andrewjstone Feb 29, 2024
7429a8d
wip
andrewjstone Feb 29, 2024
c6a396c
wip
andrewjstone Feb 29, 2024
32cd05b
wip
andrewjstone Feb 29, 2024
e7ce5af
wip
andrewjstone Feb 29, 2024
00d248e
wip
andrewjstone Feb 29, 2024
adc29dc
Solid test for sled-agent
andrewjstone Feb 29, 2024
3418a60
Make sled upserts conditional on rcgen
andrewjstone Mar 1, 2024
0488749
extra rcgen check
andrewjstone Mar 1, 2024
8a7d297
plumb through reservoir size changes
andrewjstone Mar 4, 2024
f379afb
typo
andrewjstone Mar 4, 2024
9c130e2
Merge branch 'main' into ajs/vmm-reservoir-bg-thread
andrewjstone Mar 4, 2024
f49208e
Return an result for sled upserts, with error for decommissioned
andrewjstone Mar 5, 2024
5b1914b
fix warnings
andrewjstone Mar 5, 2024
e5795c9
clippy
andrewjstone Mar 5, 2024
8d1ae0c
Merge branch 'main' into ajs/vmm-reservoir-bg-thread
andrewjstone Mar 5, 2024
0f904f4
Give sled-agent its own generation number
andrewjstone Mar 7, 2024
4fd1afd
review fixes
andrewjstone Mar 7, 2024
edbf0a0
Merge branch 'main' into ajs/vmm-reservoir-bg-thread
andrewjstone Mar 7, 2024
5b01ef0
Handle sled decommissioning
andrewjstone Mar 7, 2024
332832e
Merge branch 'main' into ajs/vmm-reservoir-bg-thread
andrewjstone Mar 7, 2024
e9167a8
type fix for Baseboard
andrewjstone Mar 7, 2024
c611a81
COMMENTS
andrewjstone Mar 7, 2024
9027e5b
Merge branch 'main' into ajs/vmm-reservoir-bg-thread
andrewjstone Mar 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions clients/nexus-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ progenitor::generate_api!(
MacAddr = omicron_common::api::external::MacAddr,
Name = omicron_common::api::external::Name,
NewPasswordHash = omicron_passwords::NewPasswordHash,
},
patch = {
SledAgentInfo = { derives = [PartialEq, Eq] },
ByteCount = { derives = [PartialEq, Eq] },
Baseboard = { derives = [PartialEq, Eq] }
}
);

Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use omicron_common::api::external::SemverVersion;
///
/// 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(38, 0, 0);
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(39, 0, 0);

table! {
disk (id) {
Expand Down Expand Up @@ -827,6 +827,7 @@ table! {
last_used_address -> Inet,
sled_policy -> crate::sled_policy::SledPolicyEnum,
sled_state -> crate::SledStateEnum,
sled_agent_gen -> Int8,
}
}

Expand Down
49 changes: 47 additions & 2 deletions nexus/db-model/src/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ use super::{ByteCount, Generation, SledState, SqlU16, SqlU32};
use crate::collection::DatastoreCollectionConfig;
use crate::ipv6;
use crate::schema::{physical_disk, service, sled, zpool};
use crate::sled::shared::Baseboard;
use crate::sled_policy::DbSledPolicy;
use chrono::{DateTime, Utc};
use db_macros::Asset;
use nexus_types::{external_api::shared, external_api::views, identity::Asset};
use nexus_types::{
external_api::{shared, views},
identity::Asset,
internal_api::params,
};
use std::net::Ipv6Addr;
use std::net::SocketAddrV6;
use uuid::Uuid;
Expand Down Expand Up @@ -41,7 +46,7 @@ pub struct Sled {
#[diesel(embed)]
identity: SledIdentity,
time_deleted: Option<DateTime<Utc>>,
rcgen: Generation,
pub rcgen: Generation,

pub rack_id: Uuid,

Expand All @@ -66,6 +71,12 @@ pub struct Sled {

#[diesel(column_name = sled_state)]
state: SledState,

/// A generation number owned and incremented by sled-agent
///
/// This is specifically distinct from `rcgen`, which is incremented by
/// child resources as part of `DatastoreCollectionConfig`.
pub sled_agent_gen: Generation,
}

impl Sled {
Expand Down Expand Up @@ -119,6 +130,34 @@ impl From<Sled> for views::Sled {
}
}

impl From<Sled> for params::SledAgentInfo {
fn from(sled: Sled) -> Self {
let role = if sled.is_scrimlet {
params::SledRole::Scrimlet
} else {
params::SledRole::Gimlet
};
let decommissioned = match sled.state {
SledState::Active => false,
SledState::Decommissioned => true,
};
Self {
sa_address: sled.address(),
role,
baseboard: Baseboard {
serial: sled.serial_number.clone(),
part: sled.part_number.clone(),
revision: sled.revision,
},
usable_hardware_threads: sled.usable_hardware_threads.into(),
usable_physical_ram: sled.usable_physical_ram.into(),
reservoir_size: sled.reservoir_size.into(),
generation: sled.sled_agent_gen.into(),
decommissioned,
}
}
}

impl DatastoreCollectionConfig<super::PhysicalDisk> for Sled {
type CollectionId = Uuid;
type GenerationNumberColumn = sled::dsl::rcgen;
Expand Down Expand Up @@ -161,6 +200,9 @@ pub struct SledUpdate {
// ServiceAddress (Sled Agent).
pub ip: ipv6::Ipv6Addr,
pub port: SqlU16,

// Generation number - owned and incremented by sled-agent.
pub sled_agent_gen: Generation,
}

impl SledUpdate {
Expand All @@ -170,6 +212,7 @@ impl SledUpdate {
baseboard: SledBaseboard,
hardware: SledSystemHardware,
rack_id: Uuid,
sled_agent_gen: Generation,
) -> Self {
Self {
id,
Expand All @@ -185,6 +228,7 @@ impl SledUpdate {
reservoir_size: hardware.reservoir_size,
ip: addr.ip().into(),
port: addr.port().into(),
sled_agent_gen,
}
}

Expand Down Expand Up @@ -220,6 +264,7 @@ impl SledUpdate {
ip: self.ip,
port: self.port,
last_used_address,
sled_agent_gen: self.sled_agent_gen,
}
}

Expand Down
8 changes: 3 additions & 5 deletions nexus/db-queries/src/db/datastore/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ impl DataStore {
mod test {
use super::*;
use crate::db::datastore::test_utils::datastore_test;
use nexus_db_model::Generation;
use nexus_db_model::SledBaseboard;
use nexus_db_model::SledSystemHardware;
use nexus_db_model::SledUpdate;
Expand Down Expand Up @@ -222,12 +223,9 @@ mod test {
reservoir_size: (16 << 30).try_into().unwrap(),
},
Uuid::new_v4(),
Generation::new(),
);
datastore
.sled_upsert(sled)
.await
.expect("failed to upsert sled")
.unwrap();
datastore.sled_upsert(sled).await.expect("failed to upsert sled");

// Create a fake zpool that backs our fake datasets.
let zpool_id = Uuid::new_v4();
Expand Down
11 changes: 7 additions & 4 deletions nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ pub use instance::InstanceAndActiveVmm;
pub use inventory::DataStoreInventoryTest;
pub use rack::RackInit;
pub use silo::Discoverability;
pub use sled::SledUpsertOutput;
pub use switch_port::SwitchPortSettingsCombinedResult;
pub use virtual_provisioning_collection::StorageType;
pub use volume::read_only_resources_associated_with_volume;
Expand Down Expand Up @@ -393,6 +392,7 @@ mod test {
use futures::stream;
use futures::StreamExt;
use nexus_config::RegionAllocationStrategy;
use nexus_db_model::Generation;
use nexus_db_model::IpAttachState;
use nexus_test_utils::db::test_setup_database;
use nexus_types::external_api::params;
Expand Down Expand Up @@ -619,8 +619,9 @@ mod test {
sled_baseboard_for_test(),
sled_system_hardware_for_test(),
rack_id,
Generation::new(),
);
datastore.sled_upsert(sled_update).await.unwrap().unwrap();
datastore.sled_upsert(sled_update).await.unwrap();
sled_id
}

Expand Down Expand Up @@ -1338,8 +1339,9 @@ mod test {
sled_baseboard_for_test(),
sled_system_hardware_for_test(),
rack_id,
Generation::new(),
);
datastore.sled_upsert(sled1).await.unwrap().unwrap();
datastore.sled_upsert(sled1).await.unwrap();

let addr2 = "[fd00:1df::1]:12345".parse().unwrap();
let sled2_id = "66285c18-0c79-43e0-e54f-95271f271314".parse().unwrap();
Expand All @@ -1349,8 +1351,9 @@ mod test {
sled_baseboard_for_test(),
sled_system_hardware_for_test(),
rack_id,
Generation::new(),
);
datastore.sled_upsert(sled2).await.unwrap().unwrap();
datastore.sled_upsert(sled2).await.unwrap();

let ip = datastore.next_ipv6_address(&opctx, sled1_id).await.unwrap();
let expected_ip = Ipv6Addr::new(0xfd00, 0x1de, 0, 0, 0, 0, 1, 0);
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-queries/src/db/datastore/physical_disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ mod test {
use crate::db::datastore::test_utils::datastore_test;
use crate::db::model::{PhysicalDiskKind, Sled, SledUpdate};
use dropshot::PaginationOrder;
use nexus_db_model::Generation;
use nexus_test_utils::db::test_setup_database;
use nexus_types::identity::Asset;
use omicron_test_utils::dev;
Expand All @@ -159,11 +160,11 @@ mod test {
sled_baseboard_for_test(),
sled_system_hardware_for_test(),
rack_id,
Generation::new(),
);
db.sled_upsert(sled_update)
.await
.expect("Could not upsert sled during test prep")
.unwrap()
}

fn list_disk_params() -> DataPageParams<'static, Uuid> {
Expand Down
4 changes: 2 additions & 2 deletions nexus/db-queries/src/db/datastore/rack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ mod test {
use async_bb8_diesel::AsyncSimpleConnection;
use internal_params::DnsRecord;
use nexus_config::NUM_INITIAL_RESERVED_IP_ADDRESSES;
use nexus_db_model::{DnsGroup, InitialDnsGroup, SledUpdate};
use nexus_db_model::{DnsGroup, Generation, InitialDnsGroup, SledUpdate};
use nexus_test_utils::db::test_setup_database;
use nexus_types::external_api::shared::SiloIdentityMode;
use nexus_types::identity::Asset;
Expand Down Expand Up @@ -1065,11 +1065,11 @@ mod test {
sled_baseboard_for_test(),
sled_system_hardware_for_test(),
rack_id(),
Generation::new(),
);
db.sled_upsert(sled_update)
.await
.expect("Could not upsert sled during test prep")
.unwrap()
}

// Hacky macro helper to:
Expand Down
Loading
Loading