Skip to content

Commit

Permalink
remove redundant object
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnedo committed Jul 24, 2024
1 parent 7a5f5a0 commit 38e41c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -403,6 +396,7 @@ impl DefaultScheduler {
}

fn plan_ingress(state: &ClusterState, ingress: &Ingress) -> Result<ApplyPlan, Box<dyn Error>> {

// TODO - check with current state
// TODO - warn about unsupported settings
let mut actions = vec!();
Expand Down
16 changes: 16 additions & 0 deletions src/state/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 38e41c6

Please sign in to comment.