From 83c1cc82b64c2839c9734b29dd28432141be4570 Mon Sep 17 00:00:00 2001 From: Ian Letourneau Date: Tue, 11 Nov 2025 14:12:56 +0000 Subject: [PATCH] fix(host_network): remove extra fields from bond config to prevent clashes (#186) Also alias `port` to support both `port` and `ports` as per the nmstate spec. Reviewed-on: https://git.nationtech.io/NationTech/harmony/pulls/186 --- harmony/src/infra/network_manager.rs | 4 +--- harmony/src/modules/okd/crd/nmstate.rs | 1 + harmony_types/src/net.rs | 10 +++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/harmony/src/infra/network_manager.rs b/harmony/src/infra/network_manager.rs index 89321fe..e5dbd24 100644 --- a/harmony/src/infra/network_manager.rs +++ b/harmony/src/infra/network_manager.rs @@ -135,8 +135,6 @@ impl OpenShiftNmStateNetworkManager { description: Some(format!("Member of bond {bond_name}")), r#type: nmstate::InterfaceType::Ethernet, state: "up".to_string(), - mtu: Some(switch_port.interface.mtu), - mac_address: Some(switch_port.interface.mac_address.to_string()), ipv4: Some(nmstate::IpStackSpec { enabled: Some(false), ..Default::default() @@ -162,7 +160,7 @@ impl OpenShiftNmStateNetworkManager { interfaces.push(nmstate::Interface { name: bond_name.to_string(), - description: Some(format!("Network bond for host {host}")), + description: Some(format!("HARMONY - Network bond for host {host}")), r#type: nmstate::InterfaceType::Bond, state: "up".to_string(), copy_mac_from, diff --git a/harmony/src/modules/okd/crd/nmstate.rs b/harmony/src/modules/okd/crd/nmstate.rs index f0eb4ae..3055766 100644 --- a/harmony/src/modules/okd/crd/nmstate.rs +++ b/harmony/src/modules/okd/crd/nmstate.rs @@ -417,6 +417,7 @@ pub struct EthernetSpec { #[serde(rename_all = "kebab-case")] pub struct BondSpec { pub mode: String, + #[serde(alias = "port")] pub ports: Vec, #[serde(skip_serializing_if = "Option::is_none")] pub options: Option>, diff --git a/harmony_types/src/net.rs b/harmony_types/src/net.rs index 51de86e..6086e54 100644 --- a/harmony_types/src/net.rs +++ b/harmony_types/src/net.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord)] pub struct MacAddress(pub [u8; 6]); impl MacAddress { @@ -19,6 +19,14 @@ impl From<&MacAddress> for String { } } +impl std::fmt::Debug for MacAddress { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_tuple("MacAddress") + .field(&String::from(self)) + .finish() + } +} + impl std::fmt::Display for MacAddress { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(&String::from(self))