Public release release-e7c2b3ac175d
Source commit: e7c2b3ac175db426791c02779841c5df1d0ffdff Public tree identity: sha256:4f0b7cd828932c06d56f2406788f89b2050ef56c1e1a4f76f55341d387d78e46
This commit is contained in:
parent
9f43c6276a
commit
cfd4f19da2
16 changed files with 1386 additions and 313 deletions
|
|
@ -2,7 +2,8 @@ use std::collections::BTreeSet;
|
|||
use std::time::Instant;
|
||||
|
||||
use clusterflux_core::{
|
||||
ArtifactId, ArtifactMetadata, NodeId, ProcessId, ProjectId, TenantId, UserId,
|
||||
ArtifactId, ArtifactMetadata, NodeId, ProcessId, ProjectId, TaskDefinitionId, TaskInstanceId,
|
||||
TenantId, UserId,
|
||||
};
|
||||
|
||||
use super::keys::{process_control_key, ProcessControlKey};
|
||||
|
|
@ -19,6 +20,9 @@ pub(super) struct StoredProcessSummary {
|
|||
pub(super) ended_at_epoch_seconds: Option<u64>,
|
||||
pub(super) final_result: Option<ProcessFinalResult>,
|
||||
pub(super) connected_nodes: Vec<NodeId>,
|
||||
pub(super) main_task_definition: Option<TaskDefinitionId>,
|
||||
pub(super) main_task_instance: Option<TaskInstanceId>,
|
||||
pub(super) main_terminal_state: Option<super::TaskTerminalState>,
|
||||
pub(super) order: u64,
|
||||
}
|
||||
|
||||
|
|
@ -84,10 +88,16 @@ impl CoordinatorService {
|
|||
}
|
||||
}
|
||||
self.recent_log_dropped_through.remove(&key);
|
||||
self.recent_log_offsets
|
||||
.retain(|(entry_tenant, entry_project, entry_process, _, _), _| {
|
||||
self.recent_log_accounted_bytes.retain(
|
||||
|(entry_tenant, entry_project, entry_process, _, _), _| {
|
||||
entry_tenant != tenant || entry_project != project || entry_process != process
|
||||
});
|
||||
},
|
||||
);
|
||||
self.recent_log_truncated_streams.retain(
|
||||
|(entry_tenant, entry_project, entry_process, _, _)| {
|
||||
entry_tenant != tenant || entry_project != project || entry_process != process
|
||||
},
|
||||
);
|
||||
self.process_summary_order
|
||||
.retain(|retained| retained != &key);
|
||||
self.evict_process_summaries_for_project(tenant, project);
|
||||
|
|
@ -101,6 +111,9 @@ impl CoordinatorService {
|
|||
ended_at_epoch_seconds: None,
|
||||
final_result: None,
|
||||
connected_nodes: Vec::new(),
|
||||
main_task_definition: None,
|
||||
main_task_instance: None,
|
||||
main_terminal_state: None,
|
||||
order,
|
||||
},
|
||||
);
|
||||
|
|
@ -133,6 +146,9 @@ impl CoordinatorService {
|
|||
ended_at_epoch_seconds: None,
|
||||
final_result: None,
|
||||
connected_nodes: Vec::new(),
|
||||
main_task_definition: None,
|
||||
main_task_instance: None,
|
||||
main_terminal_state: None,
|
||||
order,
|
||||
}
|
||||
});
|
||||
|
|
@ -141,6 +157,31 @@ impl CoordinatorService {
|
|||
entry.connected_nodes = connected_nodes;
|
||||
}
|
||||
|
||||
pub(super) fn record_main_terminal_state(
|
||||
&mut self,
|
||||
tenant: &TenantId,
|
||||
project: &ProjectId,
|
||||
process: &ProcessId,
|
||||
task_definition: TaskDefinitionId,
|
||||
task_instance: TaskInstanceId,
|
||||
terminal_state: super::TaskTerminalState,
|
||||
) {
|
||||
let key = process_control_key(tenant, project, process);
|
||||
if !self.process_summaries.contains_key(&key) {
|
||||
self.record_process_started(
|
||||
tenant,
|
||||
project,
|
||||
process,
|
||||
self.liveness_now_epoch_seconds(),
|
||||
);
|
||||
}
|
||||
if let Some(summary) = self.process_summaries.get_mut(&key) {
|
||||
summary.main_task_definition = Some(task_definition);
|
||||
summary.main_task_instance = Some(task_instance);
|
||||
summary.main_terminal_state = Some(terminal_state);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn handle_list_process_summaries(
|
||||
&mut self,
|
||||
tenant: String,
|
||||
|
|
@ -449,10 +490,7 @@ impl CoordinatorService {
|
|||
let Some(candidate) = candidate.cloned() else {
|
||||
break;
|
||||
};
|
||||
self.process_summaries.remove(&candidate);
|
||||
self.recent_log_dropped_through.remove(&candidate);
|
||||
self.process_summary_order
|
||||
.retain(|retained| retained != &candidate);
|
||||
self.remove_process_summary_state(&candidate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -466,12 +504,30 @@ impl CoordinatorService {
|
|||
let Some(candidate) = candidate.cloned() else {
|
||||
break;
|
||||
};
|
||||
self.process_summaries.remove(&candidate);
|
||||
self.recent_log_dropped_through.remove(&candidate);
|
||||
self.process_summary_order
|
||||
.retain(|retained| retained != &candidate);
|
||||
self.remove_process_summary_state(&candidate);
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_process_summary_state(&mut self, key: &super::ProcessControlKey) {
|
||||
self.process_summaries.remove(key);
|
||||
self.recent_log_dropped_through.remove(key);
|
||||
if let Some(logs) = self.recent_logs.get_mut(&(key.0.clone(), key.1.clone())) {
|
||||
logs.retain(|entry| entry.process != key.2);
|
||||
if logs.is_empty() {
|
||||
self.recent_logs.remove(&(key.0.clone(), key.1.clone()));
|
||||
}
|
||||
}
|
||||
self.recent_log_accounted_bytes
|
||||
.retain(|(tenant, project, process, _, _), _| {
|
||||
tenant != &key.0 || project != &key.1 || process != &key.2
|
||||
});
|
||||
self.recent_log_truncated_streams
|
||||
.retain(|(tenant, project, process, _, _)| {
|
||||
tenant != &key.0 || project != &key.1 || process != &key.2
|
||||
});
|
||||
self.process_summary_order
|
||||
.retain(|retained| retained != key);
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_order_cursor(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue