mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-02 21:00:55 +00:00
fix daemon config references
This commit is contained in:
parent
c9783dc244
commit
d98dc0adec
@ -10,7 +10,7 @@ pub struct DaemonConfig {
|
||||
pub oci: OciConfig,
|
||||
#[serde(default)]
|
||||
pub pci: DaemonPciConfig,
|
||||
#[serde(default)]
|
||||
#[serde(default = "default_network")]
|
||||
pub network: DaemonNetworkConfig,
|
||||
}
|
||||
|
||||
@ -55,6 +55,30 @@ pub enum DaemonPciDeviceRdmReservePolicy {
|
||||
pub struct DaemonNetworkConfig {
|
||||
#[serde(default = "default_network_nameservers")]
|
||||
pub nameservers: Vec<String>,
|
||||
#[serde(default = "default_network_ipv4")]
|
||||
pub ipv4: DaemonIpv4NetworkConfig,
|
||||
#[serde(default = "default_network_ipv6")]
|
||||
pub ipv6: DaemonIpv6NetworkConfig,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
|
||||
pub struct DaemonIpv4NetworkConfig {
|
||||
#[serde(default = "default_network_ipv4_subnet")]
|
||||
pub subnet: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
|
||||
pub struct DaemonIpv6NetworkConfig {
|
||||
#[serde(default = "default_network_ipv6_subnet")]
|
||||
pub subnet: String,
|
||||
}
|
||||
|
||||
fn default_network() -> DaemonNetworkConfig {
|
||||
DaemonNetworkConfig {
|
||||
nameservers: default_network_nameservers(),
|
||||
ipv4: default_network_ipv4(),
|
||||
ipv6: default_network_ipv6(),
|
||||
}
|
||||
}
|
||||
|
||||
fn default_network_nameservers() -> Vec<String> {
|
||||
@ -66,6 +90,26 @@ fn default_network_nameservers() -> Vec<String> {
|
||||
]
|
||||
}
|
||||
|
||||
fn default_network_ipv4() -> DaemonIpv4NetworkConfig {
|
||||
DaemonIpv4NetworkConfig {
|
||||
subnet: default_network_ipv4_subnet(),
|
||||
}
|
||||
}
|
||||
|
||||
fn default_network_ipv4_subnet() -> String {
|
||||
"10.75.80.0/24".to_string()
|
||||
}
|
||||
|
||||
fn default_network_ipv6() -> DaemonIpv6NetworkConfig {
|
||||
DaemonIpv6NetworkConfig {
|
||||
subnet: default_network_ipv6_subnet(),
|
||||
}
|
||||
}
|
||||
|
||||
fn default_network_ipv6_subnet() -> String {
|
||||
"fdd4:1476:6c7e::/48".to_string()
|
||||
}
|
||||
|
||||
impl DaemonConfig {
|
||||
pub async fn load(path: &Path) -> Result<DaemonConfig> {
|
||||
if path.exists() {
|
||||
|
@ -85,13 +85,13 @@ pub struct DaemonIdm {
|
||||
|
||||
impl DaemonIdm {
|
||||
pub async fn new(glt: ZoneLookupTable) -> Result<DaemonIdm> {
|
||||
debug!("allocating channel for IDM");
|
||||
debug!("allocating channel service for idm");
|
||||
let (service, tx_raw_sender, rx_receiver) =
|
||||
ChannelService::new("krata-channel".to_string(), None).await?;
|
||||
let (tx_sender, tx_receiver) = channel(100);
|
||||
let (snoop_sender, _) = broadcast::channel(100);
|
||||
|
||||
debug!("starting channel service");
|
||||
debug!("starting idm channel service");
|
||||
let task = service.launch().await?;
|
||||
|
||||
let clients = Arc::new(Mutex::new(HashMap::new()));
|
||||
|
@ -15,7 +15,6 @@ use krataoci::{packer::service::OciPackerService, registry::OciPlatform};
|
||||
use kratart::Runtime;
|
||||
use log::{debug, info};
|
||||
use reconcile::zone::ZoneReconciler;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::path::Path;
|
||||
use std::{net::SocketAddr, path::PathBuf, str::FromStr, sync::Arc};
|
||||
use tokio::{
|
||||
@ -125,8 +124,8 @@ impl Daemon {
|
||||
DaemonEventGenerator::new(zones.clone(), zone_reconciler_notify.clone(), idm.clone())
|
||||
.await?;
|
||||
let runtime_for_reconciler = runtime.dupe().await?;
|
||||
let ipv4_network = Ipv4Network::new(Ipv4Addr::new(10, 75, 80, 0), 24)?;
|
||||
let ipv6_network = Ipv6Network::from_str("fdd4:1476:6c7e::/48")?;
|
||||
let ipv4_network = Ipv4Network::from_str(&config.network.ipv4.subnet)?;
|
||||
let ipv6_network = Ipv6Network::from_str(&config.network.ipv6.subnet)?;
|
||||
let ip_reservation_store = IpReservationStore::open(database)?;
|
||||
let ip_assignment =
|
||||
IpAssignment::new(host_uuid, ipv4_network, ipv6_network, ip_reservation_store).await?;
|
||||
@ -143,6 +142,7 @@ impl Daemon {
|
||||
initrd_path,
|
||||
addons_path,
|
||||
ip_assignment,
|
||||
config.clone(),
|
||||
)?;
|
||||
|
||||
let zone_reconciler_task = zone_reconciler.launch(zone_reconciler_receiver).await?;
|
||||
@ -176,7 +176,7 @@ impl Daemon {
|
||||
}
|
||||
|
||||
pub async fn listen(&mut self, addr: ControlDialAddress) -> Result<()> {
|
||||
debug!("starting API service");
|
||||
debug!("starting control service");
|
||||
let control_service = DaemonControlService::new(
|
||||
self.glt.clone(),
|
||||
self.devices.clone(),
|
||||
|
@ -12,7 +12,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use crate::config::DaemonPciDeviceRdmReservePolicy;
|
||||
use crate::config::{DaemonConfig, DaemonPciDeviceRdmReservePolicy};
|
||||
use crate::devices::DaemonDeviceManager;
|
||||
use crate::ip::assignment::IpAssignment;
|
||||
use crate::reconcile::zone::ip_reservation_to_network_status;
|
||||
@ -32,6 +32,7 @@ pub struct ZoneCreator<'a> {
|
||||
pub ip_assignment: &'a IpAssignment,
|
||||
pub zlt: &'a ZoneLookupTable,
|
||||
pub runtime: &'a Runtime,
|
||||
pub config: &'a DaemonConfig,
|
||||
}
|
||||
|
||||
impl ZoneCreator<'_> {
|
||||
@ -207,6 +208,7 @@ impl ZoneCreator<'_> {
|
||||
gateway_ipv4: reservation.gateway_ipv4.to_string(),
|
||||
gateway_ipv6: reservation.gateway_ipv6.to_string(),
|
||||
zone_mac: reservation.mac,
|
||||
nameservers: self.config.network.nameservers.clone(),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
|
@ -6,6 +6,7 @@ use std::{
|
||||
};
|
||||
|
||||
use self::create::ZoneCreator;
|
||||
use crate::config::DaemonConfig;
|
||||
use crate::db::ip::IpReservation;
|
||||
use crate::ip::assignment::IpAssignment;
|
||||
use crate::{
|
||||
@ -69,6 +70,7 @@ pub struct ZoneReconciler {
|
||||
zone_reconciler_notify: Sender<Uuid>,
|
||||
zone_reconcile_lock: Arc<RwLock<()>>,
|
||||
ip_assignment: IpAssignment,
|
||||
config: Arc<DaemonConfig>,
|
||||
}
|
||||
|
||||
impl ZoneReconciler {
|
||||
@ -85,6 +87,7 @@ impl ZoneReconciler {
|
||||
initrd_path: PathBuf,
|
||||
modules_path: PathBuf,
|
||||
ip_assignment: IpAssignment,
|
||||
config: Arc<DaemonConfig>,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
devices,
|
||||
@ -100,6 +103,7 @@ impl ZoneReconciler {
|
||||
zone_reconciler_notify,
|
||||
zone_reconcile_lock: Arc::new(RwLock::with_max_readers((), PARALLEL_LIMIT)),
|
||||
ip_assignment,
|
||||
config,
|
||||
})
|
||||
}
|
||||
|
||||
@ -292,6 +296,7 @@ impl ZoneReconciler {
|
||||
ip_assignment: &self.ip_assignment,
|
||||
zlt: &self.zlt,
|
||||
runtime: &self.runtime,
|
||||
config: &self.config,
|
||||
};
|
||||
starter.create(uuid, zone).await
|
||||
}
|
||||
|
@ -60,11 +60,11 @@ impl ChannelService {
|
||||
let (input_sender, input_receiver) = channel(GROUPED_CHANNEL_QUEUE_LEN);
|
||||
let (output_sender, output_receiver) = channel(GROUPED_CHANNEL_QUEUE_LEN);
|
||||
|
||||
debug!("opening Xen event channel");
|
||||
debug!("opening xenevtchn");
|
||||
let evtchn = EventChannelService::open().await?;
|
||||
debug!("opening XenStore");
|
||||
debug!("opening xenstore");
|
||||
let store = XsdClient::open().await?;
|
||||
debug!("opening GrantTab");
|
||||
debug!("opening xengnt");
|
||||
let gnttab = GrantTab::open()?;
|
||||
|
||||
Ok((
|
||||
|
@ -49,6 +49,7 @@ pub struct ZoneLaunchNetwork {
|
||||
pub gateway_ipv4: String,
|
||||
pub gateway_ipv6: String,
|
||||
pub zone_mac: MacAddr6,
|
||||
pub nameservers: Vec<String>,
|
||||
}
|
||||
|
||||
pub struct ZoneLauncher {
|
||||
@ -90,12 +91,7 @@ impl ZoneLauncher {
|
||||
gateway: request.network.gateway_ipv6.to_string(),
|
||||
},
|
||||
resolver: LaunchNetworkResolver {
|
||||
nameservers: vec![
|
||||
"1.1.1.1".to_string(),
|
||||
"1.0.0.1".to_string(),
|
||||
"2606:4700:4700::1111".to_string(),
|
||||
"2606:4700:4700::1001".to_string(),
|
||||
],
|
||||
nameservers: request.network.nameservers,
|
||||
},
|
||||
}),
|
||||
env: request.env,
|
||||
|
Loading…
Reference in New Issue
Block a user