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
+6 -6
View File
@@ -7,9 +7,9 @@
}, },
"tasks": { "tasks": {
"task_a": { "task_a": {
"up": { "command": "/usr//bin/touch ${HOME}/task_a_${yyyymmdd}" }, "up": { "command": "/usr//bin/touch ${HOME}/task_a_${yyyymmdd}", "resources": { "cores": 1 } },
"down": { "command": "/bin/rm ${HOME}/task_a_${yyyymmdd}" }, "down": { "command": "/bin/rm ${HOME}/task_a_${yyyymmdd}", "resources": { "cores": 1 } },
"check": { "command": "/bin/test -e ${HOME}/task_a_${yyyymmdd}" }, "check": { "command": "/bin/test -e ${HOME}/task_a_${yyyymmdd}", "resources": { "cores": 1 } },
"provides": [ "task_a" ], "provides": [ "task_a" ],
@@ -21,9 +21,9 @@
"valid_to": "2022-01-08T09:00:00" "valid_to": "2022-01-08T09:00:00"
}, },
"task_b": { "task_b": {
"up": { "command": "/usr//bin/touch ${HOME}/task_b_${yyyymmdd}" }, "up": { "command": "/usr//bin/touch ${HOME}/task_b_${yyyymmdd}", "resources": { "cores": 1 } },
"down": { "command": "/bin/rm ${HOME}/task_b_${yyyymmdd}" }, "down": { "command": "/bin/rm ${HOME}/task_b_${yyyymmdd}", "resources": { "cores": 1 } },
"check": { "command": "/bin/test -e ${HOME}/task_b_${yyyymmdd}" }, "check": { "command": "/bin/test -e ${HOME}/task_b_${yyyymmdd}", "resources": { "cores": 1 } },
"provides": [ "task_b" ], "provides": [ "task_b" ],
"requires": [ { "resource": "task_a", "offset": 0 } ], "requires": [ { "resource": "task_a", "offset": 0 } ],
+2 -1
View File
@@ -29,7 +29,8 @@ async fn submit_task(
let submission = details.into_inner(); 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 data.executor
.send(ExecutorMessage::ExecuteTask { .send(ExecutorMessage::ExecuteTask {
details: submission.details, details: submission.details,
+2 -2
View File
@@ -69,8 +69,7 @@ impl AgentTarget {
#[derive(Serialize, Deserialize, Clone, Debug)] #[derive(Serialize, Deserialize, Clone, Debug)]
struct AgentTaskDetail { struct AgentTaskDetail {
/// The command and all arguments to run /// The command and all arguments to run
#[serde(default)] command: Cmd,
command: Vec<String>,
/// Environment variables to set /// Environment variables to set
#[serde(default)] #[serde(default)]
@@ -142,6 +141,7 @@ async fn submit_task(
} }
} }
Err(e) => { Err(e) => {
warn!("Failed to submit task: {:?}", e);
attempt.succeeded = false; attempt.succeeded = false;
attempt.infra_failure = true; attempt.infra_failure = true;
attempt.executor.push(format!( attempt.executor.push(format!(
-18
View File
@@ -13,24 +13,6 @@ use tokio::io::AsyncReadExt;
type Environment = HashMap<String, Option<String>>; 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 /// Contains specifics on how to run a local task
#[derive(Serialize, Deserialize, Clone, Debug)] #[derive(Serialize, Deserialize, Clone, Debug)]
struct LocalTaskDetail { struct LocalTaskDetail {
+18
View File
@@ -30,6 +30,24 @@ fn default_bytes() -> usize {
20480 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 /// Options in how to handle task output. Some tasks can be quite
/// verbose, and the output may not be needed. /// verbose, and the output may not be needed.
#[derive(Clone, Serialize, Deserialize, Copy, Debug, PartialEq, Hash, Eq)] #[derive(Clone, Serialize, Deserialize, Copy, Debug, PartialEq, Hash, Eq)]