Skip to content

Commit

Permalink
feat(node): update-config.service (#2393)
Browse files Browse the repository at this point in the history
NODE-1493

update-config.service updates the old ic-os config format to the new
ic-os config format: #1539

Once all node have an updated version of the config, we will be able to
switch nodes to _[actually
use](#1563 the new config format.
Then, once stable, we will delete update-config.service

I've successfully tested on farm and bare metal 🥳

---------

Co-authored-by: IDX GitHub Automation <infra+github-automation@dfinity.org>
  • Loading branch information
andrewbattat and IDX GitHub Automation authored Dec 4, 2024
1 parent 6e5283d commit b6e0faa
Show file tree
Hide file tree
Showing 11 changed files with 607 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ic-os/components/guestos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@ component_files = {

# fstrim
Label("fstrim/sync_fstrim.sh"): "/opt/ic/bin/sync_fstrim.sh",

# TODO(NODE-1519): delete update-config.service after switch to new icos config
Label("misc/update-config/update-guestos-config.service"): "/etc/systemd/system/update-config.service",
}
3 changes: 3 additions & 0 deletions ic-os/components/hostos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,7 @@ component_files = {
Label("upgrade/systemd-generators/hostos/mount-generator"): "/etc/systemd/system-generators/mount-generator",
Label("upgrade/systemd-generators/systemd-gpt-auto-generator"): "/etc/systemd/system-generators/systemd-gpt-auto-generator",
Label("upgrade/install-upgrade.sh"): "/opt/ic/bin/install-upgrade.sh",

# TODO(NODE-1519): delete update-config.service after switch to new icos config
Label("misc/update-config/update-hostos-config.service"): "/etc/systemd/system/update-config.service",
}
12 changes: 12 additions & 0 deletions ic-os/components/misc/update-config/update-guestos-config.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Update GuestOS Configuration
After=bootstrap-ic-node.service
Requires=bootstrap-ic-node.service

[Service]
Type=oneshot
ExecStart=/opt/ic/bin/config update-guestos-config
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
10 changes: 10 additions & 0 deletions ic-os/components/misc/update-config/update-hostos-config.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Update HostOS Configuration

[Service]
Type=oneshot
ExecStart=/opt/ic/bin/config update-hostos-config
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions ic-os/guestos/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def image_deps(mode, malicious = False):

# additional libraries to install
"//rs/ic_os/release:nss_icos": "/usr/lib/x86_64-linux-gnu/libnss_icos.so.2:0644", # Allows referring to the guest IPv6 by name guestos from host, and host as hostos from guest.

# TODO(NODE-1519): delete config tool from guestos after switch to new icos config
"//rs/ic_os/release:config": "/opt/ic/bin/config:0755",
},

# Set various configuration values
Expand Down
1 change: 1 addition & 0 deletions ic-os/hostos/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def image_deps(mode, _malicious = False):
"//rs/ic_os/release:vsock_host": "/opt/ic/bin/vsock_host:0755",
"//rs/ic_os/release:hostos_tool": "/opt/ic/bin/hostos_tool:0755",
"//rs/ic_os/release:metrics-proxy": "/opt/ic/bin/metrics-proxy:0755",
"//rs/ic_os/release:config": "/opt/ic/bin/config:0755",

# additional libraries to install
"//rs/ic_os/release:nss_icos": "/usr/lib/x86_64-linux-gnu/libnss_icos.so.2:0644",
Expand Down
2 changes: 1 addition & 1 deletion rs/ic_os/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package(default_visibility = ["//rs:ic-os-pkg"])
DEPENDENCIES = [
# Keep sorted.
"//rs/ic_os/config_types",
"//rs/ic_os/network",
"//rs/ic_os/utils",
"//rs/types/types",
"@crate_index//:anyhow",
Expand Down Expand Up @@ -47,7 +48,6 @@ rust_binary(
proc_macro_deps = MACRO_DEPENDENCIES,
deps = [
":config_lib",
"//rs/ic_os/network",
] + DEPENDENCIES,
)

Expand Down
1 change: 1 addition & 0 deletions rs/ic_os/config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod config_ini;
pub mod deployment_json;
pub mod generate_testnet_config;
pub mod update_config;

use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
Expand Down
27 changes: 27 additions & 0 deletions rs/ic_os/config/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use clap::{Args, Parser, Subcommand};
use config::config_ini::{get_config_ini_settings, ConfigIniSettings};
use config::deployment_json::get_deployment_settings;
use config::serialize_and_write_config;
use config::update_config::{update_guestos_config, update_hostos_config};
use macaddr::MacAddr6;
use network::resolve_mgmt_mac;
use regex::Regex;
Expand Down Expand Up @@ -55,6 +56,18 @@ pub enum Commands {
},
/// Creates a GuestOSConfig object directly from GenerateTestnetConfigClapArgs. Only used for testing purposes.
GenerateTestnetConfig(GenerateTestnetConfigClapArgs),
/// Creates a GuestOSConfig object from existing guestos configuration files
UpdateGuestosConfig,
UpdateHostosConfig {
#[arg(long, default_value = config::DEFAULT_HOSTOS_CONFIG_INI_FILE_PATH, value_name = "config.ini")]
config_ini_path: PathBuf,

#[arg(long, default_value = config::DEFAULT_HOSTOS_DEPLOYMENT_JSON_PATH, value_name = "deployment.json")]
deployment_json_path: PathBuf,

#[arg(long, default_value = config::DEFAULT_HOSTOS_CONFIG_OBJECT_PATH, value_name = "config.json")]
hostos_config_json_path: PathBuf,
},
}

#[derive(Parser)]
Expand Down Expand Up @@ -245,6 +258,7 @@ pub fn main() -> Result<()> {
hostos_settings,
guestos_settings,
};
// SetupOSConfig is safe to log; it does not contain any secret material
println!("SetupOSConfig: {:?}", setupos_config);

let setupos_config_json_path = Path::new(&setupos_config_json_path);
Expand Down Expand Up @@ -367,6 +381,19 @@ pub fn main() -> Result<()> {

generate_testnet_config(args, clap_args.guestos_config_json_path)
}
// TODO(NODE-1519): delete UpdateGuestosConfig and UpdateHostosConfig after moved to new config format
// Regenerate config.json on *every boot* in case the config structure changes between
// when we roll out the update-config service and when we roll out the 'config integration'
Some(Commands::UpdateGuestosConfig) => update_guestos_config(),
Some(Commands::UpdateHostosConfig {
config_ini_path,
deployment_json_path,
hostos_config_json_path,
}) => update_hostos_config(
&config_ini_path,
&deployment_json_path,
&hostos_config_json_path,
),
None => {
println!("No command provided. Use --help for usage information.");
Ok(())
Expand Down
Loading

0 comments on commit b6e0faa

Please sign in to comment.