diff --git a/src/scheduler.rs b/src/scheduler.rs index 09c13af..188e6f9 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -354,16 +354,9 @@ impl DefaultScheduler { }); // nothing to do } else { - let mut cj = CronJob::default(); - cj.metadata.name = Some(c.0.name.name.clone()); - cj.metadata.namespace = Some(c.0.name.namespace.clone()); - cj.metadata.labels = Some(BTreeMap::from([ - ("skate.io/name".to_string(), c.0.name.name), - ("skate.io/namespace".to_string(), c.0.name.namespace), - ])); actions.push(ScheduledOperation { - resource: SupportedResources::CronJob(cj), + resource: SupportedResources::CronJob(new_cron.clone()), error: None, operation: OpType::Delete, node: Some(c.1.clone()), @@ -403,6 +396,7 @@ impl DefaultScheduler { } fn plan_ingress(state: &ClusterState, ingress: &Ingress) -> Result> { + // TODO - check with current state // TODO - warn about unsupported settings let mut actions = vec!(); diff --git a/src/state/state.rs b/src/state/state.rs index 18c1cd0..ba89dd4 100644 --- a/src/state/state.rs +++ b/src/state/state.rs @@ -308,6 +308,22 @@ impl ClusterState { res } + pub fn locate_ingress(&self, name: &str, namespace: &str) -> Option<(ObjectListItem, &NodeState)> { + let res = self.nodes.iter().find_map(|n| { + n.host_info.as_ref().and_then(|h| { + h.system_info.clone().and_then(|i| { + i.ingresses.and_then(|p| { + p.clone().into_iter().find(|p| { + p.name.name == name && p.name.namespace == namespace + }).map(|p| (p, n)) + }) + }) + }) + }); + res + } + + pub fn locate_deployment(&self, name: &str, namespace: &str) -> Vec<(PodmanPodInfo, &NodeState)> { let name = name.strip_prefix(format!("{}.", namespace).as_str()).unwrap_or(name); self.filter_pods(&|p| p.deployment() == name && p.namespace() == namespace)