Remote agent working now
This commit is contained in:
parent
834b0f2c9c
commit
d82b000f9b
@@ -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,
|
||||
|
||||
@@ -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!(
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user