wip: OKd installation, some cleanup of unused and some refactoring
All checks were successful
Run Check Script / check (pull_request) Successful in 1m13s

This commit is contained in:
2025-09-01 23:36:35 -04:00
parent 35a459f63c
commit 241980ebec
9 changed files with 177 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
use crate::{
hardware::PhysicalHost,
inventory::{InventoryRepository, RepoError},
inventory::{HostRole, InventoryRepository, RepoError},
};
use async_trait::async_trait;
use harmony_types::id::Id;
@@ -55,6 +55,18 @@ impl InventoryRepository for SqliteInventoryRepository {
.await?;
todo!()
}
async fn get_all_hosts(&self) -> Result<Vec<PhysicalHost>, RepoError> {
todo!()
}
async fn save_role_mapping(
&self,
role: &HostRole,
host: &PhysicalHost,
) -> Result<(), RepoError> {
todo!("save role, host.id in the table host_role_mapping")
}
}
use sqlx::types::Json;

View File

@@ -44,12 +44,10 @@
//! which must be configured on host AND switch to connect properly.
//!
//! Configuration knobs
//! - lan_cidr: CIDR to scan/allow for discovery endpoints.
//! - public_domain: External wildcard/apps domain (e.g., apps.example.com).
//! - internal_domain: Internal cluster domain (e.g., cluster.local or harmony.mcd).
use async_trait::async_trait;
use chrono::Duration;
use derive_new::new;
use harmony_types::id::Id;
use log::{error, info, warn};
@@ -75,14 +73,7 @@ use crate::{
// -------------------------------------------------------------------------------------------------
#[derive(Debug, Clone, Serialize, Deserialize, new)]
pub struct OKDInstallationScore {
/// The LAN CIDR where discovery endpoints live (e.g., 192.168.10.0/24)
pub lan_cidr: String,
/// Public external domain (e.g., example.com). Used for api/apps wildcard, etc.
pub public_domain: String,
/// Internal cluster domain (e.g., harmony.mcd). Used for internal svc/ingress and DNS.
pub internal_domain: String,
}
pub struct OKDInstallationScore {}
impl Score<HAClusterTopology> for OKDInstallationScore {
fn create_interpret(&self) -> Box<dyn Interpret<HAClusterTopology>> {
@@ -123,7 +114,7 @@ impl OKDInstallationInterpret {
// 1) Prepare DNS and DHCP lease registration (optional)
// 2) Serve default iPXE + Kickstart and poll discovery
let discovery_score = OKDSetup01InventoryScore::new(self.score.lan_cidr.clone());
let discovery_score = OKDSetup01InventoryScore::new();
discovery_score.interpret(inventory, topology).await?;
Ok(())
@@ -135,10 +126,7 @@ impl OKDInstallationInterpret {
topology: &HAClusterTopology,
) -> Result<(), InterpretError> {
// Select and provision bootstrap
let bootstrap_score = OKDSetup02BootstrapScore::new(
self.score.public_domain.clone(),
self.score.internal_domain.clone(),
);
let bootstrap_score = OKDSetup02BootstrapScore::new();
bootstrap_score.interpret(inventory, topology).await?;
Ok(())
}
@@ -178,10 +166,7 @@ impl OKDInstallationInterpret {
inventory: &Inventory,
topology: &HAClusterTopology,
) -> Result<(), InterpretError> {
let report_score = OKDSetup06InstallationReportScore::new(
self.score.public_domain.clone(),
self.score.internal_domain.clone(),
);
let report_score = OKDSetup06InstallationReportScore::new();
report_score.interpret(inventory, topology).await?;
Ok(())
}
@@ -212,10 +197,7 @@ impl Interpret<HAClusterTopology> for OKDInstallationInterpret {
) -> Result<Outcome, InterpretError> {
instrument(HarmonyEvent::HarmonyStarted).ok();
info!(
"Starting OKD installation pipeline for public_domain={} internal_domain={} lan_cidr={}",
self.score.public_domain, self.score.internal_domain, self.score.lan_cidr
);
info!("Starting OKD installation pipeline",);
self.run_inventory_phase(inventory, topology).await?;
@@ -400,10 +382,7 @@ impl Interpret<HAClusterTopology> for OKDSetup01InventoryInterpret {
// -------------------------------------------------------------------------------------------------
#[derive(Debug, Clone, Serialize, new)]
struct OKDSetup02BootstrapScore {
public_domain: String,
internal_domain: String,
}
struct OKDSetup02BootstrapScore {}
impl Score<HAClusterTopology> for OKDSetup02BootstrapScore {
fn create_interpret(&self) -> Box<dyn Interpret<HAClusterTopology>> {
@@ -754,10 +733,7 @@ impl Interpret<HAClusterTopology> for OKDSetup05SanityCheckInterpret {
// -------------------------------------------------------------------------------------------------
#[derive(Debug, Clone, Serialize, new)]
struct OKDSetup06InstallationReportScore {
public_domain: String,
internal_domain: String,
}
struct OKDSetup06InstallationReportScore {}
impl Score<HAClusterTopology> for OKDSetup06InstallationReportScore {
fn create_interpret(&self) -> Box<dyn Interpret<HAClusterTopology>> {
@@ -787,10 +763,7 @@ impl OKDSetup06InstallationReportInterpret {
}
async fn generate(&self) -> Result<(), InterpretError> {
info!(
"[Report] Generating installation report for {} / {}",
self.score.public_domain, self.score.internal_domain
);
info!("[Report] Generating OKD installation report",);
Ok(())
}
}