summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-07-02 14:17:04 -0700
committeriximeow <me@iximeow.net>2023-07-02 14:17:04 -0700
commit2014c6e3e0ab549aabad481d2771a20da19f9ac0 (patch)
tree2250477eb81b210357312ffe5402414af326213d /src
parentf36057d23d5de636e2bb1748738772bf031bebdb (diff)
client ack to new task is now kind:started, status:started
Diffstat (limited to 'src')
-rw-r--r--src/ci_driver.rs50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/ci_driver.rs b/src/ci_driver.rs
index e3cc4c9..c6bef14 100644
--- a/src/ci_driver.rs
+++ b/src/ci_driver.rs
@@ -93,10 +93,19 @@ async fn activate_run(dbctx: Arc<DbCtx>, run: &PendingRun, clients: &mut mpsc::R
continue;
}
- if let Ok(Some(mut client_job)) = candidate.submit(&dbctx, &run, &remote_git_url, &commit_sha).await {
- break client_job;
- } else {
- // failed to submit job, move on for now
+ let res = candidate.submit(&dbctx, &run, &remote_git_url, &commit_sha).await;
+
+ match res {
+ Ok(Some(mut client_job)) => {
+ break client_job;
+ }
+ Ok(None) => {
+ eprintln!("client hung up instead of acking task");
+ }
+ Err(e) => {
+ // failed to submit job, move on for now
+ eprintln!("failed to submit task: {:?}", e);
+ }
}
};
@@ -303,25 +312,22 @@ impl RunnerClient {
remote_url: remote_git_url.to_string(),
build_token: self.build_token.to_string(),
})).await?;
- match self.recv().await {
+ match self.recv_typed::<ClientProto>().await {
+ Ok(Some(ClientProto::Started)) => {
+ let task_witness = Arc::new(());
+ ACTIVE_TASKS.lock().unwrap().insert(job.id, Arc::downgrade(&task_witness));
+ Ok(Some(ClientJob {
+ task: job.clone(),
+ dbctx: Arc::clone(dbctx),
+ sha: sha.to_string(),
+ remote_git_url: remote_git_url.to_string(),
+ client: self,
+ task_witness,
+ }))
+ }
Ok(Some(resp)) => {
- if resp == serde_json::json!({
- "status": "started"
- }) {
- let task_witness = Arc::new(());
- ACTIVE_TASKS.lock().unwrap().insert(job.id, Arc::downgrade(&task_witness));
- eprintln!("resp: {:?}", resp);
- Ok(Some(ClientJob {
- task: job.clone(),
- dbctx: Arc::clone(dbctx),
- sha: sha.to_string(),
- remote_git_url: remote_git_url.to_string(),
- client: self,
- task_witness,
- }))
- } else {
- Err("client rejected job".to_string())
- }
+ eprintln!("invalid response: {:?}", resp);
+ Err("client rejected job".to_string())
}
Ok(None) => {
Ok(None)