Remote agent working now

This commit is contained in:
Kinesin Data Technologies Incorporated
2022-10-05 10:20:54 -03:00
parent 834b0f2c9c
commit d82b000f9b
5 changed files with 28 additions and 27 deletions
+2 -1
View File
@@ -29,7 +29,8 @@ async fn submit_task(
let submission = details.into_inner();
let (_, kill) = oneshot::channel();
// Need to keep this unused, otherwise the LE will kill it immediately
let (kill_tx, kill) = oneshot::channel();
data.executor
.send(ExecutorMessage::ExecuteTask {
details: submission.details,
+2 -2
View File
@@ -69,8 +69,7 @@ impl AgentTarget {
#[derive(Serialize, Deserialize, Clone, Debug)]
struct AgentTaskDetail {
/// The command and all arguments to run
#[serde(default)]
command: Vec<String>,
command: Cmd,
/// Environment variables to set
#[serde(default)]
@@ -142,6 +141,7 @@ async fn submit_task(
}
}
Err(e) => {
warn!("Failed to submit task: {:?}", e);
attempt.succeeded = false;
attempt.infra_failure = true;
attempt.executor.push(format!(
-18
View File
@@ -13,24 +13,6 @@ use tokio::io::AsyncReadExt;
type Environment = HashMap<String, Option<String>>;
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(untagged)]
enum Cmd {
Simple(String),
Split(Vec<String>),
}
impl Cmd {
fn generate(&self, varmap: &VarMap) -> Vec<String> {
let cmd = match self {
Cmd::Simple(s) => s.split_whitespace().map(|x| x.to_string()).collect(),
Cmd::Split(v) => v.clone(),
};
cmd.into_iter().map(|x| varmap.apply_to(&x)).collect()
}
}
/// Contains specifics on how to run a local task
#[derive(Serialize, Deserialize, Clone, Debug)]
struct LocalTaskDetail {
+18
View File
@@ -30,6 +30,24 @@ fn default_bytes() -> usize {
20480
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(untagged)]
pub enum Cmd {
Simple(String),
Split(Vec<String>),
}
impl Cmd {
pub fn generate(&self, varmap: &VarMap) -> Vec<String> {
let cmd = match self {
Cmd::Simple(s) => s.split_whitespace().map(|x| x.to_string()).collect(),
Cmd::Split(v) => v.clone(),
};
cmd.into_iter().map(|x| varmap.apply_to(&x)).collect()
}
}
/// Options in how to handle task output. Some tasks can be quite
/// verbose, and the output may not be needed.
#[derive(Clone, Serialize, Deserialize, Copy, Debug, PartialEq, Hash, Eq)]