From d5fadf4f4454a2b32e11ee3bf5486cfd2551e22a Mon Sep 17 00:00:00 2001 From: Willem Date: Wed, 10 Dec 2025 14:20:24 -0500 Subject: [PATCH] fix: deleted storage node role, fixed erroneous comment, modified score name to be in line with clean code naming conventions, fixed how the OKDNodeInstallationScore is called via OKDSetup03ControlPlaneScore and OKDSetup04WorkersScore --- harmony/src/domain/inventory/mod.rs | 2 - .../modules/okd/bootstrap_03_control_plane.rs | 77 ++----------------- .../src/modules/okd/bootstrap_04_workers.rs | 58 +------------- harmony/src/modules/okd/bootstrap_okd_node.rs | 21 +++-- harmony/src/modules/okd/okd_node.rs | 15 ---- 5 files changed, 23 insertions(+), 150 deletions(-) diff --git a/harmony/src/domain/inventory/mod.rs b/harmony/src/domain/inventory/mod.rs index f7cc1ef..10fabda 100644 --- a/harmony/src/domain/inventory/mod.rs +++ b/harmony/src/domain/inventory/mod.rs @@ -71,7 +71,6 @@ pub enum HostRole { Bootstrap, ControlPlane, Worker, - Storage, } impl fmt::Display for HostRole { @@ -80,7 +79,6 @@ impl fmt::Display for HostRole { HostRole::Bootstrap => write!(f, "Bootstrap"), HostRole::ControlPlane => write!(f, "ControlPlane"), HostRole::Worker => write!(f, "Worker"), - HostRole::Storage => write!(f, "Storage"), } } } diff --git a/harmony/src/modules/okd/bootstrap_03_control_plane.rs b/harmony/src/modules/okd/bootstrap_03_control_plane.rs index 7e882ab..87b90f6 100644 --- a/harmony/src/modules/okd/bootstrap_03_control_plane.rs +++ b/harmony/src/modules/okd/bootstrap_03_control_plane.rs @@ -1,22 +1,8 @@ use crate::{ - data::Version, - hardware::PhysicalHost, - infra::inventory::InventoryRepositoryFactory, - interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}, - inventory::{HostRole, Inventory}, - modules::{ - dhcp::DhcpHostBindingScore, - http::IPxeMacBootFileScore, - inventory::DiscoverHostForRoleScore, - okd::{bootstrap_okd_node::OKDNodeInterpret, templates::BootstrapIpxeTpl}, - }, - score::Score, - topology::{HAClusterTopology, HostBinding}, + interpret::Interpret, inventory::HostRole, modules::okd::bootstrap_okd_node::OKDNodeInterpret, + score::Score, topology::HAClusterTopology, }; -use async_trait::async_trait; use derive_new::new; -use harmony_types::id::Id; -use log::{debug, info}; use serde::Serialize; // ------------------------------------------------------------------------------------------------- @@ -30,64 +16,13 @@ pub struct OKDSetup03ControlPlaneScore {} impl Score for OKDSetup03ControlPlaneScore { fn create_interpret(&self) -> Box> { - Box::new(OKDSetup03ControlPlaneInterpret::new()) + // TODO: Implement a step to wait for the control plane nodes to join the cluster + // and for the cluster operators to become available. This would be similar to + // the `wait-for bootstrap-complete` command. + Box::new(OKDNodeInterpret::new(HostRole::ControlPlane)) } fn name(&self) -> String { "OKDSetup03ControlPlaneScore".to_string() } } - -#[derive(Debug, Clone)] -pub struct OKDSetup03ControlPlaneInterpret { - version: Version, - status: InterpretStatus, -} - -impl OKDSetup03ControlPlaneInterpret { - pub fn new() -> Self { - let version = Version::from("1.0.0").unwrap(); - Self { - version, - status: InterpretStatus::QUEUED, - } - } -} - -#[async_trait] -impl Interpret for OKDSetup03ControlPlaneInterpret { - fn get_name(&self) -> InterpretName { - InterpretName::Custom("OKDSetup03ControlPlane") - } - - fn get_version(&self) -> Version { - self.version.clone() - } - - fn get_status(&self) -> InterpretStatus { - self.status.clone() - } - - fn get_children(&self) -> Vec { - vec![] - } - - async fn execute( - &self, - inventory: &Inventory, - topology: &HAClusterTopology, - ) -> Result { - OKDNodeInterpret::new(HostRole::ControlPlane) - .execute(inventory, topology) - .await?; - - // TODO: Implement a step to wait for the control plane nodes to join the cluster - // and for the cluster operators to become available. This would be similar to - // the `wait-for bootstrap-complete` command. - info!("[ControlPlane] Provisioning initiated. Monitor the cluster convergence manually."); - - Ok(Outcome::success( - "Control plane provisioning has been successfully initiated.".into(), - )) - } -} diff --git a/harmony/src/modules/okd/bootstrap_04_workers.rs b/harmony/src/modules/okd/bootstrap_04_workers.rs index 62bf2ad..c73dce1 100644 --- a/harmony/src/modules/okd/bootstrap_04_workers.rs +++ b/harmony/src/modules/okd/bootstrap_04_workers.rs @@ -1,15 +1,9 @@ -use async_trait::async_trait; use derive_new::new; -use harmony_types::id::Id; use serde::Serialize; use crate::{ - data::Version, - interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}, - inventory::{HostRole, Inventory}, - modules::okd::bootstrap_okd_node::OKDNodeInterpret, - score::Score, - topology::HAClusterTopology, + interpret::Interpret, inventory::HostRole, modules::okd::bootstrap_okd_node::OKDNodeInterpret, + score::Score, topology::HAClusterTopology, }; // ------------------------------------------------------------------------------------------------- @@ -23,56 +17,10 @@ pub struct OKDSetup04WorkersScore {} impl Score for OKDSetup04WorkersScore { fn create_interpret(&self) -> Box> { - Box::new(OKDSetup04WorkersInterpret::new()) + Box::new(OKDNodeInterpret::new(HostRole::Worker)) } fn name(&self) -> String { "OKDSetup04WorkersScore".to_string() } } - -#[derive(Debug, Clone)] -pub struct OKDSetup04WorkersInterpret { - version: Version, - status: InterpretStatus, -} - -impl OKDSetup04WorkersInterpret { - pub fn new() -> Self { - let version = Version::from("1.0.0").unwrap(); - Self { - version, - status: InterpretStatus::QUEUED, - } - } -} - -#[async_trait] -impl Interpret for OKDSetup04WorkersInterpret { - fn get_name(&self) -> InterpretName { - InterpretName::Custom("OKDSetup04Workers") - } - - fn get_version(&self) -> Version { - self.version.clone() - } - - fn get_status(&self) -> InterpretStatus { - self.status.clone() - } - - fn get_children(&self) -> Vec { - vec![] - } - - async fn execute( - &self, - inventory: &Inventory, - topology: &HAClusterTopology, - ) -> Result { - OKDNodeInterpret::new(HostRole::Worker) - .execute(inventory, topology) - .await?; - Ok(Outcome::success("Workers provisioned".into())) - } -} diff --git a/harmony/src/modules/okd/bootstrap_okd_node.rs b/harmony/src/modules/okd/bootstrap_okd_node.rs index a5eb7c2..d5b1d94 100644 --- a/harmony/src/modules/okd/bootstrap_okd_node.rs +++ b/harmony/src/modules/okd/bootstrap_okd_node.rs @@ -26,11 +26,11 @@ use crate::{ }; #[derive(Debug, Clone, Serialize, new)] -pub struct OKDNodeScore { +pub struct OKDNodeInstallationScore { host_role: HostRole, } -impl Score for OKDNodeScore { +impl Score for OKDNodeInstallationScore { fn name(&self) -> String { "OKDNodeScore".to_string() } @@ -55,7 +55,6 @@ impl OKDNodeInterpret { HostRole::Bootstrap => &BootstrapRole, HostRole::ControlPlane => &ControlPlaneRole, HostRole::Worker => &WorkerRole, - HostRole::Storage => &StorageRole, } } @@ -263,10 +262,18 @@ impl Interpret for OKDNodeInterpret { // 4. Reboot the nodes to start the OS installation. self.reboot_targets(&nodes).await?; - - // TODO: Implement a step to wait for the control plane nodes to join the cluster - // and for the cluster operators to become available. This would be similar to - // the `wait-for bootstrap-complete` command. + // TODO: Implement a step to validate that the installation of the nodes is + // complete and for the cluster operators to become available. + // + // The OpenShift installer only provides two wait commands which currently need to be + // run manually: + // - `openshift-install wait-for bootstrap-complete` + // - `openshift-install wait-for install-complete` + // + // There is no installer command that waits specifically for worker node + // provisioning. Worker nodes join asynchronously (via ignition + CSR approval), + // and the cluster becomes fully functional only once all nodes are Ready and the + // cluster operators report Available=True. info!( "[{}] Provisioning initiated. Monitor the cluster convergence manually.", self.host_role diff --git a/harmony/src/modules/okd/okd_node.rs b/harmony/src/modules/okd/okd_node.rs index 687ae5a..39ca53b 100644 --- a/harmony/src/modules/okd/okd_node.rs +++ b/harmony/src/modules/okd/okd_node.rs @@ -52,18 +52,3 @@ impl OKDRoleProperties for WorkerRole { &t.workers } } - -//TODO unsure if this is to be implemented here or not -impl OKDRoleProperties for StorageRole { - fn ignition_file(&self) -> &'static str { - todo!() - } - - fn required_hosts(&self) -> usize { - todo!() - } - - fn logical_hosts<'a>(&self, t: &'a HAClusterTopology) -> &'a Vec { - todo!() - } -}