From 893a7190e894ec9995de0d60734c61afb04c5e72 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Sat, 30 Mar 2024 15:20:44 +0530 Subject: [PATCH 1/4] fix: need not retry HTTP status errors (#332) --- uplink/src/collector/downloader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uplink/src/collector/downloader.rs b/uplink/src/collector/downloader.rs index abe8e53cb..0d2f0ef3d 100644 --- a/uplink/src/collector/downloader.rs +++ b/uplink/src/collector/downloader.rs @@ -185,7 +185,7 @@ impl FileDownloader { loop { match self.download(req, &mut download).await { Ok(_) => break, - Err(Error::Reqwest(e)) => error!("Download failed: {e}"), + Err(Error::Reqwest(e)) if !e.is_status() => error!("Download failed: {e}"), Err(e) => return Err(e), } tokio::time::sleep(Duration::from_secs(1)).await; From 88b0fba332cfda13ef17f1780e7a6ee80c4abcc1 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 1 Apr 2024 14:30:56 +0530 Subject: [PATCH 2/4] deprecate kind field in actions (#331) --- uplink/src/base/actions.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/uplink/src/base/actions.rs b/uplink/src/base/actions.rs index 047950bf3..1433a1eab 100644 --- a/uplink/src/base/actions.rs +++ b/uplink/src/base/actions.rs @@ -13,8 +13,6 @@ pub struct Action { // action id #[serde(alias = "id")] pub action_id: String, - // determines if action is a process - pub kind: String, // action name pub name: String, // action payload. json. can be args/payload. depends on the invoked command From 2f365e85ed7a44e43f77ffa6f4e94bb1f62e4391 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 1 Apr 2024 20:20:32 +0530 Subject: [PATCH 3/4] test: fix merge --- uplink/src/base/bridge/actions_lane.rs | 10 ---------- uplink/src/collector/downloader.rs | 3 --- uplink/src/collector/script_runner.rs | 2 -- 3 files changed, 15 deletions(-) diff --git a/uplink/src/base/bridge/actions_lane.rs b/uplink/src/base/bridge/actions_lane.rs index 3aeda03d7..5fc0d5eea 100644 --- a/uplink/src/base/bridge/actions_lane.rs +++ b/uplink/src/base/bridge/actions_lane.rs @@ -560,7 +560,6 @@ mod tests { let action_1 = Action { action_id: "1".to_string(), - kind: "test".to_string(), name: "route_1".to_string(), payload: "test".to_string(), deadline: None, @@ -584,7 +583,6 @@ mod tests { let action_2 = Action { action_id: "2".to_string(), - kind: "test".to_string(), name: "route_2".to_string(), payload: "test".to_string(), deadline: None, @@ -628,7 +626,6 @@ mod tests { let action_1 = Action { action_id: "1".to_string(), - kind: "test".to_string(), name: "test".to_string(), payload: "test".to_string(), deadline: None, @@ -643,7 +640,6 @@ mod tests { let action_2 = Action { action_id: "2".to_string(), - kind: "test".to_string(), name: "test".to_string(), payload: "test".to_string(), deadline: None, @@ -684,7 +680,6 @@ mod tests { let action = Action { action_id: "1".to_string(), - kind: "test".to_string(), name: "test".to_string(), payload: "test".to_string(), deadline: None, @@ -749,7 +744,6 @@ mod tests { let action = Action { action_id: "1".to_string(), - kind: "test".to_string(), name: "test".to_string(), payload: "test".to_string(), deadline: None, @@ -819,7 +813,6 @@ mod tests { let action = Action { action_id: "1".to_string(), - kind: "tunshell".to_string(), name: "launch_shell".to_string(), payload: "test".to_string(), deadline: None, @@ -830,7 +823,6 @@ mod tests { let action = Action { action_id: "2".to_string(), - kind: "test".to_string(), name: "test".to_string(), payload: "test".to_string(), deadline: None, @@ -910,7 +902,6 @@ mod tests { let action = Action { action_id: "1".to_string(), - kind: "test".to_string(), name: "test".to_string(), payload: "test".to_string(), deadline: None, @@ -921,7 +912,6 @@ mod tests { let action = Action { action_id: "2".to_string(), - kind: "tunshell".to_string(), name: "launch_shell".to_string(), payload: "test".to_string(), deadline: None, diff --git a/uplink/src/collector/downloader.rs b/uplink/src/collector/downloader.rs index 0d2f0ef3d..a3a1442cf 100644 --- a/uplink/src/collector/downloader.rs +++ b/uplink/src/collector/downloader.rs @@ -512,7 +512,6 @@ mod test { expected_forward.download_path = Some(downloader_path); let download_action = Action { action_id: "1".to_string(), - kind: "firmware_update".to_string(), name: "firmware_update".to_string(), payload: json!(download_update).to_string(), deadline: Some(Instant::now() + Duration::from_secs(60)), @@ -573,7 +572,6 @@ mod test { }; let correct_action = Action { action_id: "1".to_string(), - kind: "firmware_update".to_string(), name: "firmware_update".to_string(), payload: json!(correct_update).to_string(), deadline: Some(Instant::now() + Duration::from_secs(100)), @@ -612,7 +610,6 @@ mod test { }; let wrong_action = Action { action_id: "1".to_string(), - kind: "firmware_update".to_string(), name: "firmware_update".to_string(), payload: json!(wrong_update).to_string(), deadline: Some(Instant::now() + Duration::from_secs(100)), diff --git a/uplink/src/collector/script_runner.rs b/uplink/src/collector/script_runner.rs index 3539796fd..1f970e490 100644 --- a/uplink/src/collector/script_runner.rs +++ b/uplink/src/collector/script_runner.rs @@ -176,7 +176,6 @@ mod tests { actions_tx .send(Action { action_id: "1".to_string(), - kind: "1".to_string(), name: "test".to_string(), payload: "".to_string(), deadline: None, @@ -200,7 +199,6 @@ mod tests { actions_tx .send(Action { action_id: "1".to_string(), - kind: "1".to_string(), name: "test".to_string(), payload: "{\"url\": \"...\", \"content_length\": 0,\"file_name\": \"...\"}" .to_string(), From 155fbaa31baf985bded1d9d699a046f238a65cca Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 1 Apr 2024 20:23:25 +0530 Subject: [PATCH 4/4] fix: forward error messages triggering retry (#333) This is for observability --- uplink/src/collector/downloader.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/uplink/src/collector/downloader.rs b/uplink/src/collector/downloader.rs index a3a1442cf..c9fba6790 100644 --- a/uplink/src/collector/downloader.rs +++ b/uplink/src/collector/downloader.rs @@ -185,7 +185,13 @@ impl FileDownloader { loop { match self.download(req, &mut download).await { Ok(_) => break, - Err(Error::Reqwest(e)) if !e.is_status() => error!("Download failed: {e}"), + Err(Error::Reqwest(e)) if !e.is_status() => { + let status = ActionResponse::progress(&self.action_id, "Download Failed", 0) + .set_sequence(self.sequence()) + .add_error(e.to_string()); + self.bridge_tx.send_action_response(status).await; + error!("Download failed: {e}"); + } Err(e) => return Err(e), } tokio::time::sleep(Duration::from_secs(1)).await;