Public release release-b8454b34d38c
Source commit: b8454b34d38cc2ba0bd278e842060db45d091e1c Public tree identity: sha256:69d6c8143bf6227e1bb07852aa94e8af9c26793eca252bb46788894f728cb6d2
This commit is contained in:
commit
d2e84229c5
221 changed files with 80960 additions and 0 deletions
89
crates/clusterflux-dap/src/view_state.rs
Normal file
89
crates/clusterflux-dap/src/view_state.rs
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::virtual_model::{AdapterState, RuntimeLaunchRecord};
|
||||
|
||||
pub(crate) fn normalize_coordinator_endpoint(endpoint: &str) -> String {
|
||||
endpoint.trim().trim_end_matches('/').to_owned()
|
||||
}
|
||||
|
||||
pub(crate) fn write_view_state(state: &AdapterState, record: &RuntimeLaunchRecord) -> Result<()> {
|
||||
let dir = Path::new(&state.project).join(".clusterflux");
|
||||
fs::create_dir_all(&dir)?;
|
||||
let node_status = if record.placed_task_launched {
|
||||
if record.status_code == Some(0) {
|
||||
"completed"
|
||||
} else {
|
||||
"failed"
|
||||
}
|
||||
} else {
|
||||
"not-required-yet"
|
||||
};
|
||||
let process_status = if record.placed_task_launched {
|
||||
if record.status_code == Some(0) {
|
||||
"completed"
|
||||
} else {
|
||||
"failed"
|
||||
}
|
||||
} else {
|
||||
"running"
|
||||
};
|
||||
let log_message = if record.placed_task_launched {
|
||||
"node task output was staged as a VFS artifact"
|
||||
} else {
|
||||
"coordinator-side virtual process started; capability task not launched"
|
||||
};
|
||||
let artifact_status = if record.placed_task_launched {
|
||||
"best-effort retained on the attached node"
|
||||
} else {
|
||||
"not produced until a capability task is placed"
|
||||
};
|
||||
let view_state = json!({
|
||||
"nodes": [{
|
||||
"id": record.node,
|
||||
"status": node_status,
|
||||
"capabilities": format!("connected to {}", record.coordinator),
|
||||
}],
|
||||
"processes": [{
|
||||
"id": state.process.as_str(),
|
||||
"status": process_status,
|
||||
"entry": state.entry,
|
||||
}],
|
||||
"logs": [{
|
||||
"task": "compile-linux",
|
||||
"message": log_message,
|
||||
"bytes": format!("stdout={} stderr={}", record.stdout_bytes, record.stderr_bytes),
|
||||
}],
|
||||
"artifacts": [{
|
||||
"path": record.artifact_path.clone().unwrap_or_else(|| "/vfs/artifacts/dap-output.txt".to_owned()),
|
||||
"status": artifact_status,
|
||||
"size": "reported by node",
|
||||
}],
|
||||
"inspector": [
|
||||
{
|
||||
"label": "Runtime backend",
|
||||
"value": state.runtime_backend.description(),
|
||||
},
|
||||
{
|
||||
"label": "Coordinator",
|
||||
"value": record.coordinator,
|
||||
},
|
||||
{
|
||||
"label": "Node report",
|
||||
"value": record.node_report.to_string(),
|
||||
},
|
||||
{
|
||||
"label": "Task events",
|
||||
"value": record.task_events.to_string(),
|
||||
}
|
||||
]
|
||||
});
|
||||
fs::write(
|
||||
dir.join("views.json"),
|
||||
serde_json::to_string_pretty(&view_state)?,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue