Skip to content

Commit 43c193c

Browse files
authored
chore: [NODE-1683] Remove deprecated VM fields (#7037)
1 parent 6189a7c commit 43c193c

File tree

12 files changed

+126
-131
lines changed

12 files changed

+126
-131
lines changed

rs/ic_os/config/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ mod tests {
7474
icos_dev_settings,
7575
};
7676
let setupos_settings = SetupOSSettings;
77-
#[allow(deprecated)]
7877
let hostos_settings = HostOSSettings {
79-
vm_memory: 16,
80-
vm_cpu: "kvm".to_string(),
81-
vm_nr_of_vcpus: 64,
8278
verbose: false,
8379
hostos_dev_settings: HostOSDevSettings {
8480
vm_memory: 16,

rs/ic_os/config/src/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,7 @@ pub fn assemble_setupos_config(
234234

235235
let setupos_settings = SetupOSSettings;
236236

237-
#[allow(deprecated)]
238237
let hostos_settings = HostOSSettings {
239-
vm_memory: dev_vm_resources.memory,
240-
vm_cpu: dev_vm_resources.cpu.clone(),
241-
vm_nr_of_vcpus: dev_vm_resources.nr_of_vcpus,
242238
verbose,
243239
hostos_dev_settings: HostOSDevSettings {
244240
vm_memory: dev_vm_resources.memory,

rs/ic_os/config/src/setupos/deployment_json.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@ pub struct DeploymentSettings {
1616
pub dev_vm_resources: VmResources,
1717
}
1818

19-
// NOTE #7037: We should always use DeploymentSettings directly, but we need to
20-
// be compatible with old naming for some tests.
21-
#[derive(PartialEq, Debug, Deserialize, Serialize)]
22-
pub struct CompatDeploymentSettings {
23-
pub deployment: Deployment,
24-
#[serde(default)]
25-
pub logging: Logging,
26-
pub nns: Nns,
27-
pub vm_resources: Option<VmResources>,
28-
pub dev_vm_resources: Option<VmResources>,
29-
}
30-
3119
#[serde_as]
3220
#[derive(PartialEq, Debug, Deserialize, Serialize)]
3321
pub struct Deployment {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"config_version": "1.11.0",
3+
"network_settings": {
4+
"ipv6_config": {
5+
"Fixed": {
6+
"address": "2a00:fb01:400:200::1/64",
7+
"gateway": "2a00:fb01:400:200::1"
8+
}
9+
},
10+
"ipv4_config": {
11+
"address": "192.168.1.1",
12+
"gateway": "192.168.1.254",
13+
"prefix_length": 24
14+
},
15+
"domain_name": "ic.test"
16+
},
17+
"icos_settings": {
18+
"node_reward_type": "type3.1",
19+
"mgmt_mac": "00:00:00:00:00:01",
20+
"deployment_environment": "mainnet",
21+
"nns_urls": [
22+
"https://icp-api.io,https//icp0.io,https://ic0.app"
23+
],
24+
"use_node_operator_private_key": true,
25+
"enable_trusted_execution_environment": false,
26+
"use_ssh_authorized_keys": false,
27+
"icos_dev_settings": {}
28+
},
29+
"guestos_settings": {
30+
"inject_ic_crypto": false,
31+
"inject_ic_state": false,
32+
"inject_ic_registry_local_store": false,
33+
"guestos_dev_settings": {
34+
"backup_spool": null,
35+
"malicious_behavior": null,
36+
"query_stats_epoch_length": null,
37+
"bitcoind_addr": null,
38+
"dogecoind_addr": null,
39+
"jaeger_addr": null,
40+
"socks_proxy": null,
41+
"hostname": null,
42+
"generate_ic_boundary_tls_cert": null
43+
}
44+
},
45+
"guest_vm_type": "default",
46+
"upgrade_config": {
47+
"peer_guest_vm_address": "2a00:fb01:400:200:6801:95ff:fed7:d475"
48+
},
49+
"trusted_execution_environment_config": {
50+
"sev_cert_chain_pem": "-----BEGIN CERTIFICATE----------END CERTIFICATE-----"
51+
},
52+
"recovery_config": null
53+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"config_version": "1.11.0",
3+
"network_settings": {
4+
"ipv6_config": {
5+
"Fixed": {
6+
"address": "2a00:fb01:400:200::1/64",
7+
"gateway": "2a00:fb01:400:200::1"
8+
}
9+
},
10+
"ipv4_config": {
11+
"address": "192.168.1.1",
12+
"gateway": "192.168.1.254",
13+
"prefix_length": 24
14+
},
15+
"domain_name": "ic.test"
16+
},
17+
"icos_settings": {
18+
"node_reward_type": "type3.1",
19+
"mgmt_mac": "00:00:00:00:00:01",
20+
"deployment_environment": "mainnet",
21+
"nns_urls": [
22+
"https://icp-api.io,https//icp0.io,https://ic0.app"
23+
],
24+
"use_node_operator_private_key": true,
25+
"enable_trusted_execution_environment": false,
26+
"use_ssh_authorized_keys": false,
27+
"icos_dev_settings": {}
28+
},
29+
"hostos_settings": {
30+
"hostos_dev_settings": {
31+
"vm_memory": 16,
32+
"vm_cpu": "kvm",
33+
"vm_nr_of_vcpus": 64
34+
},
35+
"verbose": false
36+
},
37+
"guestos_settings": {
38+
"inject_ic_crypto": false,
39+
"inject_ic_state": false,
40+
"inject_ic_registry_local_store": false,
41+
"guestos_dev_settings": {
42+
"backup_spool": null,
43+
"malicious_behavior": null,
44+
"query_stats_epoch_length": null,
45+
"bitcoind_addr": null,
46+
"dogecoind_addr": null,
47+
"jaeger_addr": null,
48+
"socks_proxy": null,
49+
"hostname": null,
50+
"generate_ic_boundary_tls_cert": null
51+
}
52+
}
53+
}

rs/ic_os/config_types/compatibility_tests/src/fixture.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ fn generate_hostos_config() -> HostOSConfig {
7474
icos_dev_settings: ICOSDevSettings::default(),
7575
};
7676

77-
#[allow(deprecated)]
7877
let hostos_settings = HostOSSettings {
79-
vm_memory: 16,
80-
vm_cpu: "kvm".to_string(),
81-
vm_nr_of_vcpus: 64,
8278
verbose: false,
8379
hostos_dev_settings: HostOSDevSettings {
8480
vm_memory: 16,

rs/ic_os/config_types/src/lib.rs

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ use std::str::FromStr;
3131
use strum::EnumString;
3232
use url::Url;
3333

34-
pub const CONFIG_VERSION: &str = "1.10.0";
34+
pub const CONFIG_VERSION: &str = "1.11.0";
3535

3636
/// List of field paths that have been removed and should not be reused.
37-
pub static RESERVED_FIELD_PATHS: &[&str] =
38-
&["icos_settings.logging", "icos_settings.use_nns_public_key"];
37+
pub static RESERVED_FIELD_PATHS: &[&str] = &[
38+
"icos_settings.logging",
39+
"icos_settings.use_nns_public_key",
40+
"hostos_settings.vm_cpu",
41+
"hostos_settings.vm_memory",
42+
"hostos_settings.vm_nr_of_vcpus",
43+
];
3944

4045
pub type ConfigMap = HashMap<String, String>;
4146

@@ -148,37 +153,13 @@ pub struct ICOSDevSettings {}
148153
pub struct SetupOSSettings;
149154

150155
/// HostOS-specific settings.
151-
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
156+
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Default)]
152157
pub struct HostOSSettings {
153158
#[serde(default)]
154159
pub hostos_dev_settings: HostOSDevSettings,
155-
#[deprecated(note = "Please use hostos_dev_settings")]
156-
pub vm_memory: u32,
157-
#[deprecated(note = "Please use hostos_dev_settings")]
158-
pub vm_cpu: String,
159-
#[deprecated(note = "Please use hostos_dev_settings")]
160-
#[serde(default = "default_vm_nr_of_vcpus")]
161-
pub vm_nr_of_vcpus: u32,
162160
pub verbose: bool,
163161
}
164162

165-
impl Default for HostOSSettings {
166-
fn default() -> Self {
167-
#[allow(deprecated)]
168-
HostOSSettings {
169-
vm_memory: Default::default(),
170-
vm_cpu: Default::default(),
171-
vm_nr_of_vcpus: default_vm_nr_of_vcpus(),
172-
verbose: Default::default(),
173-
hostos_dev_settings: Default::default(),
174-
}
175-
}
176-
}
177-
178-
const fn default_vm_nr_of_vcpus() -> u32 {
179-
64
180-
}
181-
182163
/// HostOS development configuration. These settings are strictly used for development images.
183164
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
184165
pub struct HostOSDevSettings {
@@ -337,33 +318,6 @@ mod tests {
337318
use serde_json::Value;
338319
use std::collections::HashSet;
339320

340-
#[test]
341-
fn test_vm_nr_of_vcpus_deserialization() -> Result<(), Box<dyn std::error::Error>> {
342-
#[allow(deprecated)]
343-
{
344-
// Test with vm_nr_of_vcpus specified
345-
let json = r#"{
346-
"vm_memory": 16,
347-
"vm_cpu": "host",
348-
"vm_nr_of_vcpus": 4,
349-
"verbose": true
350-
}"#;
351-
let settings: HostOSSettings = serde_json::from_str(json)?;
352-
assert_eq!(settings.vm_nr_of_vcpus, 4);
353-
354-
// Test without vm_nr_of_vcpus (should use default)
355-
let json = r#"{
356-
"vm_memory": 16,
357-
"vm_cpu": "host",
358-
"verbose": true
359-
}"#;
360-
let settings: HostOSSettings = serde_json::from_str(json)?;
361-
assert_eq!(settings.vm_nr_of_vcpus, 64);
362-
}
363-
364-
Ok(())
365-
}
366-
367321
#[test]
368322
fn test_guest_vm_type_forward_compatibility() -> Result<(), Box<dyn std::error::Error>> {
369323
// Test that unknown enum variants deserialize to Unknown

rs/ic_os/dev_test_tools/setupos-image-config/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
use anyhow::{Context, Error, bail};
1010

1111
use config::setupos::config_ini::ConfigIniSettings;
12-
use config::setupos::deployment_json::CompatDeploymentSettings;
12+
use config::setupos::deployment_json::DeploymentSettings;
1313

1414
pub fn create_setupos_config(
1515
config_dir: &Path,
@@ -18,7 +18,7 @@ pub fn create_setupos_config(
1818
node_operator_private_key: Option<&Path>,
1919
nns_public_key: Option<&Path>,
2020
admin_keys: Option<&Path>,
21-
deployment_settings: CompatDeploymentSettings,
21+
deployment_settings: DeploymentSettings,
2222
) -> Result<(), Error> {
2323
// Check that config and data dirs are valid
2424
if !config_dir.is_dir() {

rs/ic_os/dev_test_tools/setupos-image-config/src/main.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use config::setupos::config_ini::ConfigIniSettings;
1212
use tempfile::NamedTempFile;
1313
use url::Url;
1414

15-
use config::setupos::deployment_json::CompatDeploymentSettings;
15+
use config::setupos::deployment_json::DeploymentSettings;
1616
use config_types::DeploymentEnvironment;
1717
use partition_tools::{Partition, ext::ExtPartition, fat::FatPartition};
1818
use setupos_image_config::write_config;
@@ -108,7 +108,7 @@ fn write_public_keys(path: &Path, ks: Vec<String>) -> Result<(), Error> {
108108
fn update_deployment(path: &Path, cfg: &DeploymentConfig) -> Result<(), Error> {
109109
let mut deployment_json = {
110110
let f = File::open(path).context("failed to open deployment config file")?;
111-
let deployment_json: CompatDeploymentSettings = serde_json::from_reader(f)?;
111+
let deployment_json: DeploymentSettings = serde_json::from_reader(f)?;
112112

113113
deployment_json
114114
};
@@ -122,27 +122,15 @@ fn update_deployment(path: &Path, cfg: &DeploymentConfig) -> Result<(), Error> {
122122
}
123123

124124
if let Some(memory) = cfg.memory_gb {
125-
deployment_json
126-
.dev_vm_resources
127-
.get_or_insert_default()
128-
.memory = memory;
129-
deployment_json.vm_resources.get_or_insert_default().memory = memory;
125+
deployment_json.dev_vm_resources.memory = memory;
130126
}
131127

132128
if let Some(cpu) = &cfg.cpu {
133-
deployment_json.dev_vm_resources.get_or_insert_default().cpu = cpu.to_owned();
134-
deployment_json.vm_resources.get_or_insert_default().cpu = cpu.to_owned();
129+
deployment_json.dev_vm_resources.cpu = cpu.to_owned();
135130
}
136131

137132
if let Some(nr_of_vcpus) = &cfg.nr_of_vcpus {
138-
deployment_json
139-
.dev_vm_resources
140-
.get_or_insert_default()
141-
.nr_of_vcpus = nr_of_vcpus.to_owned();
142-
deployment_json
143-
.vm_resources
144-
.get_or_insert_default()
145-
.nr_of_vcpus = nr_of_vcpus.to_owned();
133+
deployment_json.dev_vm_resources.nr_of_vcpus = nr_of_vcpus.to_owned();
146134
}
147135

148136
if let Some(deployment_environment) = &cfg.deployment_environment {

rs/ic_os/os_tools/guest_vm_runner/src/guest_vm_config.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,7 @@ mod tests {
220220
use_ssh_authorized_keys: false,
221221
icos_dev_settings: Default::default(),
222222
},
223-
#[allow(deprecated)]
224223
hostos_settings: HostOSSettings {
225-
vm_memory: 16,
226-
vm_cpu: "qemu".to_string(),
227-
vm_nr_of_vcpus: 56,
228224
verbose: false,
229225
hostos_dev_settings: HostOSDevSettings {
230226
vm_memory: 16,
@@ -311,11 +307,7 @@ mod tests {
311307
fn test_generate_vm_config_qemu() {
312308
test_vm_config(
313309
"guestos_vm_qemu.xml",
314-
#[allow(deprecated)]
315310
HostOSSettings {
316-
vm_memory: 16,
317-
vm_cpu: "qemu".to_string(),
318-
vm_nr_of_vcpus: 56,
319311
hostos_dev_settings: HostOSDevSettings {
320312
vm_memory: 16,
321313
vm_cpu: "qemu".to_string(),
@@ -333,11 +325,7 @@ mod tests {
333325
fn test_generate_vm_config_upgrade_guestos() {
334326
test_vm_config(
335327
"upgrade_guestos.xml",
336-
#[allow(deprecated)]
337328
HostOSSettings {
338-
vm_memory: 16,
339-
vm_cpu: "qemu".to_string(),
340-
vm_nr_of_vcpus: 64,
341329
hostos_dev_settings: HostOSDevSettings {
342330
vm_memory: 16,
343331
vm_cpu: "qemu".to_string(),
@@ -355,11 +343,7 @@ mod tests {
355343
fn test_generate_vm_config_kvm() {
356344
test_vm_config(
357345
"guestos_vm_kvm.xml",
358-
#[allow(deprecated)]
359346
HostOSSettings {
360-
vm_memory: 16,
361-
vm_cpu: "kvm".to_string(),
362-
vm_nr_of_vcpus: 56,
363347
hostos_dev_settings: HostOSDevSettings {
364348
vm_memory: 16,
365349
vm_cpu: "kvm".to_string(),
@@ -377,11 +361,7 @@ mod tests {
377361
fn test_generate_vm_config_sev() {
378362
test_vm_config(
379363
"guestos_vm_sev.xml",
380-
#[allow(deprecated)]
381364
HostOSSettings {
382-
vm_memory: 16,
383-
vm_cpu: "kvm".to_string(),
384-
vm_nr_of_vcpus: 56,
385365
hostos_dev_settings: HostOSDevSettings {
386366
vm_memory: 16,
387367
vm_cpu: "kvm".to_string(),

0 commit comments

Comments
 (0)