Skip to content

Commit fb1e0a7

Browse files
committed
walk back "minimum"ness of CPU platforms
1 parent 2af1cca commit fb1e0a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+274
-283
lines changed

common/src/api/external/mod.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,9 +1195,9 @@ pub struct Instance {
11951195
#[serde(flatten)]
11961196
pub auto_restart_status: InstanceAutoRestartStatus,
11971197

1198-
/// The minimum required CPU platform for this instance. If this is `null`,
1199-
/// the instance requires no particular CPU platform.
1200-
pub min_cpu_platform: Option<InstanceMinimumCpuPlatform>,
1198+
/// The CPU platform for this instance. If this is `null`, the instance
1199+
/// requires no particular CPU platform.
1200+
pub cpu_platform: Option<InstanceCpuPlatform>,
12011201
}
12021202

12031203
/// Status of control-plane driven automatic failure recovery for this instance.
@@ -1262,24 +1262,23 @@ pub enum InstanceAutoRestartPolicy {
12621262
BestEffort,
12631263
}
12641264

1265-
/// A minimum required CPU platform for an instance.
1265+
/// A required CPU platform for an instance.
12661266
///
1267-
/// When an instance specifies a minimum required CPU platform:
1267+
/// When an instance specifies a required CPU platform:
12681268
///
12691269
/// - The system may expose (to the VM) new CPU features that are only present
12701270
/// on that platform (or on newer platforms of the same lineage that also
12711271
/// support those features).
12721272
/// - The instance must run on hosts that have CPUs that support all the
1273-
/// features of the supplied minimum platform.
1273+
/// features of the supplied platform.
12741274
///
1275-
/// That is, the instance is restricted to hosts that have the specified minimum
1276-
/// host CPU type (or a more advanced, but still compatible, CPU), but in
1277-
/// exchange the CPU features exposed by the minimum platform are available for
1278-
/// the guest to use. Note that this may prevent an instance from starting (if
1279-
/// the hosts it requires are full but there is capacity on other incompatible
1280-
/// hosts).
1275+
/// That is, the instance is restricted to hosts that have the CPUs which
1276+
/// support all features of the required platform, but in exchange the CPU
1277+
/// features exposed by the platform are available for the guest to use. Note
1278+
/// that this may prevent an instance from starting (if the hosts that could run
1279+
/// it are full but there is capacity on other incompatible hosts).
12811280
///
1282-
/// If an instance does not specify a minimum required CPU platform, then when
1281+
/// If an instance does not specify a required CPU platform, then when
12831282
/// it starts, the control plane selects a host for the instance and then
12841283
/// supplies the guest with the "minimum" CPU platform supported by that host.
12851284
/// This maximizes the number of hosts that can run the VM if it later needs to
@@ -1294,7 +1293,7 @@ pub enum InstanceAutoRestartPolicy {
12941293
Copy, Clone, Debug, Deserialize, Serialize, JsonSchema, Eq, PartialEq,
12951294
)]
12961295
#[serde(rename_all = "snake_case")]
1297-
pub enum InstanceMinimumCpuPlatform {
1296+
pub enum InstanceCpuPlatform {
12981297
/// An AMD Milan-like CPU platform.
12991298
AmdMilan,
13001299

end-to-end-tests/src/instance_launch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async fn instance_launch() -> Result<()> {
7979
start: true,
8080
auto_restart_policy: Default::default(),
8181
anti_affinity_groups: Vec::new(),
82-
min_cpu_platform: None,
82+
cpu_platform: None,
8383
})
8484
.send()
8585
.await?;

nexus/db-model/src/instance.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use super::InstanceIntendedState as IntendedState;
66
use super::{
77
ByteCount, Disk, ExternalIp, Generation, InstanceAutoRestartPolicy,
8-
InstanceCpuCount, InstanceMinimumCpuPlatform, InstanceState, Vmm, VmmState,
8+
InstanceCpuCount, InstanceCpuPlatform, InstanceState, Vmm, VmmState,
99
};
1010
use crate::collection::DatastoreAttachTargetConfig;
1111
use crate::serde_time_delta::optional_time_delta;
@@ -68,8 +68,8 @@ pub struct Instance {
6868
#[diesel(column_name = boot_disk_id)]
6969
pub boot_disk_id: Option<Uuid>,
7070

71-
/// The instance's minimum required CPU platform.
72-
pub min_cpu_platform: Option<InstanceMinimumCpuPlatform>,
71+
/// The instance's required CPU platform.
72+
pub cpu_platform: Option<InstanceCpuPlatform>,
7373

7474
#[diesel(embed)]
7575
pub runtime_state: InstanceRuntimeState,
@@ -142,7 +142,7 @@ impl Instance {
142142
// Intentionally ignore `params.boot_disk_id` here: we can't set
143143
// `boot_disk_id` until the referenced disk is attached.
144144
boot_disk_id: None,
145-
min_cpu_platform: params.min_cpu_platform.map(Into::into),
145+
cpu_platform: params.cpu_platform.map(Into::into),
146146

147147
runtime_state,
148148
intended_state,
@@ -498,5 +498,5 @@ pub struct InstanceUpdate {
498498

499499
pub memory: ByteCount,
500500

501-
pub min_cpu_platform: Option<InstanceMinimumCpuPlatform>,
501+
pub cpu_platform: Option<InstanceCpuPlatform>,
502502
}

nexus/db-model/src/instance_minimum_cpu_platform.rs renamed to nexus/db-model/src/instance_cpu_platform.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::impl_enum_type;
88
use serde::{Deserialize, Serialize};
99

1010
impl_enum_type!(
11-
InstanceMinimumCpuPlatformEnum:
11+
InstanceCpuPlatformEnum:
1212

1313
#[derive(
1414
Copy,
@@ -20,15 +20,15 @@ impl_enum_type!(
2020
Serialize,
2121
Deserialize
2222
)]
23-
pub enum InstanceMinimumCpuPlatform;
23+
pub enum InstanceCpuPlatform;
2424

2525
AmdMilan => b"amd_milan"
2626
AmdTurin => b"amd_turin"
2727
);
2828

29-
impl InstanceMinimumCpuPlatform {
29+
impl InstanceCpuPlatform {
3030
/// Returns a slice containing the set of sled CPU families that can
31-
/// accommodate an instance with this minimum CPU platform.
31+
/// accommodate an instance with this CPU platform.
3232
pub fn compatible_sled_cpu_families(&self) -> &'static [SledCpuFamily] {
3333
match self {
3434
// Turin-based sleds have a superset of the features made available
@@ -41,27 +41,25 @@ impl InstanceMinimumCpuPlatform {
4141
}
4242
}
4343

44-
impl From<omicron_common::api::external::InstanceMinimumCpuPlatform>
45-
for InstanceMinimumCpuPlatform
44+
impl From<omicron_common::api::external::InstanceCpuPlatform>
45+
for InstanceCpuPlatform
4646
{
47-
fn from(
48-
value: omicron_common::api::external::InstanceMinimumCpuPlatform,
49-
) -> Self {
50-
use omicron_common::api::external::InstanceMinimumCpuPlatform as ApiPlatform;
47+
fn from(value: omicron_common::api::external::InstanceCpuPlatform) -> Self {
48+
use omicron_common::api::external::InstanceCpuPlatform as ApiPlatform;
5149
match value {
5250
ApiPlatform::AmdMilan => Self::AmdMilan,
5351
ApiPlatform::AmdTurin => Self::AmdTurin,
5452
}
5553
}
5654
}
5755

58-
impl From<InstanceMinimumCpuPlatform>
59-
for omicron_common::api::external::InstanceMinimumCpuPlatform
56+
impl From<InstanceCpuPlatform>
57+
for omicron_common::api::external::InstanceCpuPlatform
6058
{
61-
fn from(value: InstanceMinimumCpuPlatform) -> Self {
59+
fn from(value: InstanceCpuPlatform) -> Self {
6260
match value {
63-
InstanceMinimumCpuPlatform::AmdMilan => Self::AmdMilan,
64-
InstanceMinimumCpuPlatform::AmdTurin => Self::AmdTurin,
61+
InstanceCpuPlatform::AmdMilan => Self::AmdMilan,
62+
InstanceCpuPlatform::AmdTurin => Self::AmdTurin,
6563
}
6664
}
6765
}

nexus/db-model/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ mod image;
4343
mod instance;
4444
mod instance_auto_restart_policy;
4545
mod instance_cpu_count;
46+
mod instance_cpu_platform;
4647
mod instance_intended_state;
47-
mod instance_minimum_cpu_platform;
4848
mod instance_state;
4949
mod internet_gateway;
5050
mod inventory;
@@ -182,8 +182,8 @@ pub use image::*;
182182
pub use instance::*;
183183
pub use instance_auto_restart_policy::*;
184184
pub use instance_cpu_count::*;
185+
pub use instance_cpu_platform::*;
185186
pub use instance_intended_state::*;
186-
pub use instance_minimum_cpu_platform::*;
187187
pub use instance_state::*;
188188
pub use internet_gateway::*;
189189
pub use inventory::*;

nexus/db-model/src/schema_versions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
2828
// | leaving the first copy as an example for the next person.
2929
// v
3030
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
31-
KnownVersion::new(175, "add-instance-minimum-cpu-platform"),
31+
KnownVersion::new(175, "add-instance-cpu-platform"),
3232
KnownVersion::new(174, "sled-cpu-family"),
3333
KnownVersion::new(173, "inv-internal-dns"),
3434
KnownVersion::new(172, "add-zones-with-mupdate-override"),

nexus/db-model/src/vmm_cpu_platform.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
use crate::{InstanceMinimumCpuPlatform, SledCpuFamily};
5+
use crate::{InstanceCpuPlatform, SledCpuFamily};
66

77
use super::impl_enum_type;
88
use serde::{Deserialize, Serialize};
@@ -50,11 +50,11 @@ impl VmmCpuPlatform {
5050
}
5151
}
5252

53-
impl From<InstanceMinimumCpuPlatform> for VmmCpuPlatform {
54-
fn from(value: InstanceMinimumCpuPlatform) -> Self {
53+
impl From<InstanceCpuPlatform> for VmmCpuPlatform {
54+
fn from(value: InstanceCpuPlatform) -> Self {
5555
match value {
56-
InstanceMinimumCpuPlatform::AmdMilan => Self::AmdMilan,
57-
InstanceMinimumCpuPlatform::AmdTurin => Self::AmdTurin,
56+
InstanceCpuPlatform::AmdMilan => Self::AmdMilan,
57+
InstanceCpuPlatform::AmdTurin => Self::AmdTurin,
5858
}
5959
}
6060
}

nexus/db-queries/src/db/datastore/instance.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use crate::db::model::Instance;
2121
use crate::db::model::InstanceAutoRestart;
2222
use crate::db::model::InstanceAutoRestartPolicy;
2323
use crate::db::model::InstanceCpuCount;
24+
use crate::db::model::InstanceCpuPlatform;
2425
use crate::db::model::InstanceIntendedState;
25-
use crate::db::model::InstanceMinimumCpuPlatform;
2626
use crate::db::model::InstanceRuntimeState;
2727
use crate::db::model::InstanceState;
2828
use crate::db::model::InstanceUpdate;
@@ -266,7 +266,7 @@ impl From<InstanceAndActiveVmm> for external::Instance {
266266
.parse()
267267
.expect("found invalid hostname in the database"),
268268
boot_disk_id: value.instance.boot_disk_id,
269-
min_cpu_platform: value.instance.min_cpu_platform.map(Into::into),
269+
cpu_platform: value.instance.cpu_platform.map(Into::into),
270270
runtime: external::InstanceRuntimeState {
271271
run_state: value.effective_state(),
272272
time_run_state_updated,
@@ -1098,7 +1098,7 @@ impl DataStore {
10981098
auto_restart_policy,
10991099
ncpus,
11001100
memory,
1101-
min_cpu_platform,
1101+
cpu_platform,
11021102
} = update.clone();
11031103
async move {
11041104
// Set the auto-restart policy.
@@ -1118,7 +1118,7 @@ impl DataStore {
11181118
&authz_instance,
11191119
ncpus,
11201120
memory,
1121-
min_cpu_platform,
1121+
cpu_platform,
11221122
)
11231123
.await?;
11241124

@@ -1302,7 +1302,7 @@ impl DataStore {
13021302
authz_instance: &authz::Instance,
13031303
ncpus: InstanceCpuCount,
13041304
memory: ByteCount,
1305-
min_cpu_platform: Option<InstanceMinimumCpuPlatform>,
1305+
cpu_platform: Option<InstanceCpuPlatform>,
13061306
) -> Result<(), diesel::result::Error> {
13071307
use nexus_db_schema::schema::instance::dsl as instance_dsl;
13081308

@@ -1314,36 +1314,36 @@ impl DataStore {
13141314
.eq_any(InstanceState::NOT_INCARNATED_STATES),
13151315
);
13161316

1317-
let query = if min_cpu_platform.is_some() {
1317+
let query = if cpu_platform.is_some() {
13181318
query.filter(
13191319
instance_dsl::ncpus
13201320
.ne(ncpus)
13211321
.or(instance_dsl::memory.ne(memory))
1322-
.or(instance_dsl::min_cpu_platform.ne(min_cpu_platform))
1323-
.or(instance_dsl::min_cpu_platform.is_null()),
1322+
.or(instance_dsl::cpu_platform.ne(cpu_platform))
1323+
.or(instance_dsl::cpu_platform.is_null()),
13241324
)
13251325
} else {
13261326
query.filter(
13271327
instance_dsl::ncpus
13281328
.ne(ncpus)
13291329
.or(instance_dsl::memory.ne(memory))
1330-
.or(instance_dsl::min_cpu_platform.is_not_null()),
1330+
.or(instance_dsl::cpu_platform.is_not_null()),
13311331
)
13321332
};
13331333

13341334
let r = query
13351335
.set((
13361336
instance_dsl::ncpus.eq(ncpus),
13371337
instance_dsl::memory.eq(memory),
1338-
instance_dsl::min_cpu_platform.eq(min_cpu_platform),
1338+
instance_dsl::cpu_platform.eq(cpu_platform),
13391339
))
13401340
.check_if_exists::<Instance>(authz_instance.id())
13411341
.execute_and_check(&conn)
13421342
.await?;
13431343
match r.status {
13441344
UpdateStatus::NotUpdatedButExists => {
1345-
if (r.found.ncpus, r.found.memory, r.found.min_cpu_platform)
1346-
== (ncpus, memory, min_cpu_platform)
1345+
if (r.found.ncpus, r.found.memory, r.found.cpu_platform)
1346+
== (ncpus, memory, cpu_platform)
13471347
{
13481348
// Not updated, because the update is no change..
13491349
return Ok(());
@@ -1365,7 +1365,7 @@ impl DataStore {
13651365
"instance_id" => %r.found.id(),
13661366
"new ncpus" => ?ncpus,
13671367
"new memory" => ?memory,
1368-
"new CPU platform" => ?min_cpu_platform,
1368+
"new CPU platform" => ?cpu_platform,
13691369
);
13701370
return Err(err.bail(Error::internal_error(
13711371
"unable to change instance CPU or memory",
@@ -2255,7 +2255,7 @@ mod tests {
22552255
external_ips: Vec::new(),
22562256
disks: Vec::new(),
22572257
boot_disk: None,
2258-
min_cpu_platform: None,
2258+
cpu_platform: None,
22592259
ssh_public_keys: None,
22602260
start: false,
22612261
auto_restart_policy: Default::default(),

nexus/db-queries/src/db/datastore/migration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ mod tests {
235235
external_ips: Vec::new(),
236236
disks: Vec::new(),
237237
boot_disk: None,
238-
min_cpu_platform: None,
238+
cpu_platform: None,
239239
ssh_public_keys: None,
240240
start: false,
241241
auto_restart_policy: Default::default(),

nexus/db-queries/src/db/datastore/sled.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ pub(in crate::db::datastore) mod test {
10871087
use nexus_db_model::PhysicalDiskPolicy;
10881088
use nexus_db_model::PhysicalDiskState;
10891089
use nexus_db_model::{Generation, SledCpuFamily};
1090-
use nexus_db_model::{InstanceMinimumCpuPlatform, PhysicalDisk};
1090+
use nexus_db_model::{InstanceCpuPlatform, PhysicalDisk};
10911091
use nexus_types::identity::Asset;
10921092
use nexus_types::identity::Resource;
10931093
use omicron_common::api::external;
@@ -1475,7 +1475,7 @@ pub(in crate::db::datastore) mod test {
14751475
groups: Vec<GroupName>,
14761476
force_onto_sled: Option<SledUuid>,
14771477
resources: db::model::Resources,
1478-
min_cpu_platform: Option<db::model::InstanceMinimumCpuPlatform>,
1478+
cpu_platform: Option<db::model::InstanceCpuPlatform>,
14791479
}
14801480

14811481
struct FindTargetsOutput {
@@ -1492,7 +1492,7 @@ pub(in crate::db::datastore) mod test {
14921492
groups: vec![],
14931493
force_onto_sled: None,
14941494
resources: small_resource_request(),
1495-
min_cpu_platform: None,
1495+
cpu_platform: None,
14961496
}
14971497
}
14981498

@@ -1505,7 +1505,7 @@ pub(in crate::db::datastore) mod test {
15051505
assert!(self.force_onto_sled.is_none());
15061506

15071507
let families =
1508-
self.min_cpu_platform.map(|p| p.compatible_sled_cpu_families());
1508+
self.cpu_platform.map(|p| p.compatible_sled_cpu_families());
15091509

15101510
sled_find_targets_query(self.id, &self.resources, families)
15111511
.get_results_async::<(
@@ -2675,14 +2675,13 @@ pub(in crate::db::datastore) mod test {
26752675
}
26762676

26772677
let mut test_instance = Instance::new();
2678-
for platform in [None, Some(InstanceMinimumCpuPlatform::AmdMilan)] {
2679-
test_instance.min_cpu_platform = platform;
2678+
for platform in [None, Some(InstanceCpuPlatform::AmdMilan)] {
2679+
test_instance.cpu_platform = platform;
26802680
let possible_sleds = test_instance.find_targets(&datastore).await;
26812681
assert_eq!(possible_sleds.len(), 4);
26822682
}
26832683

2684-
test_instance.min_cpu_platform =
2685-
Some(InstanceMinimumCpuPlatform::AmdTurin);
2684+
test_instance.cpu_platform = Some(InstanceCpuPlatform::AmdTurin);
26862685
let possible_sleds = test_instance.find_targets(&datastore).await;
26872686
assert_eq!(possible_sleds.len(), 2);
26882687
}

0 commit comments

Comments
 (0)